Admin/isatest-check
author nipkow
Wed Aug 04 11:25:08 2004 +0200 (2004-08-04)
changeset 15106 e8cef6993701
parent 14981 e73f8140af78
child 15887 7dee3396d8b0
permissions -rwxr-xr-x
aded comment
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@13986
     9
# source bashrc, we're called by cron
kleing@13986
    10
. ~/.bashrc
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
## global settings
kleing@13986
    17
kleing@13986
    18
# send mail to:
skalberg@14170
    19
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"
kleing@13986
    20
skalberg@14170
    21
ADMIN="berghofe@in.tum.de"
kleing@13986
    22
kleing@13986
    23
# canoncical home for all platforms
kleing@13986
    24
HOME=/usr/stud/isatest
kleing@13986
    25
kleing@13993
    26
# where to find the distribution
kleing@13993
    27
DISTPREFIX=$HOME/isadist
kleing@13993
    28
kleing@13986
    29
# mail program
kleing@13986
    30
MAIL=$HOME/bin/pmail
kleing@13986
    31
kleing@13993
    32
# where the logs are
kleing@14035
    33
ERRORDIR=$HOME/var
kleing@14035
    34
ERRORLOG=$ERRORDIR/error.log
kleing@13993
    35
MASTERLOG=$HOME/log/isatest.log
kleing@13986
    36
kleing@13986
    37
# where the test-still-running files are
kleing@13991
    38
RUNNING=$HOME/var/running
kleing@13986
    39
kleing@13986
    40
# tmp file for sending mail
kleing@13986
    41
TMP=/tmp/isatest-makedist.$$
kleing@13986
    42
kleing@13986
    43
kleing@13986
    44
## diagnostics
kleing@13986
    45
kleing@13986
    46
PRG="$(basename "$0")"
kleing@13986
    47
kleing@13986
    48
function usage()
kleing@13986
    49
{
kleing@13986
    50
  echo
kleing@13986
    51
  echo "Usage: $PRG"
kleing@13986
    52
  echo
kleing@13993
    53
  echo "   sends email for failed tests, checks for error.log,"
kleing@13993
    54
  echo "   generates development snapshot if test ok."
kleing@13986
    55
  echo "   To be called by cron."
kleing@13986
    56
  echo
kleing@13986
    57
  exit 1
kleing@13986
    58
}
kleing@13986
    59
kleing@13986
    60
function fail()
kleing@13986
    61
{
kleing@13986
    62
  echo "$1" >&2
kleing@13986
    63
  exit 2
kleing@13986
    64
}
kleing@13986
    65
kleing@13986
    66
## main
kleing@13986
    67
kleing@13986
    68
# check if tests are still running, wait for them to finish for max 10h
kleing@13986
    69
i=0
kleing@13992
    70
while [ -n "$(ls $RUNNING)" -a $i -lt 10 ]; do 
kleing@13986
    71
    sleep 3600
kleing@13992
    72
    let "i = i+1"
kleing@13986
    73
done
kleing@13986
    74
kleing@13986
    75
# still running -> give up
kleing@13992
    76
if [ -n "$(ls $RUNNING)" ]; then
kleing@13986
    77
    echo "giving up waiting for test to finish at $(date)" > $TMP
kleing@13986
    78
    echo >> $TMP
kleing@13986
    79
    echo "Have a nice day," >> $TMP
kleing@13986
    80
    echo "  isatest" >> $TMP
kleing@13986
    81
kleing@13986
    82
    for R in $ADMIN; do
kleing@13989
    83
        $MAIL "isabelle test taking to long" $R $TMP
kleing@13986
    84
    done
kleing@13986
    85
    
kleing@13986
    86
    exit 1
kleing@13986
    87
fi
kleing@13986
    88
kleing@13986
    89
# no tests running, check if there were errors
kleing@13986
    90
if [ -e $ERRORLOG ]; then
kleing@13992
    91
    cat $ERRORLOG > $TMP
kleing@13992
    92
    echo "Have a nice day," >> $TMP
kleing@13992
    93
    echo "  isatest" >> $TMP
kleing@13986
    94
kleing@13992
    95
    for R in $MAILTO; do
kleing@14038
    96
        LOGS=$ERRORDIR/isatest*.log
kleing@14039
    97
        $MAIL "isabelle test failed" $R $TMP $LOGS
kleing@13992
    98
    done
kleing@13986
    99
kleing@13992
   100
    rm $TMP
kleing@13992
   101
    exit 1
kleing@13986
   102
fi
kleing@13986
   103
kleing@13993
   104
# generate development snapshot page only for successful tests
kleing@13993
   105
(cd $HOME/devel-page; env DISTNAME=`$DISTPREFIX/Isabelle/bin/isatool version` make)
kleing@13993
   106
echo "$(date) $HOSTNAME $PRG: generated development snapshot web page." >> $MASTERLOG
kleing@13993
   107
kleing@13992
   108
exit 0
kleing@13986
   109
## end