]>
git.ipfire.org Git - thirdparty/strongswan.git/blob - testing/do-tests
2 # Automatically execute the strongSwan test cases
4 # Copyright (C) 2004 Eric Marchionni, Patrik Rayo
5 # Zuercher Hochschule Winterthur
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 2 of the License, or (at your
10 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 DIR
=$
(dirname `readlink -f $0`)
19 .
$DIR/scripts
/function.sh
20 SSHCONF
="-F $DIR/ssh_config"
22 [ -d $DIR/hosts
] || die
"Directory 'hosts' not found"
23 [ -d $DIR/tests
] || die
"Directory 'tests' not found"
25 die
"Directory '$BUILDDIR' does not exist, please run make-testing first"
26 running_any
$STRONGSWANHOSTS || die
"Please start test environment before running $0"
28 ln -sfT $DIR $TESTDIR/testing
30 ##############################################################################
31 # take care of new path and file variables
34 [ -d $TESTRESULTSDIR ] || mkdir
$TESTRESULTSDIR
36 TESTDATE
=`date +%Y%m%d-%H%M-%S`
38 TODAYDIR
=$TESTRESULTSDIR/$TESTDATE
40 TESTRESULTSHTML
=$TODAYDIR/all.html
41 INDEX
=$TODAYDIR/index.html
42 DEFAULTTESTSDIR
=$TESTDIR/testing
/tests
44 SOURCEIP_ROUTING_TABLE
=220
50 ##############################################################################
51 # copy default tests to $BUILDDIR
54 TESTSDIR
=$BUILDDIR/tests
55 [ -d $TESTSDIR ] || mkdir
$TESTSDIR
57 ##############################################################################
58 # assign IP for each host to hostname
61 for host in $STRONGSWANHOSTS
63 eval ipv4_
${host}="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print
$1 }'`"
64 eval ipv6_${host}="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' |
awk '{ print $1 }'`"
68 eval ipv4_moon1="`echo $HOSTNAMEIPV4 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
69 eval ipv6_moon1="`echo $HOSTNAMEIPV6 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
72 eval ipv4_sun1="`echo $HOSTNAMEIPV4 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
73 eval ipv6_sun1="`echo $HOSTNAMEIPV6 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
76 eval ipv4_alice1="`echo $HOSTNAMEIPV4 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
77 eval ipv6_alice1="`echo $HOSTNAMEIPV6 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
84 eval ipv4_carol1="`echo $HOSTNAMEIPV4 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
85 eval ipv6_carol1="`echo $HOSTNAMEIPV6 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
88 eval ipv4_dave1="`echo $HOSTNAMEIPV4 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
89 eval ipv6_dave1="`echo $HOSTNAMEIPV6 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
97 ##############################################################################
100 for host in $STRONGSWANHOSTS
102 ssh $SSHCONF -N root@`eval echo \\\
$ipv4_$host` >/dev/null 2>&1 &
103 eval ssh_pid_$host="`echo $
!`"
104 do_on_exit kill `eval echo \\\
$ssh_pid_$host`
107 ##############################################################################
108 # determine actual software versions
111 [ -f $SHAREDDIR/.strongswan-version ] && SWANVERSION=`cat $SHAREDDIR/.strongswan-version
`
112 KERNELVERSION=`ssh $SSHCONF root@\
$ipv4_winnetou uname
-r 2>/dev
/null
`
114 # check if tcpdump supports --immediate-mode
115 ssh $SSHCONF root@$ipv4_winnetou tcpdump --immediate-mode -c 1 >/dev/null 2>&1
118 TCPDUMP_IM=--immediate-mode
121 ##############################################################################
122 # create header for the results html file
125 ENVIRONMENT_HEADER=$(cat <<@EOF
126 <table border="0" cellspacing="2" cellpadding="2">
129 <td colspan="3">`uname
-a`</td>
132 <td><b>Guest kernel</b></td>
133 <td colspan="3">$KERNELVERSION</td>
136 <td><b>strongSwan</b></td>
137 <td colspan="3">$SWANVERSION</td>
141 <td colspan="3">$TESTDATE</td>
144 <td width="100"> </td>
145 <td width="300"> </td>
146 <td width=" 80"> </td>
155 <title>strongSwan KVM Tests</title>
158 <h2>strongSwan KVM Tests</h2>
162 cat > $TESTRESULTSHTML <<@EOF
165 <title>strongSwan KVM Tests - All Tests</title>
168 <div><a href="index.html">strongSwan KVM Tests</a> / All Tests</div>
174 <th align="right">Time [s]</th>
179 echo "Guest kernel : $KERNELVERSION"
180 echo "strongSwan : $SWANVERSION"
181 echo "Date : $TESTDATE"
185 ##############################################################################
186 # enter specific test directory
193 # set internal field seperator
194 TESTS="`ls $DEFAULTTESTSDIR`"
199 SUBTESTS="`basename $SUBDIR`"
201 if [ $SUBTESTS = $SUBDIR ]
203 SUBTESTS="`ls $DEFAULTTESTSDIR/$SUBDIR`"
205 SUBDIR="`dirname $SUBDIR`"
208 if [ ! -d $TODAYDIR/$SUBDIR ]
210 mkdir $TODAYDIR/$SUBDIR
211 if [ $testnumber == 0 ]
213 FIRST="<b>Category</b>"
217 echo " <tr>" >> $INDEX
218 echo " <td>$FIRST</td>">> $INDEX
219 echo " <td><a href=\"$SUBDIR/index.html\">$SUBDIR</a></td>" >> $INDEX
220 echo " <td align=\"right\">x</td>" >> $INDEX
221 echo " <td> </td>" >> $INDEX
222 echo " </tr>" >> $INDEX
223 SUBTESTSINDEX=$TODAYDIR/$SUBDIR/index.html
224 cat > $SUBTESTSINDEX <<@EOF
227 <title>strongSwan $SUBDIR Tests</title>
230 <div><a href="../index.html">strongSwan KVM Tests</a> / $SUBDIR</div>
231 <h2>strongSwan $SUBDIR Tests</h2>
232 <table border="0" cellspacing="2" cellpadding="2">
234 <td><b>Guest kernel</b></td>
235 <td colspan="3">$KERNELVERSION</td>
238 <td><b>strongSwan</b></td>
239 <td colspan="3">$SWANVERSION</td>
243 <td colspan="3">$TESTDATE</td>
246 <td width="100"> </td>
247 <td width="300"> </td>
248 <td width=" 50"> </td>
254 <th colspan="2">Result</th>
259 for name in $SUBTESTS
261 let "testnumber += 1"
262 testname=$SUBDIR/$name
263 log_action " $testnumber $testname:"
265 teststart=$(date +%s)
267 if [ ! -d $DEFAULTTESTSDIR/${testname} ]
269 echo "is missing..skipped"
273 [ -f $DEFAULTTESTSDIR/${testname}/description.txt ] || die "!! File 'description.txt' is missing"
274 [ -f $DEFAULTTESTSDIR/${testname}/test.conf ] || die "!! File 'test.conf' is missing"
275 [ -f $DEFAULTTESTSDIR/${testname}/pretest.dat ] || die "!! File 'pretest.dat' is missing"
276 [ -f $DEFAULTTESTSDIR/${testname}/posttest.dat ] || die "!! File 'posttest.dat' is missing"
277 [ -f $DEFAULTTESTSDIR/${testname}/evaltest.dat ] || die "!! File 'evaltest.dat' is missing"
279 TESTRESULTDIR=$TODAYDIR/$testname
280 mkdir -p $TESTRESULTDIR
281 CONSOLE_LOG=$TESTRESULTDIR/console.log
284 TESTDIR=$TESTSDIR/${testname}
287 cp -rfp $DEFAULTTESTSDIR/${testname}/* $TESTDIR
290 ##############################################################################
291 # replace IP wildcards with actual IPv4 and IPv6 addresses
294 for host in $STRONGSWANHOSTS
298 searchandreplace PH_IP_MOON1 $ipv4_moon1 $TESTDIR
299 searchandreplace PH_IP_MOON $ipv4_moon $TESTDIR
300 searchandreplace PH_IP6_MOON1 $ipv6_moon1 $TESTDIR
301 searchandreplace PH_IP6_MOON $ipv6_moon $TESTDIR
304 searchandreplace PH_IP_SUN1 $ipv4_sun1 $TESTDIR
305 searchandreplace PH_IP_SUN $ipv4_sun $TESTDIR
306 searchandreplace PH_IP6_SUN1 $ipv6_sun1 $TESTDIR
307 searchandreplace PH_IP6_SUN $ipv6_sun $TESTDIR
310 searchandreplace PH_IP_ALICE1 $ipv4_alice1 $TESTDIR
311 searchandreplace PH_IP_ALICE $ipv4_alice $TESTDIR
312 searchandreplace PH_IP6_ALICE1 $ipv6_alice1 $TESTDIR
313 searchandreplace PH_IP6_ALICE $ipv6_alice $TESTDIR
316 searchandreplace PH_IP_VENUS $ipv4_venus $TESTDIR
317 searchandreplace PH_IP6_VENUS $ipv6_venus $TESTDIR
320 searchandreplace PH_IP_BOB $ipv4_bob $TESTDIR
321 searchandreplace PH_IPV6_BOB $ipv6_bob $TESTDIR
324 searchandreplace PH_IP_CAROL1 $ipv4_carol1 $TESTDIR
325 searchandreplace PH_IP_CAROL $ipv4_carol $TESTDIR
326 searchandreplace PH_IP6_CAROL1 $ipv6_carol1 $TESTDIR
327 searchandreplace PH_IP6_CAROL $ipv6_carol $TESTDIR
330 searchandreplace PH_IP_DAVE1 $ipv4_dave1 $TESTDIR
331 searchandreplace PH_IP_DAVE $ipv4_dave $TESTDIR
332 searchandreplace PH_IP6_DAVE1 $ipv6_dave1 $TESTDIR
333 searchandreplace PH_IP6_DAVE $ipv6_dave $TESTDIR
336 searchandreplace PH_IP_WINNETOU $ipv4_winnetou $TESTDIR
337 searchandreplace PH_IP6_WINNETOU $ipv6_winnetou $TESTDIR
343 ##########################################################################
344 # copy test specific configurations to uml hosts and clear auth.log files
349 $DIR/scripts/load-testconfig $testname
354 source $TESTDIR/test.conf
357 ##########################################################################
358 # run tcpdump in the background
361 if [ "$TCPDUMPHOSTS" != "" ]
363 echo -e "TCPDUMP\n" >> $CONSOLE_LOG 2>&1
365 for host_iface in $TCPDUMPHOSTS
367 host=`echo $host_iface |
awk -F ":" '{print $1}'`
368 iface=`echo $host_iface |
awk -F ":" '{if ($2 != "") { print $2 } else { printf("eth0") }}'`
369 tcpdump_cmd="tcpdump -l $TCPDUMP_IM -i $iface not port ssh and not port domain >/tmp/tcpdump.log 2>/tmp/tcpdump.err.log &"
370 echo "${host}# $tcpdump_cmd" >> $CONSOLE_LOG
371 ssh $SSHCONF root@`eval echo \\\
$ipv4_$host '$tcpdump_cmd'`
372 eval TDUP_${host}="true"
376 ##########################################################################
377 # create database directory in RAM
382 eval HOSTLOGIN=root@\$ipv4_${host}
383 ssh $SSHCONF $HOSTLOGIN "mkdir -p $DBDIR; mount -t ramfs -o size=5m ramfs $DBDIR" >/dev/null 2>&1
384 ssh $SSHCONF $HOSTLOGIN "chgrp www-data $DBDIR; chmod g+w $DBDIR" >/dev/null 2>&1
387 ##########################################################################
388 # flush conntrack table on all hosts
391 for host in $STRONGSWANHOSTS
393 ssh $SSHCONF root@`eval echo \\\
$ipv4_$host` 'conntrack -F' >/dev/null 2>&1
396 ##########################################################################
397 # flush IPsec state on all hosts
400 for host in $STRONGSWANHOSTS
402 ssh $SSHCONF root@`eval echo \\\
$ipv4_$host` 'ip xfrm state flush; ip xfrm policy flush' >/dev/null 2>&1
405 ##########################################################################
406 # execute pre-test commands
410 echo -e "\nPRE-TEST\n" >> $CONSOLE_LOG 2>&1
415 printf("echo \"%s# %s\"; ", $1, $2)
416 printf("ssh \044SSHCONF root@\044ipv4_%s \"%s\"; ", $1, $2)
419 }' $TESTDIR/pretest.dat
` >> $CONSOLE_LOG 2>&1
422 ##########################################################################
426 function stop_tcpdump {
427 # wait for packets to get processed, but don't wait longer than 1s
428 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;\""
429 echo "${1}# killall tcpdump" >> $CONSOLE_LOG
430 eval ssh $SSHCONF root@\$ipv4_${1} "\"killall tcpdump; while true; do killall -q -0 tcpdump || break; sleep 0.01; done;\""
431 eval TDUP_${1}="false"
432 echo "" >> $CONSOLE_LOG
436 ##########################################################################
437 # get and evaluate test results
441 echo -e "\nTEST\n" >> $CONSOLE_LOG 2>&1
452 if (command == "tcpdump")
454 printf("if [ \044TDUP_%s == \"true\" ]; then stop_tcpdump %s; fi; \n", host, host)
455 printf("echo \"%s# cat /tmp/tcpdump.log | grep \047%s\047 [%s]\"; ", host, pattern, hit)
456 printf("ssh \044SSHCONF root@\044ipv4_%s cat /tmp/tcpdump.log | grep \"%s\"; ", host, pattern)
460 printf("echo \"%s# %s | grep \047%s\047 [%s]\"; ", host, command, pattern, hit)
461 printf("ssh \044SSHCONF root@\044ipv4_%s %s | grep \"%s\"; ", host, command, pattern)
463 printf("cmd_exit=\044?; ")
465 printf("if [ \044cmd_exit -eq 0 -a \"%s\" = \"NO\" ] ", hit)
466 printf("|| [ \044cmd_exit -ne 0 -a \"%s\" = \"YES\" ] ", hit)
467 printf("; then STATUS=\"failed\"; fi; \n")
469 }' $TESTDIR/evaltest.dat
` >> $CONSOLE_LOG 2>&1
472 ##########################################################################
476 if [ $STATUS = "failed" ]
478 let "failed_cnt += 1"
480 let "passed_cnt += 1"
484 ##########################################################################
485 # log statusall and listall output
486 # get copies of ipsec.conf, ipsec.secrets
487 # create index.html for the given test case
489 cat > $TESTRESULTDIR/index.html <<@EOF
492 <title>Test $testname</title>
495 <table border="0" cellpadding="0" cellspacing="0" width="600">
497 <div><a href="../../index.html">strongSwan KVM Tests</a> / <a href="../index.html">$SUBDIR</a> / $name</div>
498 <h2>Test $testname</h2>
502 cat $TESTDIR/description.txt >> $TESTRESULTDIR/index.html
504 cat >> $TESTRESULTDIR/index.html <<@EOF
506 <li><a href="console.log">console.log</a></li>
508 <img src="../../images/$DIAGRAM" alt="$VIRTHOSTS">
513 IPROUTE_CMD="ip -6 route list table $SOURCEIP_ROUTING_TABLE"
514 IPROUTE_DSP=$IPROUTE_CMD
515 IPTABLES_CMD="ip6tables -v -n -L"
516 IPTABLES_DSP="ip6tables -L"
518 IPROUTE_CMD="ip route list table $SOURCEIP_ROUTING_TABLE"
519 IPROUTE_DSP=$IPROUTE_CMD
520 IPTABLES_CMD="iptables -v -n -L"
521 IPTABLES_DSP="iptables -L"
524 if [ $name = "net2net-ip4-in-ip6-ikev2" -o $name = "net2net-ip6-in-ip4-ikev2" ]
526 IPROUTE_CMD="ip route list table $SOURCEIP_ROUTING_TABLE; echo; ip -6 route list table $SOURCEIP_ROUTING_TABLE"
527 IPROUTE_DSP="ip (-6) route list table $SOURCEIP_ROUTING_TABLE"
528 IPTABLES_CMD="iptables -v -n -L ; echo ; ip6tables -v -n -L"
529 IPTABLES_DSP="iptables -L ; ip6tables -L"
534 eval HOSTLOGIN=root@\$ipv4_${host}
536 scp $SSHCONF $HOSTLOGIN:/etc/db.d/ipsec.sql \
537 $TESTRESULTDIR/${host}.ipsec.sql > /dev/null 2>&1
540 for host in $IPSECHOSTS
542 eval HOSTLOGIN=root@\$ipv4_${host}
544 scp $SSHCONF $HOSTLOGIN:/etc/strongswan.conf \
545 $TESTRESULTDIR/${host}.strongswan.conf > /dev/null 2>&1
548 scp $SSHCONF $HOSTLOGIN:/etc/swanctl/swanctl.conf \
549 $TESTRESULTDIR/${host}.swanctl.conf > /dev/null 2>&1
551 for subsys in conns algs certs pools authorities sas pols
553 ssh $SSHCONF $HOSTLOGIN swanctl --list-$subsys \
554 > $TESTRESULTDIR/${host}.swanctl.$subsys 2>/dev/null
557 ssh $SSHCONF $HOSTLOGIN swanctl --stats \
558 > $TESTRESULTDIR/${host}.swanctl.stats 2>/dev/null
560 echo "" >> $TESTRESULTDIR/${host}.swanctl.sas
561 cat $TESTRESULTDIR/${host}.swanctl.pols >> \
562 $TESTRESULTDIR/${host}.swanctl.sas
563 cat $TESTRESULTDIR/${host}.swanctl.algs >> \
564 $TESTRESULTDIR/${host}.swanctl.stats
566 for file in ipsec.conf ipsec.secrets
568 scp $SSHCONF $HOSTLOGIN:/etc/$file \
569 $TESTRESULTDIR/${host}.$file > /dev/null 2>&1
572 for command in statusall listall
574 ssh $SSHCONF $HOSTLOGIN ipsec $command \
575 > $TESTRESULTDIR/${host}.$command 2>/dev/null
579 if (! [ -f $TESTRESULTDIR/${host}.ipsec.sql ] ) then
580 scp $SSHCONF $HOSTLOGIN:/etc/ipsec.d/ipsec.sql \
581 $TESTRESULTDIR/${host}.ipsec.sql > /dev/null 2>&1
584 ssh $SSHCONF $HOSTLOGIN ip -s xfrm policy \
585 > $TESTRESULTDIR/${host}.ip.policy 2>/dev/null
586 ssh $SSHCONF $HOSTLOGIN ip -s xfrm state \
587 > $TESTRESULTDIR/${host}.ip.state 2>/dev/null
588 ssh $SSHCONF $HOSTLOGIN $IPROUTE_CMD \
589 > $TESTRESULTDIR/${host}.ip.route 2>/dev/null
590 ssh $SSHCONF $HOSTLOGIN $IPTABLES_CMD \
591 > $TESTRESULTDIR/${host}.iptables 2>/dev/null
592 chmod a+r $TESTRESULTDIR/*
596 cat >> $TESTRESULTDIR/index.html <<@EOF
598 <table border="0" cellspacing="0" width="600">
602 <li><a href="$host.swanctl.conf">swanctl.conf</a></li>
603 <li><a href="$host.swanctl.conns">swanctl --list-conns</a></li>
604 <li><a href="$host.swanctl.certs">swanctl --list-certs</a></li>
605 <li><a href="$host.strongswan.conf">strongswan.conf</a></li>
606 <li><a href="$host.ipsec.sql">ipsec.sql</a></li>
611 <li><a href="$host.swanctl.sas">swanctl --list-sas|--list-pols</a></li>
612 <li><a href="$host.swanctl.pools">swanctl --list-pools</a></li>
613 <li><a href="$host.swanctl.authorities">swanctl --list-authorities</a></li>
614 <li><a href="$host.swanctl.stats">swanctl --stats|--list-algs</a></li>
615 <li><a href="$host.daemon.log">daemon.log</a></li>
620 <li><a href="$host.ip.policy">ip -s xfrm policy</a></li>
621 <li><a href="$host.ip.state">ip -s xfrm state</a></li>
622 <li><a href="$host.ip.route">$IPROUTE_DSP</a></li>
623 <li><a href="$host.iptables">$IPTABLES_DSP</a></li>
624 <li><a href="$host.auth.log">auth.log</a></li>
633 cat >> $TESTRESULTDIR/index.html <<@EOF
635 <table border="0" cellspacing="0" width="600">
639 <li><a href="$host.ipsec.conf">ipsec.conf</a></li>
640 <li><a href="$host.ipsec.secrets">ipsec.secrets</a></li>
641 <li><a href="$host.ipsec.sql">ipsec.sql</a></li>
642 <li><a href="$host.strongswan.conf">strongswan.conf</a></li>
647 <li><a href="$host.statusall">ipsec statusall</a></li>
648 <li><a href="$host.listall">ipsec listall</a></li>
649 <li><a href="$host.auth.log">auth.log</a></li>
650 <li><a href="$host.daemon.log">daemon.log</a></li>
655 <li><a href="$host.ip.policy">ip -s xfrm policy</a></li>
656 <li><a href="$host.ip.state">ip -s xfrm state</a></li>
657 <li><a href="$host.ip.route">$IPROUTE_DSP</a></li>
658 <li><a href="$host.iptables">$IPTABLES_DSP</a></li>
667 for host in $RADIUSHOSTS
669 eval HOSTLOGIN=root@\$ipv4_${host}
671 for file in clients.conf eap.conf radiusd.conf proxy.conf users
673 scp $SSHCONF $HOSTLOGIN:/etc/freeradius/$file \
674 $TESTRESULTDIR/${host}.$file > /dev/null 2>&1
677 scp $SSHCONF $HOSTLOGIN:/etc/strongswan.conf \
678 $TESTRESULTDIR/${host}.strongswan.conf > /dev/null 2>&1
680 scp $SSHCONF $HOSTLOGIN:/var/log/freeradius/radius.log \
681 $TESTRESULTDIR/${host}.radius.log > /dev/null 2>&1
683 ssh $SSHCONF $HOSTLOGIN grep imcv /var/log/daemon.log \
684 >> $TESTRESULTDIR/${host}.daemon.log 2>/dev/null
686 chmod a+r $TESTRESULTDIR/*
687 cat >> $TESTRESULTDIR/index.html <<@EOF
689 <table border="0" cellspacing="0" width="600">
693 <li><a href="$host.clients.conf">clients.conf</a></li>
694 <li><a href="$host.radiusd.conf">radiusd.conf</a></li>
695 <li><a href="$host.strongswan.conf">strongswan.conf</a></li>
700 <li><a href="$host.eap.conf">eap.conf</a></li>
701 <li><a href="$host.radius.log">radius.log</a></li>
702 <li><a href="$host.daemon.log">daemon.log</a></li>
707 <li><a href="$host.proxy.conf">proxy.conf</a></li>
708 <li><a href="$host.users">users</a></li>
717 cat >> $TESTRESULTDIR/index.html <<@EOF
722 for host in $TCPDUMPHOSTS
724 cat >> $TESTRESULTDIR/index.html <<@EOF
725 <li><a href="$host.tcpdump.log">$host tcpdump.log</a></li>
729 cat >> $TESTRESULTDIR/index.html <<@EOF
733 cat >> $TESTRESULTDIR/index.html <<@EOF
741 ##########################################################################
742 # execute post-test commands
746 echo -e "\nPOST-TEST\n" >> $CONSOLE_LOG 2>&1
751 printf("echo \"%s# %s\"; ", $1, $2)
752 printf("ssh \044SSHCONF root@\044ipv4_%s \"%s\"; ", $1, $2)
755 }' $TESTDIR/posttest.dat
` >> $CONSOLE_LOG 2>&1
757 ##########################################################################
758 # check that IPsec state was cleaned up properly
761 for host in $IPSECHOSTS
763 eval HOSTLOGIN=root@\$ipv4_${host}
764 IPSECSTATE=`ssh $SSHCONF $HOSTLOGIN 'ip xfrm state'`
765 IPSECPOLICY=`ssh $SSHCONF $HOSTLOGIN 'ip xfrm policy'`
766 if [ -n "$IPSECSTATE" -o -n "$IPSECPOLICY" ]
768 echo -e "\n$host# ip xfrm state [NO]" >> $CONSOLE_LOG
769 echo "$IPSECSTATE" >> $CONSOLE_LOG
770 echo -e "\n$host# ip xfrm policy [NO]" >> $CONSOLE_LOG
771 echo "$IPSECPOLICY" >> $CONSOLE_LOG
776 ##########################################################################
777 # get a copy of /var/log/auth.log
780 for host in $IPSECHOSTS
782 eval HOSTLOGIN=root@\$ipv4_${host}
783 ssh $SSHCONF $HOSTLOGIN "grep -s -E 'charon|last message repeated|imcv|pt-tls-client' \
784 /var/log/auth.log" >> $TESTRESULTDIR/${host}.auth.log
788 ##########################################################################
789 # get a copy of /var/log/daemon.log
792 for host in $IPSECHOSTS
794 eval HOSTLOGIN=root@\$ipv4_${host}
795 ssh $SSHCONF $HOSTLOGIN "grep -s -E 'charon|last message repeated|imcv' \
796 /var/log/daemon.log" >> $TESTRESULTDIR/${host}.daemon.log
800 ##########################################################################
801 # stop tcpdump if necessary
804 for host in $TCPDUMPHOSTS
806 if [ "`eval echo \\\
$TDUP_${host}`" = "true" ]
810 eval HOSTLOGIN=root@\$ipv4_${host}
811 scp $SSHCONF $HOSTLOGIN:/tmp/tcpdump.log \
812 $TESTRESULTDIR/${host}.tcpdump.log > /dev/null 2>&1
815 ##########################################################################
816 # remove database directory if needed
821 eval HOSTLOGIN=root@\$ipv4_${host}
822 ssh $SSHCONF $HOSTLOGIN "umount $DBDIR; rm -r $DBDIR" > /dev/null 2>&1
825 ##########################################################################
826 # copy default host config back if necessary
829 $DIR/scripts/restore-defaults $testname
832 ##########################################################################
833 # write test status to html file
836 let "testend -= teststart"
837 let "timetotal += testend"
839 if [ $STATUS = "passed" ]
848 cat >> $TESTRESULTSHTML << @EOF
851 <td><a href="$testname/index.html">$testname</a></td>
852 <td align="right">$testend</td>
853 <td><a href="$testname/console.log"><font color="$COLOR">$STATUS</font></a></td>
856 cat >> $SUBTESTSINDEX << @EOF
859 <td><a href="$name/index.html">$name</a></td>
860 <td><a href="$name/console.log"><font color="$COLOR">$STATUS</font></a></td>
866 ##########################################################################
867 # remove any charon.pid files that still may exist
870 for host in $IPSECHOSTS
872 eval HOSTLOGIN=root@\$ipv4_${host}
873 ssh $SSHCONF $HOSTLOGIN 'if [ -f /var/run/charon.pid ]; then rm /var/run/charon.pid; echo " removed charon.pid on `hostname
`"; fi'
881 ##############################################################################
882 # finish the results html file
885 cat >> $TESTRESULTSHTML << @EOF
887 <td> </td><td> </td><td> </td><td> </td>
890 <td><b>Passed</b></td><td><b><font color="green">$passed_cnt</font></b></td><td> </td><td> </td>
893 <td><b>Failed</b></td><td><b><font color="red">$failed_cnt</font></b></td><td> </td><td> </td>
896 <td><b>Time [s]</b></td><td><b><font color="blue">$timetotal</font></b></td><td> </td><td> </td>
903 let "all_cnt = $passed_cnt + $failed_cnt"
905 cat >> $INDEX << @EOF
908 <td><a href="all.html"><b>all</b></a></td>
909 <td align="right"><b>$all_cnt</b></td>
913 <td><b>Failed</b></td>
915 <td align="right"><b><font color="red">$failed_cnt</font></b></td>
924 echo_ok "Passed : $passed_cnt"
925 echo_failed "Failed : $failed_cnt"
929 ##############################################################################
930 # copy the test results to the apache server
935 ssh $SSHCONF root@${ipv4_winnetou} mkdir -p $HTDOCS/testresults > /dev/null 2>&1
936 scp $SSHCONF -r $TODAYDIR root@${ipv4_winnetou}:$HTDOCS/testresults > /dev/null 2>&1
938 echo "The results are available in $TODAYDIR"
939 echo "or via the link http://$ipv4_winnetou/testresults/$TESTDATE"
941 ENDDATE=`date +%Y
%m
%d-
%H
%M-
%S
`
943 echo "Finished : $ENDDATE"