Added swanctl/net2net-ed2559 scenario and needed Ed25519 certificates
[strongswan.git] / testing / do-tests
index c4c624e..fd5cfe6 100755 (executable)
 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 # for more details.
-#
-# RCSID $Id: do-tests,v 1.20 2006/02/08 21:27:59 as Exp $
-
-DIR=`dirname $0`
 
-source $DIR/scripts/function.sh
+DIR=$(dirname `readlink -f $0`)
+. $DIR/testing.conf
+. $DIR/scripts/function.sh
+SSHCONF="-F $DIR/ssh_config"
 
-[ -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"
+[ -d $BUILDDIR ] ||
+       die "Directory '$BUILDDIR' does not exist, please run make-testing first"
+running_any $STRONGSWANHOSTS || die "Please start test environment before running $0"
 
-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."
-
+ln -sfT $DIR $TESTDIR/testing
 
 ##############################################################################
 # take care of new path and file variables
@@ -40,17 +33,20 @@ source $DIR/testing.conf
 
 [ -d $TESTRESULTSDIR ] || mkdir $TESTRESULTSDIR
 
-TESTDATE=`date +%Y%m%d-%H%M`
+TESTDATE=`date +%Y%m%d-%H%M-%S`
 
 TODAYDIR=$TESTRESULTSDIR/$TESTDATE
 mkdir $TODAYDIR
-TESTRESULTSHTML=$TODAYDIR/index.html
-DEFAULTTESTSDIR=$UMLTESTDIR/testing/tests
+TESTRESULTSHTML=$TODAYDIR/all.html
+INDEX=$TODAYDIR/index.html
+DEFAULTTESTSDIR=$TESTDIR/testing/tests
+
+SOURCEIP_ROUTING_TABLE=220
 
 testnumber="0"
 failed_cnt="0"
 passed_cnt="0"
-
+subdir_cnt="0"
 
 ##############################################################################
 # copy default tests to $BUILDDIR
@@ -58,9 +54,6 @@ passed_cnt="0"
 
 TESTSDIR=$BUILDDIR/tests
 [ -d $TESTSDIR ] || mkdir $TESTSDIR
-rm -rf $TESTSDIR/*
-cp -rfp $DEFAULTTESTSDIR/* $TESTSDIR
-
 
 ##############################################################################
 # assign IP for each host to hostname
@@ -68,279 +61,703 @@ cp -rfp $DEFAULTTESTSDIR/* $TESTSDIR
 
 for host in $STRONGSWANHOSTS
 do
-    eval ip_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $1 }' | awk '{ print $1 }'`"
+    eval ipv4_${host}="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
+    eval ipv6_${host}="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print $1 }'`"
+
     case $host in
     moon)
-        eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`"
-        searchandreplace PH_IP_MOON $ip_moon $TESTSDIR
-        searchandreplace PH_IP1_MOON $ip1_moon $TESTSDIR
+        eval ipv4_moon1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
+        eval ipv6_moon1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
         ;;
     sun)
-        eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`"
-        searchandreplace PH_IP_SUN $ip_sun $TESTSDIR
-        searchandreplace PH_IP1_SUN $ip1_sun $TESTSDIR
+        eval ipv4_sun1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
+        eval ipv6_sun1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
         ;;
     alice)
-        searchandreplace PH_IP_ALICE $ip_alice $TESTSDIR
+        eval ipv4_alice1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
+        eval ipv6_alice1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
         ;;
     venus)
-        searchandreplace PH_IP_VENUS $ip_venus $TESTSDIR
         ;;
     bob)
-        searchandreplace PH_IP_BOB $ip_bob $TESTSDIR
         ;;
     carol)
-        eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`"
-        searchandreplace PH_IP_CAROL $ip_carol $TESTSDIR
-        searchandreplace PH_IP1_CAROL $ip1_carol $TESTSDIR
-        ;;
+        eval ipv4_carol1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
+        eval ipv6_carol1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
+         ;;
     dave)
-        eval ip1_${host}="`echo $HOSTNAMEIPS | sed -n -e "s/^.*${host}://gp" | awk -F : '{ print $2 }' | awk '{ print $1 }'`"
-        searchandreplace PH_IP_DAVE $ip_dave $TESTSDIR
-        searchandreplace PH_IP1_DAVE $ip1_dave $TESTSDIR
+        eval ipv4_dave1="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
+        eval ipv6_dave1="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $2 }' | awk '{ print $1 }'`"
         ;;
     winnetou)
-        searchandreplace PH_IP_WINNETOU $ip_winnetou $TESTSDIR
         ;;
     esac
 done
 
 
 ##############################################################################
+# open ssh sessions
+#
+for host in $STRONGSWANHOSTS
+do
+    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
+
+##############################################################################
+# determine actual software versions
+#
+
+[ -f $SHAREDDIR/.strongswan-version ] && SWANVERSION=`cat $SHAREDDIR/.strongswan-version`
+KERNELVERSION=`ssh $SSHCONF root@\$ipv4_winnetou uname -r 2>/dev/null`
+
+# check if tcpdump supports --immediate-mode
+ssh $SSHCONF root@$ipv4_winnetou tcpdump --immediate-mode -c 1 >/dev/null 2>&1
+if [ $? -eq 0 ]
+then
+       TCPDUMP_IM=--immediate-mode
+fi
+
+##############################################################################
 # 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" cellpadding="2">
+    <tr valign="top">
+      <td><b>Host</b></td>
+      <td colspan="3">`uname -a`</td>
+    </tr>
+    <tr valign="top">
+      <td><b>Guest kernel</b></td>
+      <td colspan="3">$KERNELVERSION</td>
+    </tr>
+    <tr valign="top">
+      <td><b>strongSwan</b></td>
+      <td colspan="3">$SWANVERSION</td>
+    </tr>
+    <tr valign="top">
+      <td><b>Date</b></td>
+      <td colspan="3">$TESTDATE</td>
+    </tr>
+    <tr>
+      <td width="100">&nbsp;</td>
+      <td width="300">&nbsp;</td>
+      <td width=" 80">&nbsp;</td>
+      <td >&nbsp;</td>
+    </tr>
+@EOF
+)
+
+cat > $INDEX <<@EOF
+<html>
+<head>
+  <title>strongSwan KVM Tests</title>
+</head>
+<body>
+  <h2>strongSwan KVM Tests</h2>
+  $ENVIRONMENT_HEADER
+@EOF
 
 cat > $TESTRESULTSHTML <<@EOF
 <html>
 <head>
-  <title>strongSwan UML Testing</title>
+  <title>strongSwan KVM Tests - All Tests</title>
 </head>
 <body>
-  <h2>strongSwan UML Testing</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>
+  <div><a href="index.html">strongSwan KVM Tests</a> / All Tests</div>
+  <h2>All Tests</h2>
+  $ENVIRONMENT_HEADER
+    <tr align="left">
+      <th>Number</th>
+      <th>Test</th>
+      <th align="right">Time [s]</th>
+      <th>Result</th>
+    </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
+
+##############################################################################
+# trap CTRL-C to properly terminate a long run
+#
 
+function abort_tests()
+{
+       echo -n "...aborting..." > /dev/tty
+       aborted=YES
+}
+trap abort_tests INT
 
 ##############################################################################
 # enter specific test directory
 #
-
 if [ $# -gt 0 ]
 then
-    TESTS=$*
-elif [ $SELECTEDTESTSONLY = "yes" ]
-then
-    # set internal field seperator
-    TESTS=$SELECTEDTESTS
+    TESTS=$(printf "%s\n" $* | sort -u)
 else
-    # set internal field seperator
-    TESTS="`ls $TESTSDIR`"
+    TESTS=$(ls $DEFAULTTESTSDIR)
 fi
 
-for testname in $TESTS
+for SUBDIR in $TESTS
 do
-    let "testnumber += 1"
-    cecho-n " $testnumber $testname.."
-    
-    if [ ! -d $TESTSDIR/${testname} ]
+    SUBTESTS="`basename $SUBDIR`"
+
+    if [ $SUBTESTS = $SUBDIR ]
+    then
+       SUBTESTS="`ls $DEFAULTTESTSDIR/$SUBDIR`"
+    else
+       SUBDIR="`dirname $SUBDIR`"
+    fi
+
+    if [ ! -d $TODAYDIR/$SUBDIR ]
     then
-       cecho "is missing..skipped"
-       continue
+       mkdir $TODAYDIR/$SUBDIR
+       if [ $testnumber == 0 ]
+       then
+           FIRST="<b>Category</b>"
+       else
+           FIRST="&nbsp;"
+       fi
+
+       if [ $subdir_cnt != 0 ]
+       then
+           echo "      <td align=\"right\">$subdir_cnt</td>" >> $INDEX
+           echo "      <td>&nbsp;</td>" >> $INDEX
+           echo "    </tr>" >> $INDEX
+           subdir_cnt="0"
+       fi
+       echo "    <tr>" >> $INDEX
+    echo "      <td>$FIRST</td>">> $INDEX
+    echo "      <td><a href=\"$SUBDIR/index.html\">$SUBDIR</a></td>" >> $INDEX
+
+       SUBTESTSINDEX=$TODAYDIR/$SUBDIR/index.html
+       cat > $SUBTESTSINDEX <<@EOF
+<html>
+<head>
+  <title>strongSwan $SUBDIR Tests</title>
+</head>
+<body>
+  <div><a href="../index.html">strongSwan KVM Tests</a> / $SUBDIR</div>
+  <h2>strongSwan $SUBDIR Tests</h2>
+  <table border="0" cellspacing="2" cellpadding="2">
+    <tr valign="top">
+      <td><b>Guest kernel</b></td>
+      <td colspan="3">$KERNELVERSION</td>
+    </tr>
+    <tr valign="top">
+      <td><b>strongSwan</b></td>
+      <td colspan="3">$SWANVERSION</td>
+    </tr>
+    <tr valign="top">
+      <td><b>Date</b></td>
+      <td colspan="3">$TESTDATE</td>
+    </tr>
+    <tr>
+      <td width="100">&nbsp;</td>
+      <td width="300">&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
 
-    [ -f $TESTSDIR/${testname}/description.txt ] || die "!! File 'description.txt' is missing"
-    [ -f $TESTSDIR/${testname}/test.conf ]       || die "!! File 'test.conf' is missing"
-    [ -f $TESTSDIR/${testname}/pretest.dat ]     || die "!! File 'pretest.dat' is missing"
-    [ -f $TESTSDIR/${testname}/posttest.dat ]    || die "!! File 'posttest.dat' is missing"
-    [ -f $TESTSDIR/${testname}/evaltest.dat ]    || die "!! File 'evaltest.dat' is missing"
+    for name in $SUBTESTS
+    do
+       let "testnumber += 1"
+       let "subdir_cnt += 1"
+       testname=$SUBDIR/$name
+       log_action " $testnumber $testname:"
 
-    TESTRESULTDIR=$TODAYDIR/$testname
-    mkdir $TESTRESULTDIR
-    CONSOLE_LOG=$TESTRESULTDIR/console.log
-    touch $CONSOLE_LOG
+       teststart=$(date +%s)
 
+       if [ ! -d $DEFAULTTESTSDIR/${testname} ]
+       then
+           echo "is missing..skipped"
+           continue
+       fi
 
-    ##########################################################################
-    # copy test specific configurations to uml hosts and clear auth.log files
-    #
+       [ -f $DEFAULTTESTSDIR/${testname}/description.txt ] || die "!! File 'description.txt' is missing"
+       [ -f $DEFAULTTESTSDIR/${testname}/test.conf ]       || die "!! File 'test.conf' is missing"
+       [ -f $DEFAULTTESTSDIR/${testname}/pretest.dat ]     || die "!! File 'pretest.dat' is missing"
+       [ -f $DEFAULTTESTSDIR/${testname}/posttest.dat ]    || die "!! File 'posttest.dat' is missing"
+       [ -f $DEFAULTTESTSDIR/${testname}/evaltest.dat ]    || die "!! File 'evaltest.dat' is missing"
 
-    $DIR/scripts/load-testconfig $testname
-    source $TESTSDIR/$testname/test.conf
+       TESTRESULTDIR=$TODAYDIR/$testname
+       mkdir -p $TESTRESULTDIR
+       CONSOLE_LOG=$TESTRESULTDIR/console.log
+       touch $CONSOLE_LOG
 
-    
-    ##########################################################################
-    # run tcpdump in the background
-    #
+       TESTDIR=$TESTSDIR/${testname}
+       rm -rf $TESTDIR
+       mkdir -p $TESTDIR
+       cp -rfp $DEFAULTTESTSDIR/${testname}/* $TESTDIR
 
-    if [ "$TCPDUMPHOSTS" != "" ]
-    then
-        echo -e "TCPDUMP\n" >> $CONSOLE_LOG 2>&1
-
-        for host_iface in $TCPDUMPHOSTS
-        do
-           host=`echo $host_iface | awk -F ":" '{print $1}'`
-           iface=`echo $host_iface | awk -F ":" '{if ($2 != "") { print $2 } else { printf("eth0") }}'`
-           tcpdump_cmd="tcpdump -i $iface not port ssh and not port domain and not arp > /tmp/tcpdump.log 2>&1 &"
-            echo "${host}# $tcpdump_cmd" >> $CONSOLE_LOG
-            ssh root@`eval echo \\\$ip_$host '$tcpdump_cmd'`
-           eval TDUP_${host}="true"
-        done
-    fi
 
-    ##########################################################################
-    # execute pre-test commands
-    #
+       ##############################################################################
+       # replace IP wildcards with actual IPv4 and IPv6 addresses
+       #
 
-    cecho-n "pre.."
-    echo -e "\nPRE-TEST\n" >> $CONSOLE_LOG 2>&1
+       for host in $STRONGSWANHOSTS
+       do
+           case $host in
+           moon)
+               searchandreplace PH_IP_MOON1     $ipv4_moon1 $TESTDIR
+               searchandreplace PH_IP_MOON      $ipv4_moon  $TESTDIR
+               searchandreplace PH_IP6_MOON1    $ipv6_moon1 $TESTDIR
+               searchandreplace PH_IP6_MOON     $ipv6_moon  $TESTDIR
+               ;;
+           sun)
+               searchandreplace PH_IP_SUN1      $ipv4_sun1 $TESTDIR
+               searchandreplace PH_IP_SUN       $ipv4_sun  $TESTDIR
+               searchandreplace PH_IP6_SUN1     $ipv6_sun1 $TESTDIR
+               searchandreplace PH_IP6_SUN      $ipv6_sun  $TESTDIR
+               ;;
+           alice)
+               searchandreplace PH_IP_ALICE1    $ipv4_alice1 $TESTDIR
+               searchandreplace PH_IP_ALICE     $ipv4_alice  $TESTDIR
+               searchandreplace PH_IP6_ALICE1   $ipv6_alice1 $TESTDIR
+               searchandreplace PH_IP6_ALICE    $ipv6_alice  $TESTDIR
+               ;;
+           venus)
+               searchandreplace PH_IP_VENUS     $ipv4_venus $TESTDIR
+               searchandreplace PH_IP6_VENUS    $ipv6_venus $TESTDIR
+               ;;
+           bob)
+               searchandreplace PH_IP_BOB       $ipv4_bob $TESTDIR
+               searchandreplace PH_IPV6_BOB     $ipv6_bob $TESTDIR
+               ;;
+           carol)
+               searchandreplace PH_IP_CAROL1    $ipv4_carol1 $TESTDIR
+               searchandreplace PH_IP_CAROL     $ipv4_carol  $TESTDIR
+               searchandreplace PH_IP6_CAROL1   $ipv6_carol1 $TESTDIR
+               searchandreplace PH_IP6_CAROL    $ipv6_carol  $TESTDIR
+               ;;
+           dave)
+               searchandreplace PH_IP_DAVE1     $ipv4_dave1 $TESTDIR
+               searchandreplace PH_IP_DAVE      $ipv4_dave  $TESTDIR
+               searchandreplace PH_IP6_DAVE1    $ipv6_dave1 $TESTDIR
+               searchandreplace PH_IP6_DAVE     $ipv6_dave  $TESTDIR
+               ;;
+           winnetou)
+               searchandreplace PH_IP_WINNETOU  $ipv4_winnetou $TESTDIR
+               searchandreplace PH_IP6_WINNETOU $ipv6_winnetou $TESTDIR
+               ;;
+           esac
+       done
 
-    eval `awk -F "::" '{
-       if ($2 != "")
-       {
-           printf("echo \"%s# %s\"; ", $1, $2)
-           printf("ssh root@\044ip_%s \"%s\"; ", $1, $2)
-           printf("echo;\n")
-       }
-    }' $TESTSDIR/${testname}/pretest.dat` >> $CONSOLE_LOG 2>&1
 
+       ##########################################################################
+       # copy test specific configurations to hosts and clear log files
+       #
 
-    ##########################################################################
-    # stop tcpdump
-    #
+       DBDIR=/etc/db.d
 
-    function stop_tcpdump {
-        echo "${1}# killall tcpdump" >> $CONSOLE_LOG
-        eval ssh root@\$ip_${1} killall tcpdump
-        eval TDUP_${1}="false"
-       echo ""
-    }
+       $DIR/scripts/load-testconfig $testname
+       unset RADIUSHOSTS
+       unset DBHOSTS
+       unset IPV6
+       unset SWANCTL
+       source $TESTDIR/test.conf
 
 
-    ##########################################################################
-    # get and evaluate test results
-    #
+       ##########################################################################
+       # run tcpdump in the background
+       #
 
-    cecho-n "test.."
-    echo -e "\nTEST\n" >> $CONSOLE_LOG 2>&1
+       if [ "$TCPDUMPHOSTS" != "" ]
+       then
+           echo -e "TCPDUMP\n" >> $CONSOLE_LOG 2>&1
+
+           for host_iface in $TCPDUMPHOSTS
+           do
+               host=`echo $host_iface | awk -F ":" '{print $1}'`
+               iface=`echo $host_iface | awk -F ":" '{if ($2 != "") { print $2 } else { printf("eth0") }}'`
+               tcpdump_cmd="tcpdump -l $TCPDUMP_IM -i $iface not port ssh and not port domain >/tmp/tcpdump.log 2>/tmp/tcpdump.err.log &"
+               echo "${host}# $tcpdump_cmd" >> $CONSOLE_LOG
+               ssh $SSHCONF root@`eval echo \\\$ipv4_$host '$tcpdump_cmd'`
+               eval TDUP_${host}="true"
+           done
+       fi
 
-    STATUS="passed"
+       ##########################################################################
+       # create database directory in RAM
+       #
 
-    eval `awk -F "::" '{
-       host=$1
-       command=$2
-       pattern=$3
-       hit=$4
-       if (command != "")
-       {
-           if (command == "tcpdump")
-           {
-               printf("if [ \044TDUP_%s == \"true\" ]; then stop_tcpdump %s; fi; \n", host, host)
-               printf("echo \"%s# cat /tmp/tcpdump.log | grep \047%s\047  [%s]\"; ", host, pattern, hit)
-               printf("ssh root@\044ip_%s cat /tmp/tcpdump.log | grep \"%s\"; ", host, pattern)
-           }
-           else
+       for host in $DBHOSTS
+       do
+               eval HOSTLOGIN=root@\$ipv4_${host}
+           ssh $SSHCONF $HOSTLOGIN "mkdir -p $DBDIR; mount -t ramfs -o size=5m ramfs $DBDIR" >/dev/null 2>&1
+           ssh $SSHCONF $HOSTLOGIN "chgrp www-data $DBDIR; chmod g+w $DBDIR" >/dev/null 2>&1
+       done
+
+       ##########################################################################
+       # flush conntrack table on all hosts
+       #
+
+       for host in $STRONGSWANHOSTS
+       do
+               ssh $SSHCONF root@`eval echo \\\$ipv4_$host` 'conntrack -F' >/dev/null 2>&1
+       done
+
+       ##########################################################################
+       # remove leak detective log on all hosts
+       #
+
+       export LEAK_DETECTIVE_LOG=/var/log/leak-detective.log
+       for host in $STRONGSWANHOSTS
+       do
+               ssh $SSHCONF root@`eval echo \\\$ipv4_$host` 'rm -f $LEAK_DETECTIVE_LOG' >/dev/null 2>&1
+       done
+
+       ##########################################################################
+       # flush IPsec state on all hosts
+       #
+
+       for host in $STRONGSWANHOSTS
+       do
+               ssh $SSHCONF root@`eval echo \\\$ipv4_$host` 'ip xfrm state flush; ip xfrm policy flush' >/dev/null 2>&1
+       done
+
+       ##########################################################################
+       # execute pre-test commands
+       #
+
+       echo -n "pre.."
+       echo -e "\nPRE-TEST\n" >> $CONSOLE_LOG 2>&1
+
+       eval `awk -F "::" '{
+           if ($1 !~ /^#.*/ && $2 != "")
            {
-               printf("echo \"%s# %s | grep \047%s\047  [%s]\"; ", host, command, pattern, hit)
-               printf("ssh root@\044ip_%s %s | grep \"%s\"; ",  host, command, pattern)
+               printf("echo \"%s# %s\"; ", $1, $2)
+               printf("ssh \044SSHCONF root@\044ipv4_%s \"%s\"; ", $1, $2)
+               printf("echo;\n")
            }
-           printf("cmd_exit=\044?; ")
-           printf("echo; ")
-           printf("if [ \044cmd_exit -eq 0 -a \"%s\" = \"NO\"  ] ", hit)
-           printf("|| [ \044cmd_exit -ne 0 -a \"%s\" = \"YES\" ] ", hit)
-           printf("; then STATUS=\"failed\"; fi; \n")
+       }' $TESTDIR/pretest.dat` >> $CONSOLE_LOG 2>&1
 
+
+       ##########################################################################
+       # stop tcpdump
+       #
+
+       function stop_tcpdump {
+           # wait for packets to get processed, but don't wait longer than 1s
+           eval ssh $SSHCONF root@\$ipv4_${1} "\"i=100; while [ \\\$i -gt 0 ]; do pkill -USR1 tcpdump; tail -1 /tmp/tcpdump.err.log | perl -n -e '/(\\d+).*?(\\d+)/; exit (\\\$1 == \\\$2)' || break; sleep 0.01; i=\\\$((\\\$i-1)); done;\""
+           echo "${1}# killall tcpdump" >> $CONSOLE_LOG
+           eval ssh $SSHCONF root@\$ipv4_${1} "\"killall tcpdump; while true; do killall -q -0 tcpdump || break; sleep 0.01; done;\""
+           eval TDUP_${1}="false"
+           echo "" >> $CONSOLE_LOG
        }
-    }' $TESTSDIR/${testname}/evaltest.dat` >> $CONSOLE_LOG 2>&1
 
 
-    ##########################################################################
-    # set counters
-    #
+       ##########################################################################
+       # get and evaluate test results
+       #
 
-    if [ $STATUS = "failed" ]
-    then
-        let "failed_cnt += 1"
-    else
-        let "passed_cnt += 1"
-    fi
+       echo -n "test.."
+       echo -e "\nTEST\n" >> $CONSOLE_LOG 2>&1
+
+       STATUS="passed"
+
+       eval `awk -F "::" '{
+           host=$1
+           command=$2
+           pattern=$3
+           hit=$4
+           if (host !~ /^#.*/ && command != "")
+           {
+               if (command == "tcpdump")
+               {
+                   printf("if [ \044TDUP_%s == \"true\" ]; then stop_tcpdump %s; fi; \n", host, host)
+                   printf("echo \"%s# cat /tmp/tcpdump.log | grep \047%s\047  [%s]\"; ", host, pattern, hit)
+                   printf("ssh \044SSHCONF root@\044ipv4_%s cat /tmp/tcpdump.log | grep \"%s\"; ", host, pattern)
+               }
+               else
+               {
+                   printf("echo \"%s# %s | grep \047%s\047  [%s]\"; ", host, command, pattern, hit)
+                   printf("ssh \044SSHCONF root@\044ipv4_%s %s | grep \"%s\"; ",  host, command, pattern)
+               }
+               printf("cmd_exit=\044?; ")
+               printf("echo; ")
+               printf("if [ \044cmd_exit -eq 0 -a \"%s\" = \"NO\"  ] ", hit)
+               printf("|| [ \044cmd_exit -ne 0 -a \"%s\" = \"YES\" ] ", hit)
+               printf("; then STATUS=\"failed\"; fi; \n")
+           }
+       }' $TESTDIR/evaltest.dat` >> $CONSOLE_LOG 2>&1
 
 
-    ##########################################################################
-    # log statusall and listall output
-    # get copies of ipsec.conf, ipsec.secrets
-    # create index.html for the given test case
+       ##########################################################################
+       # log statusall and listall output
+       # get copies of ipsec.conf, ipsec.secrets
+       # create index.html for the given test case
 
-    cat > $TESTRESULTDIR/index.html <<@EOF
+       cat > $TESTRESULTDIR/index.html <<@EOF
 <html>
 <head>
   <title>Test $testname</title>
 </head>
 <body>
-<table border="0" width="600">
+<table border="0" cellpadding="0" cellspacing="0" width="600">
   <tr><td>
+    <div><a href="../../index.html">strongSwan KVM Tests</a> / <a href="../index.html">$SUBDIR</a> / $name</div>
     <h2>Test $testname</h2>
     <h3>Description</h3>
 @EOF
 
-    cat $TESTSDIR/${testname}/description.txt >> $TESTRESULTDIR/index.html
+       cat $TESTDIR/description.txt >> $TESTRESULTDIR/index.html
 
-    cat >> $TESTRESULTDIR/index.html <<@EOF
+       cat >> $TESTRESULTDIR/index.html <<@EOF
     <ul>
       <li><a href="console.log">console.log</a></li>
     </ul>
-    <img src="../images/$DIAGRAM" alt="$UMLHOSTS">
+    <img src="../../images/$DIAGRAM" alt="$VIRTHOSTS">
 @EOF
 
+       IPTABLES_CMD_V4="echo -e '=== filter table ==='; iptables  -v -n -L; echo -e '\n=== nat table ==='; iptables  -v -n -t nat -L; echo -e '\n=== mangle table ==='; iptables  -v -n -t mangle -L"
+       IPTABLES_CMD_V6="echo -e '=== filter table ==='; ip6tables -v -n -L; echo -e '\n=== nat table ==='; ip6tables -v -n -t nat -L; echo -e '\n=== mangle table ==='; ip6tables -v -n -t mangle -L"
 
-    for host in $IPSECHOSTS
-    do
-       eval HOSTLOGIN=root@\$ip_${host}
+       if [ -n "$IPV6" ]
+       then
+           IPROUTE_CMD="ip -6 route list table $SOURCEIP_ROUTING_TABLE"
+           IPROUTE_DSP=$IPROUTE_CMD
+           IPTABLES_CMD="$IPTABLES_CMD_V6"
+           IPTABLES_DSP="ip6tables -L"
+           IPTABLES_SAVE_CMD="ip6tables-save"
+           IPTABLES_SAVE_DSP="ip6tables-save"
+       else
+           IPROUTE_CMD="ip route list table $SOURCEIP_ROUTING_TABLE"
+           IPROUTE_DSP=$IPROUTE_CMD
+           IPTABLES_CMD="$IPTABLES_CMD_V4"
+           IPTABLES_DSP="iptables -L"
+           IPTABLES_SAVE_CMD="iptables-save"
+           IPTABLES_SAVE_DSP="iptables-save"
+       fi
+
+       if [ $name = "net2net-ip4-in-ip6-ikev2" -o $name = "net2net-ip6-in-ip4-ikev2" ]
+       then
+           IPROUTE_CMD="ip route list table $SOURCEIP_ROUTING_TABLE; echo; ip -6 route list table $SOURCEIP_ROUTING_TABLE"
+           IPROUTE_DSP="ip (-6) route list table $SOURCEIP_ROUTING_TABLE"
+           IPTABLES_CMD="$IPTABLES_CMD_V4; echo; $IPTABLES_CMD_V6"
+           IPTABLES_DSP="iptables -L ; ip6tables -L"
+           IPTABLES_SAVE_CMD="iptables-save; echo; ip6tables-save"
+           IPTABLES_SAVE_DSP="iptables-save ; ip6tables-save"
+       fi
 
-       for command in statusall listall
+       for host in $DBHOSTS
        do
-           ssh $HOSTLOGIN ipsec $command \
-               > $TESTRESULTDIR/${host}.$command 2>/dev/null
+           eval HOSTLOGIN=root@\$ipv4_${host}
+
+               scp $SSHCONF $HOSTLOGIN:/etc/db.d/ipsec.sql \
+                   $TESTRESULTDIR/${host}.ipsec.sql  > /dev/null 2>&1
        done
 
-       for file in ipsec.conf ipsec.secrets
+       for host in $IPSECHOSTS
        do
-           scp $HOSTLOGIN:/etc/$file \
-               $TESTRESULTDIR/${host}.$file  > /dev/null 2>&1
+           eval HOSTLOGIN=root@\$ipv4_${host}
+
+               scp $SSHCONF $HOSTLOGIN:/etc/strongswan.conf \
+                   $TESTRESULTDIR/${host}.strongswan.conf  > /dev/null 2>&1
+               if [  -n "$SWANCTL" ]
+               then
+                       scp $SSHCONF $HOSTLOGIN:/etc/swanctl/swanctl.conf \
+                       $TESTRESULTDIR/${host}.swanctl.conf  > /dev/null 2>&1
+
+                       for subsys in conns algs certs pools authorities sas pols
+                       do
+                               ssh $SSHCONF $HOSTLOGIN swanctl --list-$subsys \
+                                       > $TESTRESULTDIR/${host}.swanctl.$subsys 2>/dev/null
+                       done
+
+                       ssh $SSHCONF $HOSTLOGIN swanctl --stats \
+                               > $TESTRESULTDIR/${host}.swanctl.stats 2>/dev/null
+
+                       echo "" >> $TESTRESULTDIR/${host}.swanctl.sas
+                       cat $TESTRESULTDIR/${host}.swanctl.pols >> \
+                               $TESTRESULTDIR/${host}.swanctl.sas
+                       cat $TESTRESULTDIR/${host}.swanctl.algs >> \
+                               $TESTRESULTDIR/${host}.swanctl.stats
+               else
+                   for file in ipsec.conf ipsec.secrets
+                   do
+                               scp $SSHCONF $HOSTLOGIN:/etc/$file \
+                           $TESTRESULTDIR/${host}.$file  > /dev/null 2>&1
+                   done
+
+                   for command in statusall listall
+                   do
+                               ssh $SSHCONF $HOSTLOGIN ipsec $command \
+                           > $TESTRESULTDIR/${host}.$command 2>/dev/null
+                   done
+               fi
+
+               if (! [ -f $TESTRESULTDIR/${host}.ipsec.sql ] ) then
+                       scp $SSHCONF $HOSTLOGIN:/etc/ipsec.d/ipsec.sql \
+                               $TESTRESULTDIR/${host}.ipsec.sql  > /dev/null 2>&1
+               fi
+
+           ssh $SSHCONF $HOSTLOGIN ip -s xfrm policy \
+                   > $TESTRESULTDIR/${host}.ip.policy 2>/dev/null
+           ssh $SSHCONF $HOSTLOGIN ip -s xfrm state \
+                   > $TESTRESULTDIR/${host}.ip.state 2>/dev/null
+           ssh $SSHCONF $HOSTLOGIN $IPROUTE_CMD \
+                   > $TESTRESULTDIR/${host}.ip.route 2>/dev/null
+           ssh $SSHCONF $HOSTLOGIN $IPTABLES_CMD \
+                   > $TESTRESULTDIR/${host}.iptables 2>/dev/null
+               ssh $SSHCONF $HOSTLOGIN $IPTABLES_SAVE_CMD \
+                   > $TESTRESULTDIR/${host}.iptables-save 2>/dev/null
+           chmod a+r $TESTRESULTDIR/*
+
+               if [ -n "$SWANCTL" ]
+               then
+                   cat >> $TESTRESULTDIR/index.html <<@EOF
+    <h3>$host</h3>
+      <table border="0" cellspacing="0" width="600">
+      <tr>
+       <td valign="top">
+         <ul>
+           <li><a href="$host.swanctl.conf">swanctl.conf</a></li>
+           <li><a href="$host.swanctl.conns">swanctl --list-conns</a></li>
+           <li><a href="$host.swanctl.certs">swanctl --list-certs</a></li>
+           <li><a href="$host.strongswan.conf">strongswan.conf</a></li>
+           <li><a href="$host.ipsec.sql">ipsec.sql</a></li>
+         </ul>
+       </td>
+       <td valign="top">
+         <ul>
+           <li><a href="$host.swanctl.sas">swanctl --list-sas|--list-pols</a></li>
+           <li><a href="$host.swanctl.pools">swanctl --list-pools</a></li>
+           <li><a href="$host.swanctl.authorities">swanctl --list-authorities</a></li>
+           <li><a href="$host.swanctl.stats">swanctl --stats|--list-algs</a></li>
+           <li><a href="$host.auth.log">auth.log</a></li>
+           <li><a href="$host.daemon.log">daemon.log</a></li>
+         </ul>
+      </td>
+       <td valign="top">
+         <ul>
+           <li><a href="$host.ip.policy">ip -s xfrm policy</a></li>
+           <li><a href="$host.ip.state">ip -s xfrm state</a></li>
+           <li><a href="$host.ip.route">$IPROUTE_DSP</a></li>
+           <li><a href="$host.iptables">$IPTABLES_DSP</a></li>
+           <li><a href="$host.iptables-save">$IPTABLES_SAVE_DSP</a></li>
+         </ul>
+         &nbsp;
+      </td>
+    </tr>
+    </table>
+@EOF
+
+               else
+                   cat >> $TESTRESULTDIR/index.html <<@EOF
+    <h3>$host</h3>
+      <table border="0" cellspacing="0" width="600">
+      <tr>
+       <td valign="top">
+         <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.ipsec.sql">ipsec.sql</a></li>
+           <li><a href="$host.strongswan.conf">strongswan.conf</a></li>
+         </ul>
+       </td>
+       <td valign="top">
+         <ul>
+           <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>
+           <li><a href="$host.daemon.log">daemon.log</a></li>
+         </ul>
+      </td>
+       <td valign="top">
+         <ul>
+           <li><a href="$host.ip.policy">ip -s xfrm policy</a></li>
+           <li><a href="$host.ip.state">ip -s xfrm state</a></li>
+           <li><a href="$host.ip.route">$IPROUTE_DSP</a></li>
+           <li><a href="$host.iptables">$IPTABLES_DSP</a></li>
+           <li><a href="$host.iptables-save">$IPTABLES_SAVE_DSP</a></li>
+         </ul>
+      </td>
+    </tr>
+    </table>
+@EOF
+               fi
        done
 
-       cat >> $TESTRESULTDIR/index.html <<@EOF
+       for host in $RADIUSHOSTS
+       do
+           eval HOSTLOGIN=root@\$ipv4_${host}
+
+           for file in clients.conf eap.conf radiusd.conf proxy.conf users
+           do
+               scp $SSHCONF $HOSTLOGIN:/etc/freeradius/$file \
+                   $TESTRESULTDIR/${host}.$file  > /dev/null 2>&1
+           done
+
+               scp $SSHCONF $HOSTLOGIN:/etc/strongswan.conf \
+                   $TESTRESULTDIR/${host}.strongswan.conf  > /dev/null 2>&1
+
+           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 2>/dev/null
+
+           chmod a+r $TESTRESULTDIR/*
+           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="600">
+      <tr>
+       <td valign="top">
+         <ul>
+           <li><a href="$host.clients.conf">clients.conf</a></li>
+           <li><a href="$host.radiusd.conf">radiusd.conf</a></li>
+           <li><a href="$host.strongswan.conf">strongswan.conf</a></li>
+         </ul>
+       </td>
+       <td valign="top">
+         <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">
+         <ul>
+           <li><a href="$host.proxy.conf">proxy.conf</a></li>
+           <li><a href="$host.users">users</a></li>
+         </ul>
+      </td>
+    </tr>
+    </table>
 @EOF
 
-    done
+       done
 
-    cat >> $TESTRESULTDIR/index.html <<@EOF
-  </td></tr>
-  <tr><td align="right">
-    <b><a href="../index.html">Back</a></b>
+       cat >> $TESTRESULTDIR/index.html <<@EOF
+       <h3>tcpdump</h3>
+       <ul>
+@EOF
+
+       for host in $TCPDUMPHOSTS
+       do
+           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>
@@ -348,79 +765,178 @@ do
 @EOF
 
 
-    ##########################################################################
-    # execute post-test commands
-    #
+       ##########################################################################
+       # execute post-test commands
+       #
 
-    cecho-n "post.."
-    echo -e "\nPOST-TEST\n" >> $CONSOLE_LOG 2>&1
+       echo -n "post"
+       echo -e "\nPOST-TEST\n" >> $CONSOLE_LOG 2>&1
 
-    eval `awk -F "::" '{
-       if ($2 != "")
-       {
-           printf("echo \"%s# %s\"; ", $1, $2)
-           printf("ssh root@\044ip_%s \"%s\"; ", $1, $2)
-           printf("echo;\n")
-       }
-    }' $TESTSDIR/${testname}/posttest.dat` >> $CONSOLE_LOG 2>&1
+       eval `awk -F "::" '{
+           if ($1 !~ /^#.*/ && $2 != "")
+           {
+               printf("echo \"%s# %s\"; ", $1, $2)
+               printf("ssh \044SSHCONF root@\044ipv4_%s \"%s\"; ", $1, $2)
+               printf("echo;\n")
+           }
+       }' $TESTDIR/posttest.dat` >> $CONSOLE_LOG 2>&1
 
+       ##########################################################################
+       # check that IPsec state was cleaned up properly
+       #
 
-    ##########################################################################
-    # get a copy of /var/log/auth.log
-    #
+       for host in $IPSECHOSTS
+       do
+               eval HOSTLOGIN=root@\$ipv4_${host}
+               IPSECSTATE=`ssh $SSHCONF $HOSTLOGIN 'ip xfrm state'`
+               IPSECPOLICY=`ssh $SSHCONF $HOSTLOGIN 'ip xfrm policy'`
+               if [ -n "$IPSECSTATE" -o -n "$IPSECPOLICY" ]
+               then
+                       echo -e "\n$host# ip xfrm state [NO]" >> $CONSOLE_LOG
+                       echo "$IPSECSTATE" >> $CONSOLE_LOG
+                       echo -e "\n$host# ip xfrm policy [NO]" >> $CONSOLE_LOG
+                       echo "$IPSECPOLICY" >> $CONSOLE_LOG
+                       STATUS="failed"
+               fi
+       done
 
-    for host in $IPSECHOSTS
-    do
-       eval HOSTLOGIN=root@\$ip_${host}
-       ssh $HOSTLOGIN grep pluto /var/log/auth.log \
-           > $TESTRESULTDIR/${host}.auth.log
-       echo >> $TESTRESULTDIR/${host}.auth.log
-       ssh $HOSTLOGIN grep charon /var/log/auth.log \
-           >> $TESTRESULTDIR/${host}.auth.log
-    done
+
+       ##########################################################################
+       # make sure there were no leaks
+       #
+
+       for host in $STRONGSWANHOSTS
+       do
+               eval HOSTLOGIN=root@\$ipv4_${host}
+               LEAKS=`ssh $SSHCONF $HOSTLOGIN 'cat $LEAK_DETECTIVE_LOG 2>/dev/null | grep -v "No leaks detected.*"'`
+               if [ -n "$LEAKS" ]
+               then
+                       echo -e "\n$host# cat $LEAK_DETECTIVE_LOG [NO]" >> $CONSOLE_LOG
+                       echo "$LEAKS" >> $CONSOLE_LOG
+                       echo "<<< $host $LEAK_DETECTIVE_LOG >>>" >> $CONSOLE_LOG
+                       STATUS="failed"
+               fi
+       done
 
 
-    ##########################################################################
-    # stop tcpdump if necessary
-    #
+       ##########################################################################
+       # get a copy of /var/log/auth.log
+       #
 
-    for host in $TCPDUMPHOSTS
-    do
-       if [ "`eval echo \\\$TDUP_${host}`" = "true" ]
-       then
-           echo "${host}# killall tcpdump" >> $CONSOLE_LOG
-           eval ssh root@\$ip_$host killall tcpdump
-           eval TDUP_${host}="false"
-       fi
-    done
+       for host in $IPSECHOSTS
+       do
+           eval HOSTLOGIN=root@\$ipv4_${host}
+           ssh $SSHCONF $HOSTLOGIN "grep -s -E 'charon|last message repeated|imcv|pt-tls-client' \
+               /var/log/auth.log" >> $TESTRESULTDIR/${host}.auth.log
+       done
 
 
-    ##########################################################################
-    # copy default host config back if necessary
-    #
+       ##########################################################################
+       # get a copy of /var/log/daemon.log
+       #
 
-    $DIR/scripts/restore-defaults $testname
+       for host in $IPSECHOSTS
+       do
+           eval HOSTLOGIN=root@\$ipv4_${host}
+           ssh $SSHCONF $HOSTLOGIN "grep -s -E 'charon|last message repeated|imcv' \
+               /var/log/daemon.log" >> $TESTRESULTDIR/${host}.daemon.log
+       done
 
 
-    ##########################################################################
-    # write test status to html file
-    #
+       ##########################################################################
+       # stop tcpdump if necessary
+       #
 
-    cecho "$STATUS"
-    if [ $STATUS = "passed" ]
-    then
-        COLOR="green"
-    else
-        COLOR="red"
-    fi
+       for host in $TCPDUMPHOSTS
+       do
+           if [ "`eval echo \\\$TDUP_${host}`" = "true" ]
+           then
+                       stop_tcpdump $host
+           fi
+           eval HOSTLOGIN=root@\$ipv4_${host}
+               scp $SSHCONF $HOSTLOGIN:/tmp/tcpdump.log \
+                       $TESTRESULTDIR/${host}.tcpdump.log > /dev/null 2>&1
+       done
+
+       ##########################################################################
+       # remove database directory if needed
+       #
+
+       for host in $DBHOSTS
+       do
+               eval HOSTLOGIN=root@\$ipv4_${host}
+           ssh $SSHCONF $HOSTLOGIN "umount $DBDIR; rm -r $DBDIR" > /dev/null 2>&1
+       done
+
+       ##########################################################################
+       # copy default host config back if necessary
+       #
+
+       $DIR/scripts/restore-defaults $testname
+
+
+       ##########################################################################
+       # set counters
+       #
+
+       if [ $STATUS = "failed" ]
+       then
+           let "failed_cnt += 1"
+       else
+           let "passed_cnt += 1"
+       fi
+
+
+       ##########################################################################
+       # write test status to html file
+       #
+       testend=$(date +%s)
+       let "testend -= teststart"
+       let "timetotal += testend"
+
+       if [ $STATUS = "passed" ]
+       then
+               COLOR="green"
+               log_status 0
+       else
+               COLOR="red"
+               log_status 1
+       fi
 
-    cat >> $TESTRESULTSHTML << @EOF
+       cat >> $TESTRESULTSHTML << @EOF
   <tr>
     <td>$testnumber</td>
-    <td><a href="$testname/">$testname</a></td>
+    <td><a href="$testname/index.html">$testname</a></td>
+    <td align="right">$testend</td>
     <td><a href="$testname/console.log"><font color="$COLOR">$STATUS</font></a></td>
   </tr>
 @EOF
+       cat >> $SUBTESTSINDEX << @EOF
+  <tr>
+    <td>$testnumber</td>
+    <td><a href="$name/index.html">$name</a></td>
+    <td><a href="$name/console.log"><font color="$COLOR">$STATUS</font></a></td>
+    <td>&nbsp;</td>
+  </tr>
+@EOF
+
+
+       ##########################################################################
+       # remove any charon.pid files that still may exist
+       #
+
+       for host in $IPSECHOSTS
+       do
+           eval HOSTLOGIN=root@\$ipv4_${host}
+           ssh $SSHCONF $HOSTLOGIN 'if [ -f /var/run/charon.pid ]; then rm /var/run/charon.pid; echo "    removed charon.pid on `hostname`"; fi'
+       done
+
+       if [ -n "$aborted" ]
+       then
+           break 2
+       fi
+
+    done
 
 done
 
@@ -430,32 +946,60 @@ done
 #
 
 cat >> $TESTRESULTSHTML << @EOF
+    <tr>
+      <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>
+    </tr>
+    <tr>
+      <td><b>Failed</b></td><td><b><font color="red">$failed_cnt</font></b></td><td>&nbsp;</td><td>&nbsp;</td>
+    </tr>
+    <tr>
+      <td><b>Time [s]</b></td><td><b><font color="blue">$timetotal</font></b></td><td>&nbsp;</td><td>&nbsp;</td>
+    </tr>
   </table>
-  <p>
-  <b>Passed: &nbsp; $passed_cnt</b><br>
-  <b>Failed: &nbsp; $failed_cnt</b><br>
-  <p>
 </body>
 </html>
 @EOF
 
-cecho ""
-cecho "Passed:   $passed_cnt"
-cecho "Failed:   $failed_cnt"
-cecho ""
+if [ $subdir_cnt != 0 ]
+then
+cat >> $INDEX << @EOF
+      <td align="right">$subdir_cnt</td>
+      <td>&nbsp;</td>
+    </tr>
+@EOF
+fi
 
+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 align="right"><b>$all_cnt</b></td>
+      <td>&nbsp;</td>
+    </tr>
+    <tr>
+      <td><b>Failed</b></td>
+      <td>&nbsp;</td>
+      <td align="right"><b><font color="red">$failed_cnt</font></b></td>
+      <td>&nbsp;</td>
+    </tr>
+  </table>
+</body>
+</html>
+@EOF
 
-##############################################################################
-# copy the test results to the apache server
-#
+echo
+echo_ok     "Passed : $passed_cnt"
+echo_failed "Failed : $failed_cnt"
 
-HTDOCS="/var/www/localhost/htdocs"
+echo
+echo "The results are available in $TODAYDIR"
+echo "or via the link http://$ipv4_winnetou/testresults/$TESTDATE"
 
-cecho-n "Copying test results to winnetou.."
-ssh root@${ip_winnetou} mkdir -p $HTDOCS/testresults > /dev/null 2>&1
-scp -r $TODAYDIR root@${ip_winnetou}:$HTDOCS/testresults > /dev/null 2>&1
-ssh root@${ip_winnetou} ln -s $HTDOCS/images $HTDOCS/testresults/$TESTDATE/images > /dev/null 2>&1
-cecho "done"
-cecho ""
-cecho "The results are available in $TODAYDIR"
-cecho "or via the link http://$ip_winnetou/testresults/$TESTDATE"
+ENDDATE=`date +%Y%m%d-%H%M-%S`
+echo
+echo "Finished : $ENDDATE"