Admin/isatest-check
author wenzelm
Fri Dec 29 17:24:46 2006 +0100 (2006-12-29)
changeset 21935 4e20a5397b57
parent 21038 c7b041a6bbfe
permissions -rwxr-xr-x
renamed project to subgraph, improved presentation, avoided unnecessary evaluation of predicate;
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
isatest@17847
    49
# check if tests are still running, wait for them a couple of hours
kleing@13986
    50
i=0
isatest@17847
    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@21038
    56
FAIL=0
kleing@21038
    57
kleing@13986
    58
# still running -> give up
kleing@13992
    59
if [ -n "$(ls $RUNNING)" ]; then
kleing@16178
    60
    echo "Giving up waiting for test to finish at $(date)." > $TMP
kleing@18244
    61
    echo >> $TMP
kleing@18244
    62
    echo "Sessions still running:" >> $TMP
kleing@18329
    63
    echo "$(ls $RUNNING)" >> $TMP
kleing@18244
    64
    echo >> $TMP
kleing@16507
    65
    echo "Attaching all error logs collected so far." >> $TMP
kleing@13986
    66
    echo >> $TMP
kleing@16178
    67
kleing@16178
    68
    if [ -e $ERRORLOG ]; then
kleing@16178
    69
        cat $ERRORLOG >> $TMP
kleing@16178
    70
    fi
kleing@16178
    71
kleing@13986
    72
    echo "Have a nice day," >> $TMP
kleing@13986
    73
    echo "  isatest" >> $TMP
kleing@13986
    74
kleing@16178
    75
    for R in $MAILTO; do
kleing@16178
    76
        LOGS=$ERRORDIR/isatest*.log
wenzelm@16362
    77
        $MAIL "isabelle test taking too long" $R $TMP $LOGS
kleing@13986
    78
    done
kleing@21038
    79
kleing@21038
    80
    rm $TMP
kleing@13986
    81
    
kleing@21038
    82
    FAIL=1
kleing@21038
    83
elif [ -e $ERRORLOG ]; then
kleing@21038
    84
  # no tests running, check if there were errors
kleing@13992
    85
    cat $ERRORLOG > $TMP
kleing@13992
    86
    echo "Have a nice day," >> $TMP
kleing@13992
    87
    echo "  isatest" >> $TMP
kleing@13986
    88
kleing@13992
    89
    for R in $MAILTO; do
kleing@14038
    90
        LOGS=$ERRORDIR/isatest*.log
kleing@14039
    91
        $MAIL "isabelle test failed" $R $TMP $LOGS
kleing@13992
    92
    done
kleing@21038
    93
    
kleing@13992
    94
    rm $TMP
kleing@13986
    95
fi
kleing@13986
    96
kleing@13993
    97
# generate development snapshot page only for successful tests
kleing@21038
    98
# (failures in experimental sessions ok)
kleing@21038
    99
if [ "$FAIL"=="0" -a "$(echo $ERRORDIR/isatest*[^e].log)" == "$(echo)" ]; then
kleing@21038
   100
  (cd $HOME/devel-page; env DISTNAME=`$DISTPREFIX/Isabelle/bin/isatool version` make)
kleing@21038
   101
  echo "$(date) $HOSTNAME $PRG: generated development snapshot web page." >> $MASTERLOG
kleing@21038
   102
fi
kleing@13993
   103
kleing@13992
   104
exit 0
kleing@13986
   105
## end