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