scripts for automated testing, compiling and reporting
authorMatthias Braun <matze@braunis.de>
Thu, 13 Jul 2006 14:37:19 +0000 (14:37 +0000)
committerMatthias Braun <matze@braunis.de>
Thu, 13 Jul 2006 14:37:19 +0000 (14:37 +0000)
ir/be/test/compile.sh [new file with mode: 0755]
ir/be/test/fib.c
ir/be/test/makehtml.xslt [new file with mode: 0644]

diff --git a/ir/be/test/compile.sh b/ir/be/test/compile.sh
new file mode 100755 (executable)
index 0000000..1c19b24
--- /dev/null
@@ -0,0 +1,101 @@
+EDG_CFLAGS="-b ra-chordal-spill=belady -b ia32-arch=athlon -b ia32-fpunit=x87 --c --gnu=400002 -I/usr/lib/gcc-lib/i586-suse-linux/3.3.5/include"
+GCC_CFLAGS="-O3 -g -fomit-frame-pointer"
+LINKFLAGS="-lm"
+
+CFILES="*.c"
+OUTPUTDIR="stats-`date +%d.%m.%y`"
+
+mkdir -p build_firm
+mkdir -p build_gcc
+mkdir -p $OUTPUTDIR
+
+XMLRES=$OUTPUTDIR/result.xml
+cat > $XMLRES << __END__
+<?xml version="1.0"?>
+<results>
+    <environment>
+        <EDG_CFLAGS>${EDG_CFLAGS}</EDG_CFLAGS>
+        <GCC_CFLAGS>${GCC_CFLAGS}</GCC_CFLAGS>
+    </environment>
+__END__
+
+# so endless apps stop at some point...
+ulimit -t2
+
+for file in ${CFILES}; do
+    COMPILE_RES="ok"
+    LINK_RES="omitted"
+    GCC_RES="ok"
+    GCC_RUN_RES="omitted"
+    FIRM_RUN_RES="omitted"
+    DIFF_RES="omitted"
+
+    name="`basename $file .c`"
+    res="$OUTPUTDIR/buildresult_$name.txt"
+    echo "Building $name"
+    echo "Results for $name" > $res
+    echo "*** EDG/FIRM Compile" >> $res
+    CMD="edg ${EDG_CFLAGS} $file"
+    echo "$CMD" >> $res
+    $CMD >> $res 2>&1 || COMPILE_RES="failed"
+
+    if [ ${COMPILE_RES} == "ok" ]; then
+        LINK_RES="ok"
+        CMD="mv $name.s build_firm/$name.s"
+        echo "$CMD" >> $res
+        $CMD >> $res 2>&1
+        echo "*** Linking" >> $res
+        CMD="gcc build_firm/$name.s ${LINKFLAGS} -o build_firm/$name.exe"
+        echo "$CMD" >> $res
+        $CMD >> $res 2>&1 || LINK_RES="failed"
+    fi
+
+    echo "*** GCC Compile" >> $res
+    CMD="gcc ${GCC_CFLAGS} $file ${LINKFLAGS} -o build_gcc/$name.exe"
+    echo "$CMD" >> $res
+    $CMD >> $res 2>&1 || GCC_RES="failed"
+
+    if [ ${GCC_RES} = "ok" ]; then
+        GCC_RUN_RES="ok"
+
+        echo "*** Run GCC" >> $res
+        CMD="build_gcc/$name.exe > $OUTPUTDIR/result_gcc_$name.txt 2>&1"
+        echo "$CMD" >> $res
+        build_gcc/$name.exe > $OUTPUTDIR/result_gcc_$name.txt 2>&1 || GCC_RUN_RES="failed"
+    fi
+
+    if [ ${LINK_RES} = "ok" ]; then
+        FIRM_RUN_RES="ok"
+
+        echo "*** Run Firm" >> $res
+        CMD="build_firm/$name.exe > $OUTPUTDIR/result_gcc_$name.txt 2>&1"
+        echo "$CMD" >> $res
+        build_firm/$name.exe > $OUTPUTDIR/result_firm_$name.txt 2>&1 || FIRM_RUN_RES="failed"
+    fi
+
+    if [ ${GCC_RUN_RES} = "ok" -a ${FIRM_RUN_RES} = "ok" ]; then
+        DIFF_RES="ok"
+
+        echo "*** Compare Results" >> $res
+        CMD="diff -u $OUTPUTDIR/result_gcc_$name.txt $OUTPUTDIR/result_firm_$name.txt"
+        $CMD > $OUTPUTDIR/result_diff_$name.txt 2>&1 || DIFF_RES="failed"
+    fi
+
+    cat >> $XMLRES << __END__
+    <result name="$name">
+        <compile>$COMPILE_RES</compile>
+        <link>$LINK_RES</link>
+        <gcc_compile>$GCC_RES</gcc_compile>
+        <gcc_run>$GCC_RUN_RES</gcc_run>
+        <firm_run>$FIRM_RUN_RES</firm_run>
+        <diff>$DIFF_RES</diff>
+    </result>
+__END__
+done
+
+echo "</results>" >> $XMLRES
+
+xsltproc --output $OUTPUTDIR/index.html makehtml.xslt $XMLRES
+
+# maybe execute custom actions after result has been generated
+[ -e after_compile.sh ] && ./after_compile.sh "$OUTPUTDIR"
index 8db5ff2..de904ee 100644 (file)
@@ -1,19 +1,29 @@
 #include <stdio.h>
 
 #include <stdio.h>
 
+//#define COUNT_BRANCHES
+
+#ifdef COUNT_BRANCHES
 int b1, b2, b3;
 int b1, b2, b3;
+#endif
 
 unsigned fib(unsigned n)
 {
     if(n == 0) {
 
 unsigned fib(unsigned n)
 {
     if(n == 0) {
+#ifdef COUNT_BRANCHES
         b1++;
         b1++;
+#endif
         return 0;
     }
     if(n == 1) {
         return 0;
     }
     if(n == 1) {
+#ifdef COUNT_BRANCHES
         b2++;
         b2++;
+#endif
         return 1;
     }
 
         return 1;
     }
 
+#ifdef COUNT_BRANCHES
     b3++;
     b3++;
+#endif
     return fib(n-1) + fib(n-2);
 }
 
     return fib(n-1) + fib(n-2);
 }
 
@@ -22,9 +32,13 @@ int main(int argc, char** argv) {
     if(argc > 1)
         n = (unsigned) atoi(argv[1]);
 
     if(argc > 1)
         n = (unsigned) atoi(argv[1]);
 
+#ifdef COUNT_BRANCHES
     b1 = b2 = b3 = 0;
     b1 = b2 = b3 = 0;
+#endif
     printf("Fib %u: %u\n", n, fib(n));
     printf("Fib %u: %u\n", n, fib(n));
+#ifdef COUNT_BRANCHES
     printf("Branches: 1:%d 2:%d 3:%d\n", b1, b2, b3);
     printf("Branches: 1:%d 2:%d 3:%d\n", b1, b2, b3);
+#endif
 
     return 0;
 }
 
     return 0;
 }
diff --git a/ir/be/test/makehtml.xslt b/ir/be/test/makehtml.xslt
new file mode 100644 (file)
index 0000000..64d1850
--- /dev/null
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+       <xsl:output method="html" indent="yes"
+              doctype-public="-//W3C//DTD HTML 4.01//EN"
+                   doctype-system="http://www.w3.org/TR/html4/strict.dtd"/>
+
+       <xsl:template name="resultcell" match="result/*">
+               <xsl:element name="div">
+                       <xsl:if test="contains(text(), 'ok')">
+                               <xsl:attribute name="style">background-color: green; color: white;</xsl:attribute>
+                       </xsl:if>
+                       <xsl:if test="contains(text(), 'failed')">
+                               <xsl:attribute name="style">background-color: red; color: white;</xsl:attribute>
+                       </xsl:if>
+                       <xsl:value-of select="text()"/>
+               </xsl:element>
+       </xsl:template>
+
+       <xsl:template match="/">
+               <html>
+                       <head>
+                               <title>Results</title>
+                       </head>
+                       <body>
+                               <table>
+                                       <tr>
+                                               <th>Name</th>
+                                               <th>Compile</th>
+                                               <th>Link</th>
+                                               <th>GCC Compile</th>
+                                               <th>GCC Run</th>
+                                               <th>Firm Run</th>
+                                               <th>Results</th>
+                                       </tr>
+                                       <xsl:for-each select="/results/result">
+                                               <tr>
+                                                       <td>
+                                                               <xsl:element name="a">
+                                                                       <xsl:attribute name="href">buildresult_<xsl:value-of select="@name"/>.txt</xsl:attribute>
+                                                                       <xsl:value-of select="@name"/>
+                                                               </xsl:element>
+                                                       </td>
+                                                       <td><xsl:apply-templates select="compile"/></td>
+                                                       <td><xsl:apply-templates select="link"/></td>
+                                                       <td><xsl:apply-templates select="gcc_compile"/></td>
+                                                       <td><xsl:apply-templates select="gcc_run"/></td>
+                                                       <td><xsl:apply-templates select="firm_run"/></td>
+                                                       <td><xsl:apply-templates select="diff"/></td>
+                                               </tr>
+                                       </xsl:for-each>
+                               </table>
+                       </body>
+               </html>
+       </xsl:template>
+</xsl:stylesheet>