]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/scripts/crontab.sh
catches more errors
[helm.git] / helm / matita / scripts / crontab.sh
1 #!/bin/bash
2 MARK=`date +%Y%m%d`
3 LASTMARK=`date -d yesterday +%Y%m%d`
4 TMPDIRNAME=.__${MARK}_crontab
5 CVSROOT=":ext:$USER@marcello.cs.unibo.it:/home/faculty/PROJECTS/cvs/helm"
6
7 OLD=$PWD
8 rm -rf $TMPDIRNAME 
9 mkdir $TMPDIRNAME
10 cd $TMPDIRNAME
11 cvs -d $CVSROOT co helm/matita/scripts 1>/dev/null 2>/dev/null
12 helm/matita/scripts/profile_cvs.sh 2> LOG
13
14 CUR_TIME=`echo "select mark, SUM(TIME_TO_SEC(time)) from bench where mark = \"$MARK\" group by mark;" | mysql -u helm -h mowgli.cs.unibo.it matita | tail -n 1 | awk '{print $2}'`
15 OLD_TIME=`echo "select mark, SUM(TIME_TO_SEC(time)) from bench where mark = \"$LASTMARK\" group by mark;" | mysql -u helm -h mowgli.cs.unibo.it matita | tail -n 1 | awk '{print $2}'`
16
17 if [ -z "$CUR_TIME" -o -z "$OLD_TIME" ]; then
18   echo "No benchamks records for $MARK"
19   exit 1
20 fi
21
22 ((DELTA=$CUR_TIME - $OLD_TIME))
23 if [ $DELTA -lt 0 ]; then
24   ((DELTA=$DELTA * -1))
25 fi
26 ((PERC=100 * $DELTA))
27 ((PERC=$PERC / $OLD_TIME))
28
29 if [ $PERC -ge 5 ]; then
30   cat <<EOT
31   REPORT FOR `date`
32   http://mowgli.cs.unibo.it/tassi/bench.php
33
34   PREFORMANCE LOSS DETECTED
35   is $CUR_TIME sec 
36   was $OLD_TIME sec
37
38 EOT
39 fi
40
41 CUR_FAIL=`echo "select count(distinct test) from bench where mark = \"$MARK\" and result = 'fail';" | mysql -u helm -h mowgli.cs.unibo.it matita | tail -n 1`
42 OLD_FAIL=`echo "select count(distinct test) from bench where mark = \"$LASTMARK\" and result = 'fail';" | mysql -u helm -h mowgli.cs.unibo.it matita | tail -n 1`
43
44 if [ $CUR_FAIL -gt $OLD_FAIL ]; then
45   cat <<EOT
46   REPORT FOR `date`
47   http://mowgli.cs.unibo.it/tassi/bench.php
48
49   MORE BROKEN TESTS DETECTED
50   now broken:
51   `echo "select distinct test from bench where mark = \"$MARK\" and result = 'fail';" | mysql -u helm -h mowgli.cs.unibo.it matita`
52   were broken:
53   `echo "select distinct test from bench where mark = \"$OLDMARK\" and result = 'fail';" | mysql -u helm -h mowgli.cs.unibo.it matita`
54   
55 EOT
56
57 fi
58
59 cd $OLD
60 rm -rf $TMPDIRNAME
61