Admin/isatest-check
author haftmann
Tue Oct 10 13:59:12 2006 +0200 (2006-10-10)
changeset 20950 981fa0ce23ed
parent 18329 221d47d17a81
child 21038 c7b041a6bbfe
permissions -rwxr-xr-x
added IsarAdvanced material
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@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@18244
    59
    echo >> $TMP
kleing@18244
    60
    echo "Sessions still running:" >> $TMP
kleing@18329
    61
    echo "$(ls $RUNNING)" >> $TMP
kleing@18244
    62
    echo >> $TMP
kleing@16507
    63
    echo "Attaching all error logs collected so far." >> $TMP
kleing@13986
    64
    echo >> $TMP
kleing@16178
    65
kleing@16178
    66
    if [ -e $ERRORLOG ]; then
kleing@16178
    67
        cat $ERRORLOG >> $TMP
kleing@16178
    68
    fi
kleing@16178
    69
kleing@13986
    70
    echo "Have a nice day," >> $TMP
kleing@13986
    71
    echo "  isatest" >> $TMP
kleing@13986
    72
kleing@16178
    73
    for R in $MAILTO; do
kleing@16178
    74
        LOGS=$ERRORDIR/isatest*.log
wenzelm@16362
    75
        $MAIL "isabelle test taking too long" $R $TMP $LOGS
kleing@13986
    76
    done
kleing@13986
    77
    
kleing@13986
    78
    exit 1
kleing@13986
    79
fi
kleing@13986
    80
kleing@13986
    81
# no tests running, check if there were errors
kleing@13986
    82
if [ -e $ERRORLOG ]; then
kleing@13992
    83
    cat $ERRORLOG > $TMP
kleing@13992
    84
    echo "Have a nice day," >> $TMP
kleing@13992
    85
    echo "  isatest" >> $TMP
kleing@13986
    86
kleing@13992
    87
    for R in $MAILTO; do
kleing@14038
    88
        LOGS=$ERRORDIR/isatest*.log
kleing@14039
    89
        $MAIL "isabelle test failed" $R $TMP $LOGS
kleing@13992
    90
    done
kleing@13986
    91
kleing@13992
    92
    rm $TMP
kleing@13992
    93
    exit 1
kleing@13986
    94
fi
kleing@13986
    95
kleing@13993
    96
# generate development snapshot page only for successful tests
kleing@13993
    97
(cd $HOME/devel-page; env DISTNAME=`$DISTPREFIX/Isabelle/bin/isatool version` make)
kleing@13993
    98
echo "$(date) $HOSTNAME $PRG: generated development snapshot web page." >> $MASTERLOG
kleing@13993
    99
kleing@13992
   100
exit 0
kleing@13986
   101
## end