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