Admin/isatest/isatest-check
changeset 22410 da313b67a04d
child 22411 1956d895a4ed
equal deleted inserted replaced
22409:5f7c9c82b05e 22410:da313b67a04d
       
     1 #!/usr/bin/env bash
       
     2 #
       
     3 # $Id$
       
     4 # Author: Gerwin Klein, TU Muenchen
       
     5 #
       
     6 # DESCRIPTION: sends email for failed tests, checks for error.log,
       
     7 #              generates development snapshot if test ok
       
     8 
       
     9 ## global settings
       
    10 . ~/admin/isatest-settings
       
    11 
       
    12 # produce empty list for patterns like isatest-*.log if no 
       
    13 # such file exists 
       
    14 shopt -s nullglob
       
    15 
       
    16 # mail program
       
    17 MAIL=$HOME/bin/pmail
       
    18 
       
    19 # tmp file for sending mail
       
    20 TMP=/tmp/isatest-makedist.$$
       
    21 
       
    22 export DISTPREFIX
       
    23 
       
    24 
       
    25 ## diagnostics
       
    26 
       
    27 PRG="$(basename "$0")"
       
    28 
       
    29 function usage()
       
    30 {
       
    31   echo
       
    32   echo "Usage: $PRG"
       
    33   echo
       
    34   echo "   sends email for failed tests, checks for error.log,"
       
    35   echo "   generates development snapshot if test ok."
       
    36   echo "   To be called by cron."
       
    37   echo
       
    38   exit 1
       
    39 }
       
    40 
       
    41 function fail()
       
    42 {
       
    43   echo "$1" >&2
       
    44   exit 2
       
    45 }
       
    46 
       
    47 ## main
       
    48 
       
    49 # check if tests are still running, wait for them a couple of hours
       
    50 i=0
       
    51 while [ -n "$(ls $RUNNING)" -a $i -lt 8 ]; do 
       
    52     sleep 3600
       
    53     let "i = i+1"
       
    54 done
       
    55 
       
    56 FAIL=0
       
    57 
       
    58 # still running -> give up
       
    59 if [ -n "$(ls $RUNNING)" ]; then
       
    60     echo "Giving up waiting for test to finish at $(date)." > $TMP
       
    61     echo >> $TMP
       
    62     echo "Sessions still running:" >> $TMP
       
    63     echo "$(ls $RUNNING)" >> $TMP
       
    64     echo >> $TMP
       
    65     echo "Attaching all error logs collected so far." >> $TMP
       
    66     echo >> $TMP
       
    67 
       
    68     if [ -e $ERRORLOG ]; then
       
    69         cat $ERRORLOG >> $TMP
       
    70     fi
       
    71 
       
    72     echo "Have a nice day," >> $TMP
       
    73     echo "  isatest" >> $TMP
       
    74 
       
    75     for R in $MAILTO; do
       
    76         LOGS=$ERRORDIR/isatest*.log
       
    77         $MAIL "isabelle test taking too long" $R $TMP $LOGS
       
    78     done
       
    79 
       
    80     rm $TMP
       
    81     
       
    82     FAIL=1
       
    83 elif [ -e $ERRORLOG ]; then
       
    84   # no tests running, check if there were errors
       
    85     cat $ERRORLOG > $TMP
       
    86     echo "Have a nice day," >> $TMP
       
    87     echo "  isatest" >> $TMP
       
    88 
       
    89     for R in $MAILTO; do
       
    90         LOGS=$ERRORDIR/isatest*.log
       
    91         $MAIL "isabelle test failed" $R $TMP $LOGS
       
    92     done
       
    93     
       
    94     rm $TMP
       
    95 fi
       
    96 
       
    97 # generate development snapshot page only for successful tests
       
    98 # (failures in experimental sessions ok)
       
    99 if [ "$FAIL"=="0" -a "$(echo $ERRORDIR/isatest*[^e].log)" == "$(echo)" ]; then
       
   100   (cd $HOME/devel-page; env DISTNAME=`$DISTPREFIX/Isabelle/bin/isatool version` make)
       
   101   echo "$(date) $HOSTNAME $PRG: generated development snapshot web page." >> $MASTERLOG
       
   102 fi
       
   103 
       
   104 exit 0
       
   105 ## end