]>
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 printf("cmd_out=\044(tempfile -p test -s out); ")
448 if (command == "tcpdump")
450 printf("if [ \044TDUP_%s == \"true\" ]; then stop_tcpdump %s; fi; \n", host, host)
451 printf("ssh \044SSHCONF root@\044ipv4_%s cat /tmp/tcpdump.log > \044cmd_out; ", host)
455 printf("ssh \044SSHCONF root@\044ipv4_%s %s >\044cmd_out 2>\044cmd_err; ", host, command)
457 printf("cmd_res=\044(cat \044cmd_out | grep \"%s\"); ", pattern)
458 printf("cmd_exit=\044?; ")
459 printf("cmd_fail=0; ")
460 if (hit ~ /^[0-9]+$/)
462 printf("if [ \044(echo \"\044cmd_res\" | wc -l) -ne %d ] ", hit)
466 printf("if [ \044cmd_exit -eq 0 -a \"%s\" = \"NO\" ] ", hit)
467 printf("|| [ \044cmd_exit -ne 0 -a \"%s\" = \"YES\" ] ", hit)
469 printf("; then STATUS=\"failed\"; cmd_fail=1; fi; \n")
471 printf("if [ \044cmd_fail -ne 0 ]; then echo \"~~~~~~~ FAIL ~~~~~~~\"; fi; \n")
472 if (command == "tcpdump")
474 printf("echo \"$(print_time)%s# cat /tmp/tcpdump.log | grep \047%s\047 [%s]\"; ", host, pattern, hit)
478 printf("echo \"$(print_time)%s# %s | grep \047%s\047 [%s]\"; ", host, command, pattern, hit)
480 printf("if [ -n \"\044cmd_res\" ]; then echo \"\044cmd_res\"; fi; \n")
481 printf("cat \044cmd_err; \n")
482 printf("if [ \044cmd_fail -ne 0 ]; then \n")
483 printf("if [ -s \044cmd_out ]; then echo \"~~ output ~~~~~~~~~~\"; \n")
484 printf("if [ \"\044verbose\" == \"YES\" ]; then cat \044cmd_out;\n")
485 printf("else cat \044cmd_out | head; fi; fi; \n")
486 printf("echo \"~~~~~~~~~~~~~~~~~~~~\"; fi; \n")
487 printf("rm -f -- \044cmd_out \044cmd_err; \n")
489 }' $TESTDIR/evaltest.dat
` >> $CONSOLE_LOG 2>&1
492 ##########################################################################
493 # log statusall and listall output
494 # get copies of ipsec.conf, ipsec.secrets
495 # create index.html for the given test case
497 cat > $TESTRESULTDIR/index.html <<@EOF
500 <title>Test $testname</title>
503 <table border="0" cellpadding="0" cellspacing="0" width="600">
505 <div><a href="../../index.html">strongSwan KVM Tests</a> / <a href="../index.html">$SUBDIR</a> / $name</div>
506 <h2>Test $testname</h2>
510 cat $TESTDIR/description.txt >> $TESTRESULTDIR/index.html
512 cat >> $TESTRESULTDIR/index.html <<@EOF
514 <li><a href="console.log">console.log</a></li>
516 <img src="../../images/$DIAGRAM" alt="$VIRTHOSTS">
519 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"
520 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"
524 IPROUTE_CMD="ip -6 route list table $SOURCEIP_ROUTING_TABLE"
525 IPROUTE_DSP=$IPROUTE_CMD
526 IPTABLES_CMD="$IPTABLES_CMD_V6"
527 IPTABLES_DSP="ip6tables -L"
528 IPTABLES_SAVE_CMD="ip6tables-save"
529 IPTABLES_SAVE_DSP="ip6tables-save"
531 IPROUTE_CMD="ip route list table $SOURCEIP_ROUTING_TABLE"
532 IPROUTE_DSP=$IPROUTE_CMD
533 IPTABLES_CMD="$IPTABLES_CMD_V4"
534 IPTABLES_DSP="iptables -L"
535 IPTABLES_SAVE_CMD="iptables-save"
536 IPTABLES_SAVE_DSP="iptables-save"
539 if [ $name = "net2net-ip4-in-ip6-ikev2" -o $name = "net2net-ip6-in-ip4-ikev2" ]
541 IPROUTE_CMD="ip route list table $SOURCEIP_ROUTING_TABLE; echo; ip -6 route list table $SOURCEIP_ROUTING_TABLE"
542 IPROUTE_DSP="ip (-6) route list table $SOURCEIP_ROUTING_TABLE"
543 IPTABLES_CMD="$IPTABLES_CMD_V4; echo; $IPTABLES_CMD_V6"
544 IPTABLES_DSP="iptables -L ; ip6tables -L"
545 IPTABLES_SAVE_CMD="iptables-save; echo; ip6tables-save"
546 IPTABLES_SAVE_DSP="iptables-save ; ip6tables-save"
551 eval HOSTLOGIN=root@\$ipv4_${host}
553 scp $SSHCONF $HOSTLOGIN:/etc/db.d/ipsec.sql \
554 $TESTRESULTDIR/${host}.ipsec.sql > /dev/null 2>&1
557 for host in $IPSECHOSTS
559 eval HOSTLOGIN=root@\$ipv4_${host}
561 scp $SSHCONF $HOSTLOGIN:/etc/strongswan.conf \
562 $TESTRESULTDIR/${host}.strongswan.conf > /dev/null 2>&1
565 scp $SSHCONF $HOSTLOGIN:/etc/swanctl/swanctl.conf \
566 $TESTRESULTDIR/${host}.swanctl.conf > /dev/null 2>&1
568 for subsys in conns algs certs pools authorities sas pols
570 ssh $SSHCONF $HOSTLOGIN swanctl --list-$subsys \
571 > $TESTRESULTDIR/${host}.swanctl.$subsys 2>/dev/null
574 ssh $SSHCONF $HOSTLOGIN swanctl --stats \
575 > $TESTRESULTDIR/${host}.swanctl.stats 2>/dev/null
577 echo "" >> $TESTRESULTDIR/${host}.swanctl.sas
578 cat $TESTRESULTDIR/${host}.swanctl.pols >> \
579 $TESTRESULTDIR/${host}.swanctl.sas
580 cat $TESTRESULTDIR/${host}.swanctl.algs >> \
581 $TESTRESULTDIR/${host}.swanctl.stats
583 for file in ipsec.conf ipsec.secrets
585 scp $SSHCONF $HOSTLOGIN:/etc/$file \
586 $TESTRESULTDIR/${host}.$file > /dev/null 2>&1
589 for command in statusall listall
591 ssh $SSHCONF $HOSTLOGIN ipsec $command \
592 > $TESTRESULTDIR/${host}.$command 2>/dev/null
596 if (! [ -f $TESTRESULTDIR/${host}.ipsec.sql ] ) then
597 scp $SSHCONF $HOSTLOGIN:/etc/ipsec.d/ipsec.sql \
598 $TESTRESULTDIR/${host}.ipsec.sql > /dev/null 2>&1
601 ssh $SSHCONF $HOSTLOGIN ip -s xfrm policy \
602 > $TESTRESULTDIR/${host}.ip.policy 2>/dev/null
603 ssh $SSHCONF $HOSTLOGIN ip -s xfrm state \
604 > $TESTRESULTDIR/${host}.ip.state 2>/dev/null
605 ssh $SSHCONF $HOSTLOGIN $IPROUTE_CMD \
606 > $TESTRESULTDIR/${host}.ip.route 2>/dev/null
607 ssh $SSHCONF $HOSTLOGIN $IPTABLES_CMD \
608 > $TESTRESULTDIR/${host}.iptables 2>/dev/null
609 ssh $SSHCONF $HOSTLOGIN $IPTABLES_SAVE_CMD \
610 > $TESTRESULTDIR/${host}.iptables-save 2>/dev/null
611 chmod a+r $TESTRESULTDIR/*
615 cat >> $TESTRESULTDIR/index.html <<@EOF
617 <table border="0" cellspacing="0" width="600">
621 <li><a href="$host.swanctl.conf">swanctl.conf</a></li>
622 <li><a href="$host.swanctl.conns">swanctl --list-conns</a></li>
623 <li><a href="$host.swanctl.certs">swanctl --list-certs</a></li>
624 <li><a href="$host.strongswan.conf">strongswan.conf</a></li>
625 <li><a href="$host.ipsec.sql">ipsec.sql</a></li>
630 <li><a href="$host.swanctl.sas">swanctl --list-sas|--list-pols</a></li>
631 <li><a href="$host.swanctl.pools">swanctl --list-pools</a></li>
632 <li><a href="$host.swanctl.authorities">swanctl --list-authorities</a></li>
633 <li><a href="$host.swanctl.stats">swanctl --stats|--list-algs</a></li>
634 <li><a href="$host.auth.log">auth.log</a></li>
635 <li><a href="$host.daemon.log">daemon.log</a></li>
640 <li><a href="$host.ip.policy">ip -s xfrm policy</a></li>
641 <li><a href="$host.ip.state">ip -s xfrm state</a></li>
642 <li><a href="$host.ip.route">$IPROUTE_DSP</a></li>
643 <li><a href="$host.iptables">$IPTABLES_DSP</a></li>
644 <li><a href="$host.iptables-save">$IPTABLES_SAVE_DSP</a></li>
653 cat >> $TESTRESULTDIR/index.html <<@EOF
655 <table border="0" cellspacing="0" width="600">
659 <li><a href="$host.ipsec.conf">ipsec.conf</a></li>
660 <li><a href="$host.ipsec.secrets">ipsec.secrets</a></li>
661 <li><a href="$host.ipsec.sql">ipsec.sql</a></li>
662 <li><a href="$host.strongswan.conf">strongswan.conf</a></li>
667 <li><a href="$host.statusall">ipsec statusall</a></li>
668 <li><a href="$host.listall">ipsec listall</a></li>
669 <li><a href="$host.auth.log">auth.log</a></li>
670 <li><a href="$host.daemon.log">daemon.log</a></li>
675 <li><a href="$host.ip.policy">ip -s xfrm policy</a></li>
676 <li><a href="$host.ip.state">ip -s xfrm state</a></li>
677 <li><a href="$host.ip.route">$IPROUTE_DSP</a></li>
678 <li><a href="$host.iptables">$IPTABLES_DSP</a></li>
679 <li><a href="$host.iptables-save">$IPTABLES_SAVE_DSP</a></li>
688 for host in $RADIUSHOSTS
690 eval HOSTLOGIN=root@\$ipv4_${host}
692 for file in clients.conf eap.conf radiusd.conf proxy.conf users
694 scp $SSHCONF $HOSTLOGIN:/etc/freeradius/$file \
695 $TESTRESULTDIR/${host}.$file > /dev/null 2>&1
698 scp $SSHCONF $HOSTLOGIN:/etc/strongswan.conf \
699 $TESTRESULTDIR/${host}.strongswan.conf > /dev/null 2>&1
701 scp $SSHCONF $HOSTLOGIN:/var/log/freeradius/radius.log \
702 $TESTRESULTDIR/${host}.radius.log > /dev/null 2>&1
704 ssh $SSHCONF $HOSTLOGIN grep imcv /var/log/daemon.log \
705 >> $TESTRESULTDIR/${host}.daemon.log 2>/dev/null
707 chmod a+r $TESTRESULTDIR/*
708 cat >> $TESTRESULTDIR/index.html <<@EOF
710 <table border="0" cellspacing="0" width="600">
714 <li><a href="$host.clients.conf">clients.conf</a></li>
715 <li><a href="$host.radiusd.conf">radiusd.conf</a></li>
716 <li><a href="$host.strongswan.conf">strongswan.conf</a></li>
721 <li><a href="$host.eap.conf">eap.conf</a></li>
722 <li><a href="$host.radius.log">radius.log</a></li>
723 <li><a href="$host.daemon.log">daemon.log</a></li>
728 <li><a href="$host.proxy.conf">proxy.conf</a></li>
729 <li><a href="$host.users">users</a></li>
738 cat >> $TESTRESULTDIR/index.html <<@EOF
743 for host in $TCPDUMPHOSTS
745 cat >> $TESTRESULTDIR/index.html <<@EOF
746 <li><a href="$host.tcpdump.log">$host tcpdump.log</a></li>
750 cat >> $TESTRESULTDIR/index.html <<@EOF
754 cat >> $TESTRESULTDIR/index.html <<@EOF
762 ##########################################################################
763 # execute post-test commands
767 echo -e "\nPOST-TEST\n" >> $CONSOLE_LOG 2>&1
770 if ($1 !~ /^#.*/ && $2 != "")
772 printf("echo \"$(print_time)%s# %s\"; ", $1, $2)
773 printf("ssh \044SSHCONF root@\044ipv4_%s \"%s\"; ", $1, $2)
776 }' $TESTDIR/posttest.dat
` >> $CONSOLE_LOG 2>&1
778 ##########################################################################
779 # check that IPsec state was cleaned up properly
782 for host in $IPSECHOSTS
784 eval HOSTLOGIN=root@\$ipv4_${host}
785 IPSECSTATE=`ssh $SSHCONF $HOSTLOGIN 'ip xfrm state'`
786 # ignore IPv4/v6 states created with IPComp SAs
787 IPSECSTATEISSUE=`echo "$IPSECSTATE" |
grep 'proto.*spi' |
grep -v 'proto 4'`
788 IPSECPOLICY=`ssh $SSHCONF $HOSTLOGIN 'ip xfrm policy'`
789 if [ -n "$IPSECSTATEISSUE" -o -n "$IPSECPOLICY" ]
791 echo -e "\n$host# ip xfrm state [NO]" >> $CONSOLE_LOG
792 echo "$IPSECSTATE" >> $CONSOLE_LOG
793 echo -e "\n$host# ip xfrm policy [NO]" >> $CONSOLE_LOG
794 echo "$IPSECPOLICY" >> $CONSOLE_LOG
800 ##########################################################################
801 # make sure there were no leaks
804 for host in $STRONGSWANHOSTS
806 eval HOSTLOGIN=root@\$ipv4_${host}
807 LEAKS=`ssh $SSHCONF $HOSTLOGIN 'cat $LEAK_DETECTIVE_LOG 2>/dev/null | grep -v "No leaks detected.*"'`
810 echo -e "\n$host# cat $LEAK_DETECTIVE_LOG [NO]" >> $CONSOLE_LOG
811 echo "$LEAKS" >> $CONSOLE_LOG
812 echo "<<< $host $LEAK_DETECTIVE_LOG >>>" >> $CONSOLE_LOG
818 ##########################################################################
819 # get a copy of /var/log/auth.log
822 for host in $IPSECHOSTS
824 eval HOSTLOGIN=root@\$ipv4_${host}
825 ssh $SSHCONF $HOSTLOGIN "grep -s -E 'charon|last message repeated|imcv|pt-tls-client' \
826 /var/log/auth.log" >> $TESTRESULTDIR/${host}.auth.log
830 ##########################################################################
831 # get a copy of /var/log/daemon.log
834 for host in $IPSECHOSTS
836 eval HOSTLOGIN=root@\$ipv4_${host}
837 ssh $SSHCONF $HOSTLOGIN "grep -s -E 'systemd|swanctl|charon|last message repeated|imcv' \
838 /var/log/daemon.log" >> $TESTRESULTDIR/${host}.daemon.log
842 ##########################################################################
843 # stop tcpdump if necessary
846 for host in $TCPDUMPHOSTS
848 if [ "`eval echo \\\
$TDUP_${host}`" = "true" ]
852 eval HOSTLOGIN=root@\$ipv4_${host}
853 scp $SSHCONF $HOSTLOGIN:/tmp/tcpdump.log \
854 $TESTRESULTDIR/${host}.tcpdump.log > /dev/null 2>&1
857 ##########################################################################
858 # remove database directory if needed
863 eval HOSTLOGIN=root@\$ipv4_${host}
864 ssh $SSHCONF $HOSTLOGIN "umount $DBDIR; rm -r $DBDIR" > /dev/null 2>&1
867 ##########################################################################
868 # copy default host config back if necessary
871 $DIR/scripts/restore-defaults $testname
874 ##########################################################################
878 if [ $STATUS = "failed" ]
880 let "failed_cnt += 1"
882 let "passed_cnt += 1"
886 ##########################################################################
887 # write test status to html file
890 let "testend -= teststart"
891 let "timetotal += testend"
893 if [ $STATUS = "passed" ]
902 cat >> $TESTRESULTSHTML << @EOF
905 <td><a href="$testname/index.html">$testname</a></td>
906 <td align="right">$testend</td>
907 <td><a href="$testname/console.log"><font color="$COLOR">$STATUS</font></a></td>
910 cat >> $SUBTESTSINDEX << @EOF
913 <td><a href="$name/index.html">$name</a></td>
914 <td><a href="$name/console.log"><font color="$COLOR">$STATUS</font></a></td>
920 ##########################################################################
921 # remove any charon.pid files that still may exist
924 for host in $IPSECHOSTS
926 eval HOSTLOGIN=root@\$ipv4_${host}
927 ssh $SSHCONF $HOSTLOGIN 'if [ -f /var/run/charon.pid ]; then rm /var/run/charon.pid; echo " removed charon.pid on `hostname
`"; fi'
940 ##############################################################################
941 # finish the results html file
944 cat >> $TESTRESULTSHTML << @EOF
946 <td> </td><td> </td><td> </td><td> </td>
949 <td><b>Passed</b></td><td><b><font color="green">$passed_cnt</font></b></td><td> </td><td> </td>
952 <td><b>Failed</b></td><td><b><font color="red">$failed_cnt</font></b></td><td> </td><td> </td>
955 <td><b>Time [s]</b></td><td><b><font color="blue">$timetotal</font></b></td><td> </td><td> </td>
962 if [ $subdir_cnt != 0 ]
964 cat >> $INDEX << @EOF
965 <td align="right">$subdir_cnt</td>
971 let "all_cnt = $passed_cnt + $failed_cnt"
973 cat >> $INDEX << @EOF
976 <td><a href="all.html"><b>all</b></a></td>
977 <td align="right"><b>$all_cnt</b></td>
981 <td><b>Failed</b></td>
983 <td align="right"><b><font color="red">$failed_cnt</font></b></td>
992 echo_ok "Passed : $passed_cnt"
993 echo_failed "Failed : $failed_cnt"
996 echo "The results are available in $TODAYDIR"
997 echo "or via the link http://$ipv4_winnetou/testresults/$TESTDATE"
999 ENDDATE=`date +%Y
%m
%d-
%H
%M-
%S
`
1001 echo "Finished : $ENDDATE"