update makreport to allow specifying directories
[libfirm] / ir / be / test / makereport.sh
1 EDG_BIN="eccp"
2 EDG_CFLAGS="${ADDCFLAGS} -O3"
3 GCC_CFLAGS="-O3 -g -fomit-frame-pointer"
4 LINKFLAGS="-lm"
5 TIMEOUT_COMPILE=300
6 TIMEOUT_RUN=30
7
8 CFILES="*.c"
9 OUTPUTDIR="stats-`date +%d.%m.%y`"
10
11 mkdir -p build_firm
12 mkdir -p build_gcc
13 mkdir -p $OUTPUTDIR
14
15 XMLRES=$OUTPUTDIR/result.xml
16 cat > $XMLRES << __END__
17 <?xml version="1.0"?>
18 <results>
19     <environment>
20         <EDG_CFLAGS>${EDG_CFLAGS}</EDG_CFLAGS>
21         <GCC_CFLAGS>${GCC_CFLAGS}</GCC_CFLAGS>
22     </environment>
23 __END__
24
25 # so endless apps stop at some point...
26 #ulimit -t2
27
28 basedir=`pwd`
29
30 DIRS=". gcc-testsuite gcc-testsuite/ieee"
31 test -n "$1" && DIRS="$1"
32
33 for dir in $DIRS; do
34         curdir=$basedir/$dir
35     echo "<section name=\"$curdir/\">" >> $XMLRES
36 for file in $curdir/$CFILES; do
37     COMPILE_RES="ok"
38     LINK_RES="omitted"
39     GCC_RES="ok"
40     GCC_RUN_RES="omitted"
41     FIRM_RUN_RES="omitted"
42     DIFF_RES="omitted"
43
44     name="`basename $file .c`"
45     res="$OUTPUTDIR/buildresult_$name.txt"
46     echo "Building $name"
47     echo "Results for $name" > $res
48     echo "*** EDG/FIRM Compile" >> $res
49     CMD="ulimit -t${TIMEOUT_COMPILE} ; ${EDG_BIN} ${EDG_CFLAGS} $file"
50     echo "$CMD" >> $res
51     /bin/bash -c "ulimit -t${TIMEOUT_COMPILE} ; ${EDG_BIN} ${EDG_CFLAGS} $file" >> $res 2>&1 || COMPILE_RES="failed"
52
53     if [ ${COMPILE_RES} == "ok" ]; then
54         LINK_RES="ok"
55         CMD="mv $curdir/$name.s build_firm/$name.s"
56         echo "$CMD" >> $res
57         $CMD >> $res 2>&1
58         echo "*** Linking" >> $res
59         CMD="gcc build_firm/$name.s ${LINKFLAGS} -o build_firm/$name.exe"
60         echo "$CMD" >> $res
61         $CMD >> $res 2>&1 || LINK_RES="failed"
62     fi
63
64     echo "*** GCC Compile" >> $res
65     CMD="gcc ${GCC_CFLAGS} $file ${LINKFLAGS} -o build_gcc/$name.exe"
66     echo "$CMD" >> $res
67     $CMD >> $res 2>&1 || GCC_RES="failed"
68
69     if [ ${GCC_RES} = "ok" ]; then
70         GCC_RUN_RES="ok"
71
72         echo "*** Run GCC" >> $res
73         CMD="ulimit -t${TIMEOUT_RUN} ; build_gcc/$name.exe > $OUTPUTDIR/result_gcc_$name.txt 2>&1"
74         echo "$CMD" >> $res
75         /bin/bash -c "ulimit -t${TIMEOUT_RUN} ; build_gcc/$name.exe" > $OUTPUTDIR/result_gcc_$name.txt 2>&1 || GCC_RUN_RES="failed"
76     fi
77
78     if [ ${LINK_RES} = "ok" ]; then
79         FIRM_RUN_RES="ok"
80
81         echo "*** Run Firm" >> $res
82         CMD="ulimit -t${TIMEOUT_RUN} ; build_firm/$name.exe > $OUTPUTDIR/result_gcc_$name.txt 2>&1"
83         echo "$CMD" >> $res
84         /bin/bash -c "ulimit -t${TIMEOUT_RUN} ; build_firm/$name.exe" > $OUTPUTDIR/result_firm_$name.txt 2>&1 || FIRM_RUN_RES="failed"
85     fi
86
87     if [ ${GCC_RUN_RES} = "ok" -a ${FIRM_RUN_RES} = "ok" ]; then
88         DIFF_RES="ok"
89
90         echo "*** Compare Results" >> $res
91         CMD="diff -u $OUTPUTDIR/result_gcc_$name.txt $OUTPUTDIR/result_firm_$name.txt"
92         $CMD > $OUTPUTDIR/result_diff_$name.txt 2>&1 || DIFF_RES="failed"
93     fi
94
95     cat >> $XMLRES << __END__
96     <result name="$name">
97         <compile>$COMPILE_RES</compile>
98         <link>$LINK_RES</link>
99         <gcc_compile>$GCC_RES</gcc_compile>
100         <gcc_run>$GCC_RUN_RES</gcc_run>
101         <firm_run>$FIRM_RUN_RES</firm_run>
102         <diff>$DIFF_RES</diff>
103     </result>
104 __END__
105 done
106     echo "</section>" >> $XMLRES
107 done
108
109 echo "</results>" >> $XMLRES
110
111 xsltproc --output $OUTPUTDIR/index.html makehtml.xslt $XMLRES
112
113 # maybe execute custom actions after result has been generated
114 [ -e after_compile.sh ] && ./after_compile.sh "$OUTPUTDIR"