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