]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/bench_disamberrors
remove debug fake data
[helm.git] / helm / software / matita / bench_disamberrors
1 #!/bin/bash
2 TEMP=`getopt -o c:d:m: -- "$@"`
3 libdir="`pwd`/library"
4 matitac="`pwd`/matitac.opt"
5 devel="library"
6 matitadep="./matitadep.opt"
7 eval set -- "$TEMP"
8 while true ; do
9   case "$1" in
10     -d) libdir="$2"; shift 2 ;;
11     -c) matitac="$2"; shift 2 ;;
12     --) shift; break ;;
13      *) echo "Usage: errors_bench [-c MATITAC_PATH] [-d LIBRARY_DIR] [-m MATITAMAKE_DEVEL]"; exit 1 ;;
14   esac
15 done
16 if ! [ -d "$libdir" ] ; then
17   echo "Can't find library directory '$libdir'"
18   exit 2
19 fi
20 if ! [ -x "$matitac" ] ; then
21   echo "Can't find executable Matita compiler '$matitac'"
22   exit 2
23 fi
24
25 ma_s=$(find $libdir -name "*.ma" -type f)
26 sorted_ma_s=$($matitadep -order $ma_s)
27
28 log="bench_disamberrors.txt"
29 rm -f "$log"
30 echo -e "# FILENAME\tOUTCOME\tEXPECTED_ERROR\tERRORS\tSPURIOUS_ERRORS" > $log
31 # format: tab-separated fields:
32 #   FILENAME OUTCOME EXPECTED_ERROR ERRORS SPURIOUS_ERRORS
33 # field descriptions:
34 #   OUTCOME is one of {"OK","KO","UNKNOWN(n)"}, n is an exit code
35 #   EXPECTED_ERROR is FROM-TO, where FROM and TO are character counts
36 #   ERRORS, same format as above (FROM-TO)
37 #   SPURIOUS_ERRORS, same format as above (FROM-TO)
38 log_outcome ()
39 {
40   echo -e "$1\t$2\t$3\t$4\t$5" >> "$log"
41 }
42
43 for ma in $sorted_ma_s ; do
44   mo=`echo $ma | sed 's/\.ma$/.mo/'`
45   make -C $libdir $mo # ensure deps for $mo have been built
46   rotten_mas=$(ls $libdir/$ma.*.rottened)
47   for rotten_ma in $rotten_mas ; do
48     rotten_ma=$(echo $rotten_ma | sed s@^$(pwd)/@@)  # prettier names
49     echo "$rotten_ma ..."
50     tmp="bench_disamberrors.tmp"
51     $matitac $rotten_ma &> $tmp
52     outcome=$?
53     if [ "$outcome" = 3 ] ; then
54       outcome="KO"
55     elif [ "$outcome" = 0 ] ; then
56       outcome="OK"
57     else
58       outcome="UNKNOWN($outcome)"
59     fi
60     supposed_error=$(grep ^error-at: $rotten_ma | cut -f 2 -d' ')
61     raw_errors=$(grep '^*Error at' $tmp | sed 's/:.*$//' | cut -f 3 -d' ')
62     errors=""
63     for e in $raw_errors ; do
64       if ! [ -z "$errors" ] ; then errors="$errors," ; fi
65       errors="$errors$e"
66     done
67     raw_spurious_errors=$(grep '^*(Spurious?) Error at' $tmp | sed 's/:.*$//' | cut -f 4 -d' ')
68     spurious_errors=""
69     for e in $raw_spurious_errors ; do
70       if ! [ -z "$spurious_errors" ] ; then spurious_errors="$spurious_errors," ; fi
71       spurious_errors="$spurious_errors$e"
72     done
73     log_outcome $rotten_ma $outcome $supposed_error $errors $spurious_errors
74   done
75 done
76
77 echo "See $log for benchmark results"