hierarchical display of tests
[strongswan.git] / testing / do-tests
index 1e8e6ab..537a439 100755 (executable)
@@ -44,7 +44,8 @@ TESTDATE=`date +%Y%m%d-%H%M`
 
 TODAYDIR=$TESTRESULTSDIR/$TESTDATE
 mkdir $TODAYDIR
-TESTRESULTSHTML=$TODAYDIR/index.html
+TESTRESULTSHTML=$TODAYDIR/all.html
+INDEX=$TODAYDIR/index.html
 DEFAULTTESTSDIR=$UMLTESTDIR/testing/tests
 
 testnumber="0"
@@ -104,22 +105,45 @@ done
 KERNEL_VERSION=`basename $KERNEL .tar.bz2`
 IPSEC_VERSION=`basename $STRONGSWAN .tar.bz2`
 
-cat > $TESTRESULTSHTML <<@EOF
+cat > $INDEX <<@EOF
 <html>
 <head>
-  <title>strongSwan UML Testing</title>
+  <title>strongSwan UML Tests</title>
 </head>
 <body>
-  <h2>strongSwan UML Testing</h2>
+  <h2>strongSwan UML Tests</h2>
   <table border="0" cellspacing="2">
-    <tr><td><b>Host:</b></td><td>`uname -a`</td></tr>
-    <tr><td><b>UML kernel: &nbsp;</b></td><td>$KERNEL_VERSION</td></tr>
-    <tr><td><b>IPsec:</b></td><td>$IPSEC_VERSION</td></tr>
-    <tr><td><b>Date:</b></td><td>$TESTDATE</td></tr>
-  </table>
-  <p>
-  <table border="0" width="500">
-    <thead align="left"><th>Number</th><th>Test</th><th>Result</th></thead>
+    <tr valign="top">
+      <td><b>Host:</b></td>
+      <td colspan="3">`uname -a`</td>
+    </tr>
+    <tr valign="top">
+      <td><b>UML kernel: &nbsp;</b></td>
+      <td colspan="3">$KERNEL_VERSION</td>
+    </tr>
+    <tr valign="top">
+      <td><b>IPsec:</b></td>
+      <td colspan="3">$IPSEC_VERSION</td>
+    </tr>
+    <tr valign="top">
+      <td><b>Date:</b></td>
+      <td colspan="3">$TESTDATE</td>
+    </tr>
+    <tr>
+      <td width="100">&nbsp;</td>
+      <td width="200">&nbsp;</td>
+      <td width=" 50">&nbsp;</td>
+      <td >&nbsp;</td>
+    </tr>
+@EOF
+
+cat $INDEX > $TESTRESULTSHTML
+cat >> $TESTRESULTSHTML <<@EOF
+    <tr align="left">
+      <th>Number</th>
+      <th>Test</th>
+      <th colspan="2">Result</th>
+    </tr>
 @EOF
 
 cecho "UML kernel: $KERNEL_VERSION"
@@ -155,6 +179,51 @@ do
        SUBDIR="`dirname $SUBDIR`"
     fi
 
+    if [ ! -d $TODAYDIR/$SUBDIR ]
+    then
+       mkdir $TODAYDIR/$SUBDIR
+       if [ $testnumber == 0 ]
+       then
+           FIRST="<b>Category:</b"
+       else
+           FIRST="&nbsp;"
+       fi
+       echo "    <tr><td>$FIRST</td><td><a href=\"$SUBDIR/index.html\">$SUBDIR</a></td></tr>" >> $INDEX
+       SUBTESTSINDEX=$TODAYDIR/$SUBDIR/index.html
+       cat > $SUBTESTSINDEX <<@EOF
+<html>
+<head>
+  <title>strongSwan $SUBDIR Tests</title>
+</head>
+<body>
+  <h2>strongSwan $SUBDIR Tests</h2>
+  <table border="0" cellspacing="2">
+    <tr valign="top">
+      <td><b>UML kernel: &nbsp;</b></td>
+      <td colspan="3">$KERNEL_VERSION</td>
+    </tr>
+    <tr valign="top">
+      <td><b>IPsec:</b></td>
+      <td colspan="3">$IPSEC_VERSION</td>
+    </tr>
+    <tr valign="top">
+      <td><b>Date:</b></td>
+      <td colspan="3">$TESTDATE</td>
+    </tr>
+    <tr>
+      <td width="100">&nbsp;</td>
+      <td width="200">&nbsp;</td>
+      <td width=" 50">&nbsp;</td>
+      <td >&nbsp;</td>
+    </tr>
+    <tr align="left">
+       <th>Number</th>
+       <th>Test</th>
+       <th colspan="2">Result</th>
+    </tr>
+@EOF
+    fi
+
     for name in $SUBTESTS
     do
        let "testnumber += 1"
@@ -314,19 +383,6 @@ do
                    printf("echo \"%s# cat /tmp/tcpdump.log | grep \047%s\047  [%s]\"; ", host, pattern, hit)
                    printf("ssh root@\044ipv4_%s cat /tmp/tcpdump.log | grep \"%s\"; ", host, pattern)
                }
-               else if (command == "tcpdumpcount")
-               {
-                   printf("if [ \044TDUP_%s == \"true\" ]; then stop_tcpdump %s; fi; \n", host, host)
-                   printf("echo -e \"%s# [ \\\\140cat /tmp/tcpdump.log | grep \047%s\047 | tee -a /dev/stderr | wc -l\\\\140 -eq %s ]  [YES]\"; ", host, pattern, hit)
-                   printf("tcpdumpcount=\`ssh root@\044ipv4_%s cat /tmp/tcpdump.log | grep \"%s\" | tee -a /dev/stderr | wc -l\`; ", host, pattern)
-                   printf("[ \044tcpdumpcount -eq %s ]; ", hit)
-                   hit="YES"
-               }
-               else if (command == "cmd")
-               {
-                   printf("echo \"%s# %s  [%s]\"; ", host, pattern, hit)
-                   printf("ssh root@\044ipv4_%s %s; ",  host, pattern)
-               }
                else
                {
                    printf("echo \"%s# %s | grep \047%s\047  [%s]\"; ", host, command, pattern, hit)
@@ -376,7 +432,7 @@ do
     <ul>
       <li><a href="console.log">console.log</a></li>
     </ul>
-    <img src="../images/$DIAGRAM" alt="$UMLHOSTS">
+    <img src="../../images/$DIAGRAM" alt="$UMLHOSTS">
 @EOF
 
        for host in $IPSECHOSTS
@@ -395,15 +451,32 @@ do
                    $TESTRESULTDIR/${host}.$file  > /dev/null 2>&1
            done
 
+           ssh $HOSTLOGIN ip route list \
+                   > $TESTRESULTDIR/${host}.iproute 2>/dev/null
+           ssh $HOSTLOGIN iptables -v -n -L \
+                   > $TESTRESULTDIR/${host}.iptables 2>/dev/null
            cat >> $TESTRESULTDIR/index.html <<@EOF
     <h3>$host</h3>
-    <ul>
-      <li><a href="$host.ipsec.conf">ipsec.conf</a></li>
-      <li><a href="$host.ipsec.secrets">ipsec.secrets</a></li>
-      <li><a href="$host.statusall">ipsec statusall</a></li>
-      <li><a href="$host.listall">ipsec listall</a></li>
-      <li><a href="$host.auth.log">auth.log</a></li>
-    </ul>
+      <table border="0" cellspacing="0" width="400">
+      <tr>
+       <td>
+         <ul>
+           <li><a href="$host.ipsec.conf">ipsec.conf</a></li>
+           <li><a href="$host.ipsec.secrets">ipsec.secrets</a></li>
+           <li><a href="$host.statusall">ipsec statusall</a></li>
+           <li><a href="$host.listall">ipsec listall</a></li>
+         </ul>
+       </td>
+       <td>
+         <ul>
+           <li><a href="$host.auth.log">auth.log</a></li>
+           <li><a href="$host.daemon.log">daemon.log</a></li>
+           <li><a href="$host.iproute">ip route list</a></li>
+           <li><a href="$host.iptables">iptables -L</a></li>
+       </ul>
+      </td>
+    </tr>
+    </table>
 @EOF
 
        done
@@ -452,6 +525,21 @@ do
 
 
        ##########################################################################
+       # get a copy of /var/log/daemon.log
+       #
+
+       for host in $IPSECHOSTS
+       do
+           eval HOSTLOGIN=root@\$ipv4_${host}
+           ssh $HOSTLOGIN grep pluto /var/log/daemon.log \
+               > $TESTRESULTDIR/${host}.daemon.log
+           echo >> $TESTRESULTDIR/${host}.daemon.log
+           ssh $HOSTLOGIN grep charon /var/log/daemon.log \
+               >> $TESTRESULTDIR/${host}.daemon.log
+       done
+
+
+       ##########################################################################
        # stop tcpdump if necessary
        #
 
@@ -490,10 +578,20 @@ do
     <td>$testnumber</td>
     <td><a href="$testname/">$testname</a></td>
     <td><a href="$testname/console.log"><font color="$COLOR">$STATUS</font></a></td>
+    <td>&nbsp;</td>
+  </tr>
+@EOF
+       cat >> $SUBTESTSINDEX << @EOF
+  <tr>
+    <td>$testnumber</td>
+    <td><a href="$name/">$name</a></td>
+    <td><a href="$name/console.log"><font color="$COLOR">$STATUS</font></a></td>
+    <td>&nbsp;</td>
   </tr>
 @EOF
 
     done
+
 done
 
 
@@ -504,13 +602,33 @@ done
 cat >> $TESTRESULTSHTML << @EOF
   </table>
   <p>
-  <b>Passed: &nbsp; $passed_cnt</b><br>
-  <b>Failed: &nbsp; $failed_cnt</b><br>
+  <b>Passed: &nbsp; <font color="green">$passed_cnt</font></b><br>
+  <b>Failed: &nbsp; <font color="red">$failed_cnt</font></b><br>
   <p>
 </body>
 </html>
 @EOF
 
+let "all_cnt = $passed_cnt + $failed_cnt"
+
+cat >> $INDEX << @EOF
+    <tr>
+      <td>&nbsp;</td>
+      <td><a href="all.html"><b>all</b></a></td>
+         <td><b>$all_cnt</td>
+         <td>&nbsp;</td>
+    </tr>
+    <tr>
+      <td><b>Failed:</b></td>
+      <td>&nbsp;</td>
+         <td><b><font color="red">$failed_cnt</font></b></td>
+         <td>&nbsp;</td>
+    </tr>
+  </table>
+</body>
+</html>
+@EOF
+
 cecho ""
 cecho "Passed:   $passed_cnt"
 cecho "Failed:   $failed_cnt"