Admin/isatest-check
author haftmann
Sun Jun 05 14:33:02 2005 +0200 (2005-06-05)
changeset 16275 951803bff5b1
parent 16178 754efc5afd5d
child 16362 f321def7279c
permissions -rwxr-xr-x
a more spohisticated symlink handling
kleing@13986
     1
#!/usr/bin/env bash
kleing@13986
     2
#
kleing@13986
     3
# $Id$
kleing@13986
     4
# Author: Gerwin Klein, TU Muenchen
kleing@13986
     5
#
kleing@13993
     6
# DESCRIPTION: sends email for failed tests, checks for error.log,
kleing@13993
     7
#              generates development snapshot if test ok
kleing@13986
     8
kleing@16095
     9
## global settings
kleing@16095
    10
. ~/admin/isatest-settings
kleing@13986
    11
kleing@14038
    12
# produce empty list for patterns like isatest-*.log if no 
kleing@14038
    13
# such file exists 
kleing@14038
    14
shopt -s nullglob
kleing@13986
    15
kleing@13986
    16
# mail program
kleing@13986
    17
MAIL=$HOME/bin/pmail
kleing@13986
    18
kleing@13986
    19
# tmp file for sending mail
kleing@13986
    20
TMP=/tmp/isatest-makedist.$$
kleing@13986
    21
kleing@16095
    22
export DISTPREFIX
kleing@16095
    23
kleing@13986
    24
kleing@13986
    25
## diagnostics
kleing@13986
    26
kleing@13986
    27
PRG="$(basename "$0")"
kleing@13986
    28
kleing@13986
    29
function usage()
kleing@13986
    30
{
kleing@13986
    31
  echo
kleing@13986
    32
  echo "Usage: $PRG"
kleing@13986
    33
  echo
kleing@13993
    34
  echo "   sends email for failed tests, checks for error.log,"
kleing@13993
    35
  echo "   generates development snapshot if test ok."
kleing@13986
    36
  echo "   To be called by cron."
kleing@13986
    37
  echo
kleing@13986
    38
  exit 1
kleing@13986
    39
}
kleing@13986
    40
kleing@13986
    41
function fail()
kleing@13986
    42
{
kleing@13986
    43
  echo "$1" >&2
kleing@13986
    44
  exit 2
kleing@13986
    45
}
kleing@13986
    46
kleing@13986
    47
## main
kleing@13986
    48
kleing@16178
    49
# check if tests are still running, wait for them to finish for max 8h
kleing@13986
    50
i=0
kleing@16178
    51
while [ -n "$(ls $RUNNING)" -a $i -lt 8 ]; do 
kleing@13986
    52
    sleep 3600
kleing@13992
    53
    let "i = i+1"
kleing@13986
    54
done
kleing@13986
    55
kleing@13986
    56
# still running -> give up
kleing@13992
    57
if [ -n "$(ls $RUNNING)" ]; then
kleing@16178
    58
    echo "Giving up waiting for test to finish at $(date)." > $TMP
kleing@16178
    59
    echo "Attaching all running and error logs." >> $TMP
kleing@13986
    60
    echo >> $TMP
kleing@16178
    61
kleing@16178
    62
    if [ -e $ERRORLOG ]; then
kleing@16178
    63
        cat $ERRORLOG >> $TMP
kleing@16178
    64
    fi
kleing@16178
    65
kleing@13986
    66
    echo "Have a nice day," >> $TMP
kleing@13986
    67
    echo "  isatest" >> $TMP
kleing@13986
    68
kleing@16178
    69
    for R in $MAILTO; do
kleing@16178
    70
        LOGS=$ERRORDIR/isatest*.log
kleing@16178
    71
        $MAIL "isabelle test taking to long" $R $TMP $LOGS
kleing@13986
    72
    done
kleing@13986
    73
    
kleing@13986
    74
    exit 1
kleing@13986
    75
fi
kleing@13986
    76
kleing@13986
    77
# no tests running, check if there were errors
kleing@13986
    78
if [ -e $ERRORLOG ]; then
kleing@13992
    79
    cat $ERRORLOG > $TMP
kleing@13992
    80
    echo "Have a nice day," >> $TMP
kleing@13992
    81
    echo "  isatest" >> $TMP
kleing@13986
    82
kleing@13992
    83
    for R in $MAILTO; do
kleing@14038
    84
        LOGS=$ERRORDIR/isatest*.log
kleing@14039
    85
        $MAIL "isabelle test failed" $R $TMP $LOGS
kleing@13992
    86
    done
kleing@13986
    87
kleing@13992
    88
    rm $TMP
kleing@13992
    89
    exit 1
kleing@13986
    90
fi
kleing@13986
    91
kleing@13993
    92
# generate development snapshot page only for successful tests
kleing@13993
    93
(cd $HOME/devel-page; env DISTNAME=`$DISTPREFIX/Isabelle/bin/isatool version` make)
kleing@13993
    94
echo "$(date) $HOSTNAME $PRG: generated development snapshot web page." >> $MASTERLOG
kleing@13993
    95
kleing@13992
    96
exit 0
kleing@13986
    97
## end