]>
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
51 ##############################################################################
52 # parse optional arguments
67 [ "$verbose" == "YES" ] && echo "$(date +%T.%N) ~ "
70 ##############################################################################
71 # copy default tests to $BUILDDIR
74 TESTSDIR
=$BUILDDIR/tests
75 [ -d $TESTSDIR ] || mkdir
$TESTSDIR
77 ##############################################################################
78 # assign IP for each host to hostname
81 for host in $STRONGSWANHOSTS
83 eval ipv4_
${host}="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' | awk '{ print
$1 }'`"
84 eval ipv6_${host}="`echo $HOSTNAMEIPV6 | sed -n -e "s/^.*${host},//gp" | awk -F, '{ print $1 }' |
awk '{ print $1 }'`"
88 eval ipv4_moon1="`echo $HOSTNAMEIPV4 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
89 eval ipv6_moon1="`echo $HOSTNAMEIPV6 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
92 eval ipv4_sun1="`echo $HOSTNAMEIPV4 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
93 eval ipv6_sun1="`echo $HOSTNAMEIPV6 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
96 eval ipv4_alice1="`echo $HOSTNAMEIPV4 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
97 eval ipv6_alice1="`echo $HOSTNAMEIPV6 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
104 eval ipv4_carol1="`echo $HOSTNAMEIPV4 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
105 eval ipv6_carol1="`echo $HOSTNAMEIPV6 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
108 eval ipv4_dave1="`echo $HOSTNAMEIPV4 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
109 eval ipv6_dave1="`echo $HOSTNAMEIPV6 |
sed -n -e "s/^.*${host},//gp" |
awk -F, '{ print $2 }' |
awk '{ print $1 }'`"
117 ##############################################################################
120 for host in $STRONGSWANHOSTS
122 ssh $SSHCONF -N root@`eval echo \\\
$ipv4_$host` >/dev/null 2>&1 &
123 eval ssh_pid_$host="`echo $
!`"
124 do_on_exit kill `eval echo \\\
$ssh_pid_$host`
127 ##############################################################################
128 # determine actual software versions
131 [ -f $SHAREDDIR/.strongswan-version ] && SWANVERSION=`cat $SHAREDDIR/.strongswan-version
`
132 KERNELVERSION=`ssh $SSHCONF root@\
$ipv4_winnetou uname
-r 2>/dev
/null
`
134 # check if tcpdump supports --immediate-mode
135 ssh $SSHCONF root@$ipv4_winnetou tcpdump --immediate-mode -c 1 >/dev/null 2>&1
138 TCPDUMP_IM=--immediate-mode
141 ##############################################################################
142 # create header for the results html file
145 ENVIRONMENT_HEADER=$(cat <<@EOF
146 <table border="0" cellspacing="2" cellpadding="2">
149 <td colspan="3">`uname
-a`</td>
152 <td><b>Guest kernel</b></td>
153 <td colspan="3">$KERNELVERSION</td>
156 <td><b>strongSwan</b></td>
157 <td colspan="3">$SWANVERSION</td>
161 <td colspan="3">$TESTDATE</td>
164 <td width="100"> </td>
165 <td width="300"> </td>
166 <td width=" 80"> </td>
175 <title>strongSwan KVM Tests</title>
178 <h2>strongSwan KVM Tests</h2>
182 cat > $TESTRESULTSHTML <<@EOF
185 <title>strongSwan KVM Tests - All Tests</title>
188 <div><a href="index.html">strongSwan KVM Tests</a> / All Tests</div>
194 <th align="right">Time [s]</th>
199 echo "Guest kernel : $KERNELVERSION"
200 echo "strongSwan : $SWANVERSION"
201 echo "Date : $TESTDATE"
204 ##############################################################################
205 # trap CTRL-C to properly terminate a long run
208 function abort_tests()
210 echo -n "...aborting..." > /dev/tty
215 ##############################################################################
216 # enter specific test directory
220 TESTS=$(printf "%s\n" $* | sort -u)
222 TESTS=$(ls $DEFAULTTESTSDIR)
227 SUBTESTS="`basename $SUBDIR`"
229 if [ $SUBTESTS = $SUBDIR ]
231 SUBTESTS="`ls $DEFAULTTESTSDIR/$SUBDIR`"
233 if [[ $SUBTESTS == *'*'* ]]
235 SUBTESTS="`basename -a $DEFAULTTESTSDIR/$SUBDIR`"
237 SUBDIR="`dirname $SUBDIR`"
240 if [ ! -d $TODAYDIR/$SUBDIR ]
242 mkdir $TODAYDIR/$SUBDIR
243 if [ $testnumber == 0 ]
245 FIRST="<b>Category</b>"
250 if [ $subdir_cnt != 0 ]
252 echo " <td align=\"right\">$subdir_cnt</td>" >> $INDEX
253 echo " <td> </td>" >> $INDEX
254 echo " </tr>" >> $INDEX
257 echo " <tr>" >> $INDEX
258 echo " <td>$FIRST</td>">> $INDEX
259 echo " <td><a href=\"$SUBDIR/index.html\">$SUBDIR</a></td>" >> $INDEX
261 SUBTESTSINDEX=$TODAYDIR/$SUBDIR/index.html
262 cat > $SUBTESTSINDEX <<@EOF
265 <title>strongSwan $SUBDIR Tests</title>
268 <div><a href="../index.html">strongSwan KVM Tests</a> / $SUBDIR</div>
269 <h2>strongSwan $SUBDIR Tests</h2>
270 <table border="0" cellspacing="2" cellpadding="2">
272 <td><b>Guest kernel</b></td>
273 <td colspan="3">$KERNELVERSION</td>
276 <td><b>strongSwan</b></td>
277 <td colspan="3">$SWANVERSION</td>
281 <td colspan="3">$TESTDATE</td>
284 <td width="100"> </td>
285 <td width="300"> </td>
286 <td width=" 50"> </td>
292 <th colspan="2">Result</th>
297 for name in $SUBTESTS
299 let "testnumber += 1"
300 let "subdir_cnt += 1"
301 testname=$SUBDIR/$name
302 log_action " $testnumber $testname:"
304 teststart=$(date +%s)
306 if [ ! -d $DEFAULTTESTSDIR/${testname} ]
308 echo "is missing..skipped"
312 [ -f $DEFAULTTESTSDIR/${testname}/description.txt ] || die "!! File 'description.txt' is missing"
313 [ -f $DEFAULTTESTSDIR/${testname}/test.conf ] || die "!! File 'test.conf' is missing"
314 [ -f $DEFAULTTESTSDIR/${testname}/pretest.dat ] || die "!! File 'pretest.dat' is missing"
315 [ -f $DEFAULTTESTSDIR/${testname}/posttest.dat ] || die "!! File 'posttest.dat' is missing"
316 [ -f $DEFAULTTESTSDIR/${testname}/evaltest.dat ] || die "!! File 'evaltest.dat' is missing"
318 TESTRESULTDIR=$TODAYDIR/$testname
319 mkdir -p $TESTRESULTDIR
320 CONSOLE_LOG=$TESTRESULTDIR/console.log
323 TESTDIR=$TESTSDIR/${testname}
325 ##########################################################################
326 # copy test specific configurations to hosts and clear log files
331 $DIR/scripts/load-testconfig $testname
336 source $TESTDIR/test.conf
339 ##########################################################################
340 # run tcpdump in the background
343 if [ "$TCPDUMPHOSTS" != "" ]
345 echo -e "TCPDUMP\n" >> $CONSOLE_LOG 2>&1
347 for host_iface in $TCPDUMPHOSTS
349 host=`echo $host_iface |
awk -F ":" '{print $1}'`
350 iface=`echo $host_iface |
awk -F ":" '{if ($2 != "") { print $2 } else { printf("eth0") }}'`
351 tcpdump_cmd="tcpdump -l $TCPDUMP_IM -i $iface not port ssh and not port domain >/tmp/tcpdump.log 2>/tmp/tcpdump.err.log &"
352 echo "$(print_time)${host}# $tcpdump_cmd" >> $CONSOLE_LOG
353 ssh $SSHCONF root@`eval echo \\\
$ipv4_$host '$tcpdump_cmd'`
354 eval TDUP_${host}="true"
358 ##########################################################################
359 # create database directory in RAM
364 eval HOSTLOGIN=root@\$ipv4_${host}
365 ssh $SSHCONF $HOSTLOGIN "mkdir -p $DBDIR; mount -t ramfs -o size=5m ramfs $DBDIR" >/dev/null 2>&1
366 ssh $SSHCONF $HOSTLOGIN "chgrp www-data $DBDIR; chmod g+w $DBDIR" >/dev/null 2>&1
369 ##########################################################################
370 # flush conntrack table on all hosts
373 for host in $STRONGSWANHOSTS
375 ssh $SSHCONF root@`eval echo \\\
$ipv4_$host` 'conntrack -F' >/dev/null 2>&1
378 ##########################################################################
379 # remove leak detective log on all hosts
382 export LEAK_DETECTIVE_LOG=/var/log/leak-detective.log
383 for host in $STRONGSWANHOSTS
385 ssh $SSHCONF root@`eval echo \\\
$ipv4_$host` 'rm -f $LEAK_DETECTIVE_LOG' >/dev/null 2>&1
388 ##########################################################################
389 # flush IPsec state on all hosts
392 for host in $STRONGSWANHOSTS
394 ssh $SSHCONF root@`eval echo \\\
$ipv4_$host` 'ip xfrm state flush; ip xfrm policy flush' >/dev/null 2>&1
397 ##########################################################################
398 # execute pre-test commands
402 echo -e "\nPRE-TEST\n" >> $CONSOLE_LOG 2>&1
405 if ($1 !~ /^#.*/ && $2 != "")
407 printf("echo \"$(print_time)%s# %s\"; ", $1, $2)
408 printf("ssh \044SSHCONF root@\044ipv4_%s \"%s\"; ", $1, $2)
411 }' $TESTDIR/pretest.dat
` >> $CONSOLE_LOG 2>&1
414 ##########################################################################
418 function stop_tcpdump {
419 # wait for packets to get processed, but don't wait longer than 1s
420 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;\""
421 echo "$(print_time)${1}# killall tcpdump" >> $CONSOLE_LOG
422 eval ssh $SSHCONF root@\$ipv4_${1} "\"killall tcpdump; while true; do killall -q -0 tcpdump || break; sleep 0.01; done;\""
423 eval TDUP_${1}="false"
424 echo "" >> $CONSOLE_LOG
428 ##########################################################################
429 # get and evaluate test results
433 echo -e "\nTEST\n" >> $CONSOLE_LOG 2>&1
442 if (host ~ /^#.*/ || command == "")
446 printf("cmd_err=\044(tempfile -p test -s err); ")
447 if (command == "tcpdump")
449 printf("if [ \044TDUP_%s == \"true\" ]; then stop_tcpdump %s; fi; \n", host, host)
450 printf("cmd_out=\044(ssh \044SSHCONF root@\044ipv4_%s cat /tmp/tcpdump.log | grep \"%s\"); ", host, pattern)
454 printf("cmd_out=\044(ssh \044SSHCONF root@\044ipv4_%s %s 2>\044cmd_err | grep \"%s\"); ", host, command, pattern)
456 printf("cmd_exit=\044?; ")
457 printf("cmd_fail=0; ")
458 if (hit ~ /^[0-9]+$/)
460 printf("if [ \044(echo \"\044cmd_out\" | wc -l) -ne %d ] ", hit)
464 printf("if [ \044cmd_exit -eq 0 -a \"%s\" = \"NO\" ] ", hit)
465 printf("|| [ \044cmd_exit -ne 0 -a \"%s\" = \"YES\" ] ", hit)
467 printf("; then STATUS=\"failed\"; cmd_fail=1; fi; \n")
469 printf("if [ \044cmd_fail -ne 0 ]; then echo \"~~~~~~~ FAIL ~~~~~~~\"; fi; \n")
470 if (command == "tcpdump")
472 printf("echo \"$(print_time)%s# cat /tmp/tcpdump.log | grep \047%s\047 [%s]\"; ", host, pattern, hit)
476 printf("echo \"$(print_time)%s# %s | grep \047%s\047 [%s]\"; ", host, command, pattern, hit)
478 printf("if [ -n \"\044cmd_out\" ]; then echo \"\044cmd_out\"; fi; \n")
479 printf("cat \044cmd_err; rm -f -- \044cmd_err; \n")
480 printf("if [ \044cmd_fail -ne 0 ]; then echo \"~~~~~~~~~~~~~~~~~~~~\"; fi; \n")
482 }' $TESTDIR/evaltest.dat
` >> $CONSOLE_LOG 2>&1
485 ##########################################################################
486 # log statusall and listall output
487 # get copies of ipsec.conf, ipsec.secrets
488 # create index.html for the given test case
490 cat > $TESTRESULTDIR/index.html <<@EOF
493 <title>Test $testname</title>
496 <table border="0" cellpadding="0" cellspacing="0" width="600">
498 <div><a href="../../index.html">strongSwan KVM Tests</a> / <a href="../index.html">$SUBDIR</a> / $name</div>
499 <h2>Test $testname</h2>
503 cat $TESTDIR/description.txt >> $TESTRESULTDIR/index.html
505 cat >> $TESTRESULTDIR/index.html <<@EOF
507 <li><a href="console.log">console.log</a></li>
509 <img src="../../images/$DIAGRAM" alt="$VIRTHOSTS">
512 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"
513 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"
517 IPROUTE_CMD="ip -6 route list table $SOURCEIP_ROUTING_TABLE"
518 IPROUTE_DSP=$IPROUTE_CMD
519 IPTABLES_CMD="$IPTABLES_CMD_V6"
520 IPTABLES_DSP="ip6tables -L"
521 IPTABLES_SAVE_CMD="ip6tables-save"
522 IPTABLES_SAVE_DSP="ip6tables-save"
524 IPROUTE_CMD="ip route list table $SOURCEIP_ROUTING_TABLE"
525 IPROUTE_DSP=$IPROUTE_CMD
526 IPTABLES_CMD="$IPTABLES_CMD_V4"
527 IPTABLES_DSP="iptables -L"
528 IPTABLES_SAVE_CMD="iptables-save"
529 IPTABLES_SAVE_DSP="iptables-save"
532 if [ $name = "net2net-ip4-in-ip6-ikev2" -o $name = "net2net-ip6-in-ip4-ikev2" ]
534 IPROUTE_CMD="ip route list table $SOURCEIP_ROUTING_TABLE; echo; ip -6 route list table $SOURCEIP_ROUTING_TABLE"
535 IPROUTE_DSP="ip (-6) route list table $SOURCEIP_ROUTING_TABLE"
536 IPTABLES_CMD="$IPTABLES_CMD_V4; echo; $IPTABLES_CMD_V6"
537 IPTABLES_DSP="iptables -L ; ip6tables -L"
538 IPTABLES_SAVE_CMD="iptables-save; echo; ip6tables-save"
539 IPTABLES_SAVE_DSP="iptables-save ; ip6tables-save"
544 eval HOSTLOGIN=root@\$ipv4_${host}
546 scp $SSHCONF $HOSTLOGIN:/etc/db.d/ipsec.sql \
547 $TESTRESULTDIR/${host}.ipsec.sql > /dev/null 2>&1
550 for host in $IPSECHOSTS
552 eval HOSTLOGIN=root@\$ipv4_${host}
554 scp $SSHCONF $HOSTLOGIN:/etc/strongswan.conf \
555 $TESTRESULTDIR/${host}.strongswan.conf > /dev/null 2>&1
558 scp $SSHCONF $HOSTLOGIN:/etc/swanctl/swanctl.conf \
559 $TESTRESULTDIR/${host}.swanctl.conf > /dev/null 2>&1
561 for subsys in conns algs certs pools authorities sas pols
563 ssh $SSHCONF $HOSTLOGIN swanctl --list-$subsys \
564 > $TESTRESULTDIR/${host}.swanctl.$subsys 2>/dev/null
567 ssh $SSHCONF $HOSTLOGIN swanctl --stats \
568 > $TESTRESULTDIR/${host}.swanctl.stats 2>/dev/null
570 echo "" >> $TESTRESULTDIR/${host}.swanctl.sas
571 cat $TESTRESULTDIR/${host}.swanctl.pols >> \
572 $TESTRESULTDIR/${host}.swanctl.sas
573 cat $TESTRESULTDIR/${host}.swanctl.algs >> \
574 $TESTRESULTDIR/${host}.swanctl.stats
576 for file in ipsec.conf ipsec.secrets
578 scp $SSHCONF $HOSTLOGIN:/etc/$file \
579 $TESTRESULTDIR/${host}.$file > /dev/null 2>&1
582 for command in statusall listall
584 ssh $SSHCONF $HOSTLOGIN ipsec $command \
585 > $TESTRESULTDIR/${host}.$command 2>/dev/null
589 if (! [ -f $TESTRESULTDIR/${host}.ipsec.sql ] ) then
590 scp $SSHCONF $HOSTLOGIN:/etc/ipsec.d/ipsec.sql \
591 $TESTRESULTDIR/${host}.ipsec.sql > /dev/null 2>&1
594 ssh $SSHCONF $HOSTLOGIN ip -s xfrm policy \
595 > $TESTRESULTDIR/${host}.ip.policy 2>/dev/null
596 ssh $SSHCONF $HOSTLOGIN ip -s xfrm state \
597 > $TESTRESULTDIR/${host}.ip.state 2>/dev/null
598 ssh $SSHCONF $HOSTLOGIN $IPROUTE_CMD \
599 > $TESTRESULTDIR/${host}.ip.route 2>/dev/null
600 ssh $SSHCONF $HOSTLOGIN $IPTABLES_CMD \
601 > $TESTRESULTDIR/${host}.iptables 2>/dev/null
602 ssh $SSHCONF $HOSTLOGIN $IPTABLES_SAVE_CMD \
603 > $TESTRESULTDIR/${host}.iptables-save 2>/dev/null
604 chmod a+r $TESTRESULTDIR/*
608 cat >> $TESTRESULTDIR/index.html <<@EOF
610 <table border="0" cellspacing="0" width="600">
614 <li><a href="$host.swanctl.conf">swanctl.conf</a></li>
615 <li><a href="$host.swanctl.conns">swanctl --list-conns</a></li>
616 <li><a href="$host.swanctl.certs">swanctl --list-certs</a></li>
617 <li><a href="$host.strongswan.conf">strongswan.conf</a></li>
618 <li><a href="$host.ipsec.sql">ipsec.sql</a></li>
623 <li><a href="$host.swanctl.sas">swanctl --list-sas|--list-pols</a></li>
624 <li><a href="$host.swanctl.pools">swanctl --list-pools</a></li>
625 <li><a href="$host.swanctl.authorities">swanctl --list-authorities</a></li>
626 <li><a href="$host.swanctl.stats">swanctl --stats|--list-algs</a></li>
627 <li><a href="$host.auth.log">auth.log</a></li>
628 <li><a href="$host.daemon.log">daemon.log</a></li>
633 <li><a href="$host.ip.policy">ip -s xfrm policy</a></li>
634 <li><a href="$host.ip.state">ip -s xfrm state</a></li>
635 <li><a href="$host.ip.route">$IPROUTE_DSP</a></li>
636 <li><a href="$host.iptables">$IPTABLES_DSP</a></li>
637 <li><a href="$host.iptables-save">$IPTABLES_SAVE_DSP</a></li>
646 cat >> $TESTRESULTDIR/index.html <<@EOF
648 <table border="0" cellspacing="0" width="600">
652 <li><a href="$host.ipsec.conf">ipsec.conf</a></li>
653 <li><a href="$host.ipsec.secrets">ipsec.secrets</a></li>
654 <li><a href="$host.ipsec.sql">ipsec.sql</a></li>
655 <li><a href="$host.strongswan.conf">strongswan.conf</a></li>
660 <li><a href="$host.statusall">ipsec statusall</a></li>
661 <li><a href="$host.listall">ipsec listall</a></li>
662 <li><a href="$host.auth.log">auth.log</a></li>
663 <li><a href="$host.daemon.log">daemon.log</a></li>
668 <li><a href="$host.ip.policy">ip -s xfrm policy</a></li>
669 <li><a href="$host.ip.state">ip -s xfrm state</a></li>
670 <li><a href="$host.ip.route">$IPROUTE_DSP</a></li>
671 <li><a href="$host.iptables">$IPTABLES_DSP</a></li>
672 <li><a href="$host.iptables-save">$IPTABLES_SAVE_DSP</a></li>
681 for host in $RADIUSHOSTS
683 eval HOSTLOGIN=root@\$ipv4_${host}
685 for file in clients.conf eap.conf radiusd.conf proxy.conf users
687 scp $SSHCONF $HOSTLOGIN:/etc/freeradius/$file \
688 $TESTRESULTDIR/${host}.$file > /dev/null 2>&1
691 scp $SSHCONF $HOSTLOGIN:/etc/strongswan.conf \
692 $TESTRESULTDIR/${host}.strongswan.conf > /dev/null 2>&1
694 scp $SSHCONF $HOSTLOGIN:/var/log/freeradius/radius.log \
695 $TESTRESULTDIR/${host}.radius.log > /dev/null 2>&1
697 ssh $SSHCONF $HOSTLOGIN grep imcv /var/log/daemon.log \
698 >> $TESTRESULTDIR/${host}.daemon.log 2>/dev/null
700 chmod a+r $TESTRESULTDIR/*
701 cat >> $TESTRESULTDIR/index.html <<@EOF
703 <table border="0" cellspacing="0" width="600">
707 <li><a href="$host.clients.conf">clients.conf</a></li>
708 <li><a href="$host.radiusd.conf">radiusd.conf</a></li>
709 <li><a href="$host.strongswan.conf">strongswan.conf</a></li>
714 <li><a href="$host.eap.conf">eap.conf</a></li>
715 <li><a href="$host.radius.log">radius.log</a></li>
716 <li><a href="$host.daemon.log">daemon.log</a></li>
721 <li><a href="$host.proxy.conf">proxy.conf</a></li>
722 <li><a href="$host.users">users</a></li>
731 cat >> $TESTRESULTDIR/index.html <<@EOF
736 for host in $TCPDUMPHOSTS
738 cat >> $TESTRESULTDIR/index.html <<@EOF
739 <li><a href="$host.tcpdump.log">$host tcpdump.log</a></li>
743 cat >> $TESTRESULTDIR/index.html <<@EOF
747 cat >> $TESTRESULTDIR/index.html <<@EOF
755 ##########################################################################
756 # execute post-test commands
760 echo -e "\nPOST-TEST\n" >> $CONSOLE_LOG 2>&1
763 if ($1 !~ /^#.*/ && $2 != "")
765 printf("echo \"$(print_time)%s# %s\"; ", $1, $2)
766 printf("ssh \044SSHCONF root@\044ipv4_%s \"%s\"; ", $1, $2)
769 }' $TESTDIR/posttest.dat
` >> $CONSOLE_LOG 2>&1
771 ##########################################################################
772 # check that IPsec state was cleaned up properly
775 for host in $IPSECHOSTS
777 eval HOSTLOGIN=root@\$ipv4_${host}
778 IPSECSTATE=`ssh $SSHCONF $HOSTLOGIN 'ip xfrm state'`
779 # ignore IPv4/v6 states created with IPComp SAs
780 IPSECSTATEISSUE=`echo "$IPSECSTATE" |
grep 'proto.*spi' |
grep -v 'proto 4'`
781 IPSECPOLICY=`ssh $SSHCONF $HOSTLOGIN 'ip xfrm policy'`
782 if [ -n "$IPSECSTATEISSUE" -o -n "$IPSECPOLICY" ]
784 echo -e "\n$host# ip xfrm state [NO]" >> $CONSOLE_LOG
785 echo "$IPSECSTATE" >> $CONSOLE_LOG
786 echo -e "\n$host# ip xfrm policy [NO]" >> $CONSOLE_LOG
787 echo "$IPSECPOLICY" >> $CONSOLE_LOG
793 ##########################################################################
794 # make sure there were no leaks
797 for host in $STRONGSWANHOSTS
799 eval HOSTLOGIN=root@\$ipv4_${host}
800 LEAKS=`ssh $SSHCONF $HOSTLOGIN 'cat $LEAK_DETECTIVE_LOG 2>/dev/null | grep -v "No leaks detected.*"'`
803 echo -e "\n$host# cat $LEAK_DETECTIVE_LOG [NO]" >> $CONSOLE_LOG
804 echo "$LEAKS" >> $CONSOLE_LOG
805 echo "<<< $host $LEAK_DETECTIVE_LOG >>>" >> $CONSOLE_LOG
811 ##########################################################################
812 # get a copy of /var/log/auth.log
815 for host in $IPSECHOSTS
817 eval HOSTLOGIN=root@\$ipv4_${host}
818 ssh $SSHCONF $HOSTLOGIN "grep -s -E 'charon|last message repeated|imcv|pt-tls-client' \
819 /var/log/auth.log" >> $TESTRESULTDIR/${host}.auth.log
823 ##########################################################################
824 # get a copy of /var/log/daemon.log
827 for host in $IPSECHOSTS
829 eval HOSTLOGIN=root@\$ipv4_${host}
830 ssh $SSHCONF $HOSTLOGIN "grep -s -E 'systemd|swanctl|charon|last message repeated|imcv' \
831 /var/log/daemon.log" >> $TESTRESULTDIR/${host}.daemon.log
835 ##########################################################################
836 # stop tcpdump if necessary
839 for host in $TCPDUMPHOSTS
841 if [ "`eval echo \\\
$TDUP_${host}`" = "true" ]
845 eval HOSTLOGIN=root@\$ipv4_${host}
846 scp $SSHCONF $HOSTLOGIN:/tmp/tcpdump.log \
847 $TESTRESULTDIR/${host}.tcpdump.log > /dev/null 2>&1
850 ##########################################################################
851 # remove database directory if needed
856 eval HOSTLOGIN=root@\$ipv4_${host}
857 ssh $SSHCONF $HOSTLOGIN "umount $DBDIR; rm -r $DBDIR" > /dev/null 2>&1
860 ##########################################################################
861 # copy default host config back if necessary
864 $DIR/scripts/restore-defaults $testname
867 ##########################################################################
871 if [ $STATUS = "failed" ]
873 let "failed_cnt += 1"
875 let "passed_cnt += 1"
879 ##########################################################################
880 # write test status to html file
883 let "testend -= teststart"
884 let "timetotal += testend"
886 if [ $STATUS = "passed" ]
895 cat >> $TESTRESULTSHTML << @EOF
898 <td><a href="$testname/index.html">$testname</a></td>
899 <td align="right">$testend</td>
900 <td><a href="$testname/console.log"><font color="$COLOR">$STATUS</font></a></td>
903 cat >> $SUBTESTSINDEX << @EOF
906 <td><a href="$name/index.html">$name</a></td>
907 <td><a href="$name/console.log"><font color="$COLOR">$STATUS</font></a></td>
913 ##########################################################################
914 # remove any charon.pid files that still may exist
917 for host in $IPSECHOSTS
919 eval HOSTLOGIN=root@\$ipv4_${host}
920 ssh $SSHCONF $HOSTLOGIN 'if [ -f /var/run/charon.pid ]; then rm /var/run/charon.pid; echo " removed charon.pid on `hostname
`"; fi'
933 ##############################################################################
934 # finish the results html file
937 cat >> $TESTRESULTSHTML << @EOF
939 <td> </td><td> </td><td> </td><td> </td>
942 <td><b>Passed</b></td><td><b><font color="green">$passed_cnt</font></b></td><td> </td><td> </td>
945 <td><b>Failed</b></td><td><b><font color="red">$failed_cnt</font></b></td><td> </td><td> </td>
948 <td><b>Time [s]</b></td><td><b><font color="blue">$timetotal</font></b></td><td> </td><td> </td>
955 if [ $subdir_cnt != 0 ]
957 cat >> $INDEX << @EOF
958 <td align="right">$subdir_cnt</td>
964 let "all_cnt = $passed_cnt + $failed_cnt"
966 cat >> $INDEX << @EOF
969 <td><a href="all.html"><b>all</b></a></td>
970 <td align="right"><b>$all_cnt</b></td>
974 <td><b>Failed</b></td>
976 <td align="right"><b><font color="red">$failed_cnt</font></b></td>
985 echo_ok "Passed : $passed_cnt"
986 echo_failed "Failed : $failed_cnt"
989 echo "The results are available in $TODAYDIR"
990 echo "or via the link http://$ipv4_winnetou/testresults/$TESTDATE"
992 ENDDATE=`date +%Y
%m
%d-
%H
%M-
%S
`
994 echo "Finished : $ENDDATE"