Admin/isatest-check
author mehta
Fri Apr 16 15:46:50 2004 +0200 (2004-04-16)
changeset 14591 7be4d5dadf15
parent 14170 edd5a2ea3807
child 14981 e73f8140af78
permissions -rwxr-xr-x
lemma drop_Suc_conv_tl added.
     1 #!/usr/bin/env bash
     2 #
     3 # $Id$
     4 # Author: Gerwin Klein, TU Muenchen
     5 # License: GPL (GNU GENERAL PUBLIC LICENSE)
     6 #
     7 # DESCRIPTION: sends email for failed tests, checks for error.log,
     8 #              generates development snapshot if test ok
     9 
    10 # source bashrc, we're called by cron
    11 . ~/.bashrc
    12 
    13 # produce empty list for patterns like isatest-*.log if no 
    14 # such file exists 
    15 shopt -s nullglob
    16 
    17 ## global settings
    18 
    19 # send mail to:
    20 MAILTO="kleing@in.tum.de nipkow@in.tum.de berghofe@in.tum.de schirmer@in.tum.de lp15@cam.ac.uk skalberg@in.tum.de"
    21 
    22 ADMIN="berghofe@in.tum.de"
    23 
    24 # canoncical home for all platforms
    25 HOME=/usr/stud/isatest
    26 
    27 # where to find the distribution
    28 DISTPREFIX=$HOME/isadist
    29 
    30 # mail program
    31 MAIL=$HOME/bin/pmail
    32 
    33 # where the logs are
    34 ERRORDIR=$HOME/var
    35 ERRORLOG=$ERRORDIR/error.log
    36 MASTERLOG=$HOME/log/isatest.log
    37 
    38 # where the test-still-running files are
    39 RUNNING=$HOME/var/running
    40 
    41 # tmp file for sending mail
    42 TMP=/tmp/isatest-makedist.$$
    43 
    44 
    45 ## diagnostics
    46 
    47 PRG="$(basename "$0")"
    48 
    49 function usage()
    50 {
    51   echo
    52   echo "Usage: $PRG"
    53   echo
    54   echo "   sends email for failed tests, checks for error.log,"
    55   echo "   generates development snapshot if test ok."
    56   echo "   To be called by cron."
    57   echo
    58   exit 1
    59 }
    60 
    61 function fail()
    62 {
    63   echo "$1" >&2
    64   exit 2
    65 }
    66 
    67 ## main
    68 
    69 # check if tests are still running, wait for them to finish for max 10h
    70 i=0
    71 while [ -n "$(ls $RUNNING)" -a $i -lt 10 ]; do 
    72     sleep 3600
    73     let "i = i+1"
    74 done
    75 
    76 # still running -> give up
    77 if [ -n "$(ls $RUNNING)" ]; then
    78     echo "giving up waiting for test to finish at $(date)" > $TMP
    79     echo >> $TMP
    80     echo "Have a nice day," >> $TMP
    81     echo "  isatest" >> $TMP
    82 
    83     for R in $ADMIN; do
    84         $MAIL "isabelle test taking to long" $R $TMP
    85     done
    86     
    87     exit 1
    88 fi
    89 
    90 # no tests running, check if there were errors
    91 if [ -e $ERRORLOG ]; then
    92     cat $ERRORLOG > $TMP
    93     echo "Have a nice day," >> $TMP
    94     echo "  isatest" >> $TMP
    95 
    96     for R in $MAILTO; do
    97         LOGS=$ERRORDIR/isatest*.log
    98         $MAIL "isabelle test failed" $R $TMP $LOGS
    99     done
   100 
   101     rm $TMP
   102     exit 1
   103 fi
   104 
   105 # generate development snapshot page only for successful tests
   106 (cd $HOME/devel-page; env DISTNAME=`$DISTPREFIX/Isabelle/bin/isatool version` make)
   107 echo "$(date) $HOSTNAME $PRG: generated development snapshot web page." >> $MASTERLOG
   108 
   109 exit 0
   110 ## end