List daemon.log on $RADIUSHOSTS
[strongswan.git] / testing / do-tests
index f0b654a..49f8892 100755 (executable)
 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 # for more details.
 
-DIR=`dirname $0`
+DIR=$(dirname `readlink -f $0`)
+. $DIR/testing.conf
+. $DIR/scripts/function.sh
 
-source $DIR/scripts/function.sh
-
-[ -f $DIR/testing.conf ] || die "Configuration file 'testing.conf' not found"
 [ -d $DIR/hosts ] || die "Directory 'hosts' not found"
 [ -d $DIR/tests ] || die "Directory 'tests' not found"
-
-source $DIR/testing.conf
-
-
-##############################################################################
-# test if UMLs have been built at all
-#
-
-[ -d $BUILDDIR ] || die "Directory '$BUILDDIR' does not exist. Please run 'make-testing'first."
-
+[ -d $BUILDDIR ] ||
+       die "Directory '$BUILDDIR' does not exist, please run make-testing first"
 
 ##############################################################################
 # take care of new path and file variables
@@ -44,7 +35,7 @@ TODAYDIR=$TESTRESULTSDIR/$TESTDATE
 mkdir $TODAYDIR
 TESTRESULTSHTML=$TODAYDIR/all.html
 INDEX=$TODAYDIR/index.html
-DEFAULTTESTSDIR=$UMLTESTDIR/testing/tests
+DEFAULTTESTSDIR=$TESTDIR/testing/tests
 
 SOURCEIP_ROUTING_TABLE=220
 
@@ -105,8 +96,9 @@ done
 #
 for host in $STRONGSWANHOSTS
 do
-    ssh $SSHCONF -N root@`eval echo \\\$ipv4_$host` &
+    ssh $SSHCONF -N root@`eval echo \\\$ipv4_$host` >/dev/null 2>&1 &
     eval ssh_pid_$host="`echo $!`"
+    do_on_exit kill `eval echo \\\$ssh_pid_$host`
 done
 
 
@@ -114,25 +106,22 @@ done
 # create header for the results html file
 #
 
-KERNEL_VERSION=`basename $KERNEL .tar.bz2`
-IPSEC_VERSION=`basename $STRONGSWAN .tar.bz2`
-
 ENVIRONMENT_HEADER=$(cat <<@EOF
-  <table border="0" cellspacing="2">
+  <table border="0" cellspacing="2" cellpadding="2">
     <tr valign="top">
-      <td><b>Host:</b></td>
+      <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>
+      <td><b>Guest kernel</b></td>
+      <td colspan="3">$KERNELVERSION</td>
     </tr>
     <tr valign="top">
-      <td><b>IPsec:</b></td>
-      <td colspan="3">$IPSEC_VERSION</td>
+      <td><b>strongSwan</b></td>
+      <td colspan="3">$SWANVERSION</td>
     </tr>
     <tr valign="top">
-      <td><b>Date:</b></td>
+      <td><b>Date</b></td>
       <td colspan="3">$TESTDATE</td>
     </tr>
     <tr>
@@ -170,10 +159,10 @@ cat > $TESTRESULTSHTML <<@EOF
     </tr>
 @EOF
 
-cecho "UML kernel: $KERNEL_VERSION"
-cecho "IPsec:      $IPSEC_VERSION"
-cecho "Date:       $TESTDATE"
-cecho ""
+echo "Guest kernel : $KERNELVERSION"
+echo "strongSwan   : $SWANVERSION"
+echo "Date         : $TESTDATE"
+echo
 
 
 ##############################################################################
@@ -183,10 +172,6 @@ cecho ""
 if [ $# -gt 0 ]
 then
     TESTS=$*
-elif [ $SELECTEDTESTSONLY = "yes" ]
-then
-    # set internal field seperator
-    TESTS=$SELECTEDTESTS
 else
     # set internal field seperator
     TESTS="`ls $DEFAULTTESTSDIR`"
@@ -208,7 +193,7 @@ do
        mkdir $TODAYDIR/$SUBDIR
        if [ $testnumber == 0 ]
        then
-           FIRST="<b>Category:</b>"
+           FIRST="<b>Category</b>"
        else
            FIRST="&nbsp;"
        fi
@@ -227,17 +212,17 @@ do
 <body>
   <div><a href="../index.html">strongSwan UML Tests</a> / $SUBDIR</div>
   <h2>strongSwan $SUBDIR Tests</h2>
-  <table border="0" cellspacing="2">
+  <table border="0" cellspacing="2" cellpadding="2">
     <tr valign="top">
-      <td><b>UML kernel: &nbsp;</b></td>
-      <td colspan="3">$KERNEL_VERSION</td>
+      <td><b>UML kernel</b></td>
+      <td colspan="3">$KERNELVERSION</td>
     </tr>
     <tr valign="top">
-      <td><b>IPsec:</b></td>
-      <td colspan="3">$IPSEC_VERSION</td>
+      <td><b>strongSwan</b></td>
+      <td colspan="3">$SWANVERSION</td>
     </tr>
     <tr valign="top">
-      <td><b>Date:</b></td>
+      <td><b>Date</b></td>
       <td colspan="3">$TESTDATE</td>
     </tr>
     <tr>
@@ -258,11 +243,11 @@ do
     do
        let "testnumber += 1"
        testname=$SUBDIR/$name
-       cecho-n " $testnumber $testname.."
+       log_action " $testnumber $testname:"
 
        if [ ! -d $DEFAULTTESTSDIR/${testname} ]
        then
-           cecho "is missing..skipped"
+           echo "is missing..skipped"
            continue
        fi
 
@@ -390,7 +375,7 @@ do
        # execute pre-test commands
        #
 
-       cecho-n "pre.."
+       echo -n "pre.."
        echo -e "\nPRE-TEST\n" >> $CONSOLE_LOG 2>&1
 
        eval `awk -F "::" '{
@@ -419,7 +404,7 @@ do
        # get and evaluate test results
        #
 
-       cecho-n "test.."
+       echo -n "test.."
        echo -e "\nTEST\n" >> $CONSOLE_LOG 2>&1
 
        STATUS="passed"
@@ -568,6 +553,9 @@ do
            scp $SSHCONF $HOSTLOGIN:/var/log/freeradius/radius.log \
                $TESTRESULTDIR/${host}.radius.log  > /dev/null 2>&1
 
+           ssh $SSHCONF $HOSTLOGIN grep imcv /var/log/daemon.log \
+               >> $TESTRESULTDIR/${host}.daemon.log
+
            chmod a+r $TESTRESULTDIR/*
            cat >> $TESTRESULTDIR/index.html <<@EOF
     <h3>$host</h3>
@@ -584,6 +572,7 @@ do
          <ul>
            <li><a href="$host.eap.conf">eap.conf</a></li>
            <li><a href="$host.radius.log">radius.log</a></li>
+           <li><a href="$host.daemon.log">daemon.log</a></li>
          </ul>
       </td>
        <td valign="top">
@@ -599,6 +588,28 @@ do
        done
 
        cat >> $TESTRESULTDIR/index.html <<@EOF
+       <h3>tcpdump</h3>
+       <ul>
+@EOF
+
+       for host in $TCPDUMPHOSTS
+       do
+           eval HOSTLOGIN=root@\$ipv4_${host}
+
+               scp $SSHCONF $HOSTLOGIN:/tmp/tcpdump.log \
+                       $TESTRESULTDIR/${host}.tcpdump.log > /dev/null 2>&1
+
+           cat >> $TESTRESULTDIR/index.html <<@EOF
+           <li><a href="$host.tcpdump.log">$host tcpdump.log</a></li>
+@EOF
+
+       done
+
+       cat >> $TESTRESULTDIR/index.html <<@EOF
+       </ul>
+@EOF
+
+       cat >> $TESTRESULTDIR/index.html <<@EOF
   </td></tr>
 </table>
 </body>
@@ -610,7 +621,7 @@ do
        # execute post-test commands
        #
 
-       cecho-n "post.."
+       echo -n "post"
        echo -e "\nPOST-TEST\n" >> $CONSOLE_LOG 2>&1
 
        eval `awk -F "::" '{
@@ -675,11 +686,11 @@ do
 
        if [ $STATUS = "passed" ]
        then
-           COLOR="green"
-           cecho "\033[1;32m$STATUS"
+               COLOR="green"
+               log_status 0
        else
-           COLOR="red"
-           cecho "$STATUS"
+               COLOR="red"
+               log_status 1
        fi
 
        cat >> $TESTRESULTSHTML << @EOF
@@ -724,10 +735,10 @@ cat >> $TESTRESULTSHTML << @EOF
       <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
     </tr>
     <tr>
-      <td><b>Passed:</b></td><td><b><font color="green">$passed_cnt</font></b></td><td>&nbsp;</td><td>&nbsp;</td>
+      <td><b>Passed</b></td><td><b><font color="green">$passed_cnt</font></b></td><td>&nbsp;</td><td>&nbsp;</td>
     </tr>
     <tr>
-      <td><b>Failed:</b></td><td><b><font color="red">$failed_cnt</font></b></td><td>&nbsp;</td><td>&nbsp;</td>
+      <td><b>Failed</b></td><td><b><font color="red">$failed_cnt</font></b></td><td>&nbsp;</td><td>&nbsp;</td>
     </tr>
   </table>
 </body>
@@ -744,7 +755,7 @@ cat >> $INDEX << @EOF
       <td>&nbsp;</td>
     </tr>
     <tr>
-      <td><b>Failed:</b></td>
+      <td><b>Failed</b></td>
       <td>&nbsp;</td>
       <td align="right"><b><font color="red">$failed_cnt</font></b></td>
       <td>&nbsp;</td>
@@ -754,10 +765,10 @@ cat >> $INDEX << @EOF
 </html>
 @EOF
 
-cecho ""
-cecho "\033[1;32mPassed:   $passed_cnt"
-cecho "Failed:   $failed_cnt"
-cecho ""
+echo
+echo_ok     "Passed : $passed_cnt"
+echo_failed "Failed : $failed_cnt"
+echo
 
 
 ##############################################################################
@@ -766,20 +777,13 @@ cecho ""
 
 HTDOCS="/var/www"
 
-cecho-n "Copying test results to winnetou.."
 ssh $SSHCONF root@${ipv4_winnetou} mkdir -p $HTDOCS/testresults > /dev/null 2>&1
 scp $SSHCONF -r $TODAYDIR root@${ipv4_winnetou}:$HTDOCS/testresults > /dev/null 2>&1
 ssh $SSHCONF root@${ipv4_winnetou} ln -s $HTDOCS/images $HTDOCS/testresults/$TESTDATE/images > /dev/null 2>&1
-cgecho "done"
-cecho ""
-cecho "The results are available in $TODAYDIR"
-cecho "or via the link http://$ipv4_winnetou/testresults/$TESTDATE"
-
+echo
+echo "The results are available in $TODAYDIR"
+echo "or via the link http://$ipv4_winnetou/testresults/$TESTDATE"
 
-##########################################################################
-# close ssh sessions
-#
-for host in $STRONGSWANHOSTS
-do
-    kill `eval echo \\\$ssh_pid_$host`
-done
+ENDDATE=`date +%Y%m%d-%H%M`
+echo
+echo "Finished : $ENDDATE"