13986
|
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 |
|
|
9 |
# source bashrc, we're called by cron
|
|
10 |
. ~/.bashrc
|
|
11 |
|
|
12 |
|
|
13 |
## global settings
|
|
14 |
|
|
15 |
# send mail to:
|
|
16 |
MAILTO="kleing@in.tum.de nipkow@in.tum.de berghofe@in.tum.de schirmer@in.tum.de lp15@cam.ac.uk"
|
|
17 |
|
|
18 |
ADMIN="kleing@in.tum.de"
|
|
19 |
|
|
20 |
# canoncical home for all platforms
|
|
21 |
HOME=/usr/stud/isatest
|
|
22 |
|
|
23 |
# mail program
|
|
24 |
MAIL=$HOME/bin/pmail
|
|
25 |
|
|
26 |
# where the error log is
|
|
27 |
ERRORLOG=$HOME/var/error.log
|
|
28 |
|
|
29 |
# where the test-still-running files are
|
|
30 |
RUNNING=$HOME/var/run/
|
|
31 |
|
|
32 |
# tmp file for sending mail
|
|
33 |
TMP=/tmp/isatest-makedist.$$
|
|
34 |
|
|
35 |
|
|
36 |
## diagnostics
|
|
37 |
|
|
38 |
PRG="$(basename "$0")"
|
|
39 |
|
|
40 |
function usage()
|
|
41 |
{
|
|
42 |
echo
|
|
43 |
echo "Usage: $PRG"
|
|
44 |
echo
|
|
45 |
echo " sends email for failed tests, checks for error.log."
|
|
46 |
echo " To be called by cron."
|
|
47 |
echo
|
|
48 |
exit 1
|
|
49 |
}
|
|
50 |
|
|
51 |
function fail()
|
|
52 |
{
|
|
53 |
echo "$1" >&2
|
|
54 |
exit 2
|
|
55 |
}
|
|
56 |
|
|
57 |
## main
|
|
58 |
|
|
59 |
# check if tests are still running, wait for them to finish for max 10h
|
|
60 |
i=0
|
|
61 |
while [ -n $(ls $RUNNING) -a $((i < 10)) ]; do
|
|
62 |
sleep 3600
|
|
63 |
$((i = i+1))
|
|
64 |
done
|
|
65 |
|
|
66 |
# still running -> give up
|
|
67 |
if [ -n $(ls $RUNNING) ]; then
|
|
68 |
echo "giving up waiting for test to finish at $(date)" > $TMP
|
|
69 |
echo >> $TMP
|
|
70 |
echo "Have a nice day," >> $TMP
|
|
71 |
echo " isatest" >> $TMP
|
|
72 |
|
|
73 |
for R in $ADMIN; do
|
13989
|
74 |
$MAIL "isabelle test taking to long" $R $TMP
|
13986
|
75 |
done
|
|
76 |
|
|
77 |
exit 1
|
|
78 |
fi
|
|
79 |
|
|
80 |
# no tests running, check if there were errors
|
|
81 |
if [ -e $ERRORLOG ]; then
|
|
82 |
cat $ERRORLOG > $TMP
|
|
83 |
echo "Have a nice day," >> $TMP
|
|
84 |
echo " isatest" >> $TMP
|
|
85 |
|
|
86 |
for R in $MAILTO; do
|
|
87 |
$MAIL "isabelle test failed" $R $TMP
|
|
88 |
done
|
|
89 |
|
|
90 |
rm $TMP
|
|
91 |
fi
|
|
92 |
|
|
93 |
## end
|