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