introduced subdirectory structure

This commit is contained in:
Andreas Steffen
2006-07-03 07:10:17 +00:00
parent 971218c3ae
commit d9a883c337
+269 -255
View File
@@ -144,194 +144,208 @@ else
TESTS="`ls $DEFAULTTESTSDIR`" TESTS="`ls $DEFAULTTESTSDIR`"
fi fi
for testname in $TESTS for SUBDIR in $TESTS
do do
let "testnumber += 1" SUBTESTS="`basename $SUBDIR`"
cecho-n " $testnumber $testname.."
if [ ! -d $DEFAULTTESTSDIR/${testname} ] if [ $SUBTESTS = $SUBDIR ]
then then
cecho "is missing..skipped" SUBTESTS="`ls $DEFAULTTESTSDIR/$SUBDIR`"
continue
fi
[ -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"
TESTRESULTDIR=$TODAYDIR/$testname
mkdir $TESTRESULTDIR
CONSOLE_LOG=$TESTRESULTDIR/console.log
touch $CONSOLE_LOG
TESTDIR=$TESTSDIR/${testname}
rm -rf $TESTDIR/*
cp -rfp $DEFAULTTESTSDIR/${testname} $TESTSDIR
##############################################################################
# replace IP wildcards with actual IPv4 and IPv6 addresses
#
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_ALICE $ipv4_alice $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 $TESTSDIR
searchandreplace PH_IP_DAVE $ipv4_dave $TESTSDIR
searchandreplace PH_IP6_DAVE1 $ipv6_dave1 $TESTSDIR
searchandreplace PH_IP6_DAVE $ipv6_dave $TESTSDIR
;;
winnetou)
searchandreplace PH_IP_WINNETOU $ipv4_winnetou $TESTSDIR
searchandreplace PH_IP6_WINNETOU $ipv6_winnetou $TESTSDIR
;;
esac
done
##########################################################################
# copy test specific configurations to uml hosts and clear auth.log files
#
$DIR/scripts/load-testconfig $testname
source $TESTDIR/test.conf
##########################################################################
# run tcpdump in the background
#
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 \\\$ipv4_$host '$tcpdump_cmd'`
eval TDUP_${host}="true"
done
fi
##########################################################################
# execute pre-test commands
#
cecho-n "pre.."
echo -e "\nPRE-TEST\n" >> $CONSOLE_LOG 2>&1
eval `awk -F "::" '{
if ($2 != "")
{
printf("echo \"%s# %s\"; ", $1, $2)
printf("ssh root@\044ipv4_%s \"%s\"; ", $1, $2)
printf("echo;\n")
}
}' $TESTDIR/pretest.dat` >> $CONSOLE_LOG 2>&1
##########################################################################
# stop tcpdump
#
function stop_tcpdump {
echo "${1}# killall tcpdump" >> $CONSOLE_LOG
eval ssh root@\$ipv4_${1} killall tcpdump
eval TDUP_${1}="false"
echo ""
}
##########################################################################
# get and evaluate test results
#
cecho-n "test.."
echo -e "\nTEST\n" >> $CONSOLE_LOG 2>&1
STATUS="passed"
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@\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 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
##########################################################################
# set counters
#
if [ $STATUS = "failed" ]
then
let "failed_cnt += 1"
else else
let "passed_cnt += 1" SUBDIR="`dirname $SUBDIR`"
fi fi
for name in $SUBTESTS
do
let "testnumber += 1"
testname=$SUBDIR/$name
cecho-n " $testnumber $testname.."
########################################################################## if [ ! -d $DEFAULTTESTSDIR/${testname} ]
# log statusall and listall output then
# get copies of ipsec.conf, ipsec.secrets cecho "is missing..skipped"
# create index.html for the given test case continue
fi
cat > $TESTRESULTDIR/index.html <<@EOF [ -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"
TESTRESULTDIR=$TODAYDIR/$testname
mkdir -p $TESTRESULTDIR
CONSOLE_LOG=$TESTRESULTDIR/console.log
touch $CONSOLE_LOG
TESTDIR=$TESTSDIR/${testname}
rm -rf $TESTDIR
mkdir -p $TESTDIR
cp -rfp $DEFAULTTESTSDIR/${testname}/* $TESTDIR
##############################################################################
# replace IP wildcards with actual IPv4 and IPv6 addresses
#
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_ALICE $ipv4_alice $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
##########################################################################
# copy test specific configurations to uml hosts and clear auth.log files
#
$DIR/scripts/load-testconfig $testname
source $TESTDIR/test.conf
##########################################################################
# run tcpdump in the background
#
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 \\\$ipv4_$host '$tcpdump_cmd'`
eval TDUP_${host}="true"
done
fi
##########################################################################
# execute pre-test commands
#
cecho-n "pre.."
echo -e "\nPRE-TEST\n" >> $CONSOLE_LOG 2>&1
eval `awk -F "::" '{
if ($2 != "")
{
printf("echo \"%s# %s\"; ", $1, $2)
printf("ssh root@\044ipv4_%s \"%s\"; ", $1, $2)
printf("echo;\n")
}
}' $TESTDIR/pretest.dat` >> $CONSOLE_LOG 2>&1
##########################################################################
# stop tcpdump
#
function stop_tcpdump {
echo "${1}# killall tcpdump" >> $CONSOLE_LOG
eval ssh root@\$ipv4_${1} killall tcpdump
eval TDUP_${1}="false"
echo ""
}
##########################################################################
# get and evaluate test results
#
cecho-n "test.."
echo -e "\nTEST\n" >> $CONSOLE_LOG 2>&1
STATUS="passed"
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@\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 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
##########################################################################
# set counters
#
if [ $STATUS = "failed" ]
then
let "failed_cnt += 1"
else
let "passed_cnt += 1"
fi
##########################################################################
# 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
<html> <html>
<head> <head>
<title>Test $testname</title> <title>Test $testname</title>
@@ -343,33 +357,32 @@ do
<h3>Description</h3> <h3>Description</h3>
@EOF @EOF
cat $TESTDIR/description.txt >> $TESTRESULTDIR/index.html cat $TESTDIR/description.txt >> $TESTRESULTDIR/index.html
cat >> $TESTRESULTDIR/index.html <<@EOF cat >> $TESTRESULTDIR/index.html <<@EOF
<ul> <ul>
<li><a href="console.log">console.log</a></li> <li><a href="console.log">console.log</a></li>
</ul> </ul>
<img src="../images/$DIAGRAM" alt="$UMLHOSTS"> <img src="../images/$DIAGRAM" alt="$UMLHOSTS">
@EOF @EOF
for host in $IPSECHOSTS
for host in $IPSECHOSTS
do
eval HOSTLOGIN=root@\$ipv4_${host}
for command in statusall listall
do do
ssh $HOSTLOGIN ipsec $command \ eval HOSTLOGIN=root@\$ipv4_${host}
> $TESTRESULTDIR/${host}.$command 2>/dev/null
done
for file in ipsec.conf ipsec.secrets for command in statusall listall
do do
scp $HOSTLOGIN:/etc/$file \ ssh $HOSTLOGIN ipsec $command \
$TESTRESULTDIR/${host}.$file > /dev/null 2>&1 > $TESTRESULTDIR/${host}.$command 2>/dev/null
done done
cat >> $TESTRESULTDIR/index.html <<@EOF for file in ipsec.conf ipsec.secrets
do
scp $HOSTLOGIN:/etc/$file \
$TESTRESULTDIR/${host}.$file > /dev/null 2>&1
done
cat >> $TESTRESULTDIR/index.html <<@EOF
<h3>$host</h3> <h3>$host</h3>
<ul> <ul>
<li><a href="$host.ipsec.conf">ipsec.conf</a></li> <li><a href="$host.ipsec.conf">ipsec.conf</a></li>
@@ -380,9 +393,9 @@ do
</ul> </ul>
@EOF @EOF
done done
cat >> $TESTRESULTDIR/index.html <<@EOF cat >> $TESTRESULTDIR/index.html <<@EOF
</td></tr> </td></tr>
<tr><td align="right"> <tr><td align="right">
<b><a href="../index.html">Back</a></b> <b><a href="../index.html">Back</a></b>
@@ -393,73 +406,73 @@ do
@EOF @EOF
########################################################################## ##########################################################################
# execute post-test commands # execute post-test commands
# #
cecho-n "post.." cecho-n "post.."
echo -e "\nPOST-TEST\n" >> $CONSOLE_LOG 2>&1 echo -e "\nPOST-TEST\n" >> $CONSOLE_LOG 2>&1
eval `awk -F "::" '{ eval `awk -F "::" '{
if ($2 != "") if ($2 != "")
{ {
printf("echo \"%s# %s\"; ", $1, $2) printf("echo \"%s# %s\"; ", $1, $2)
printf("ssh root@\044ipv4_%s \"%s\"; ", $1, $2) printf("ssh root@\044ipv4_%s \"%s\"; ", $1, $2)
printf("echo;\n") printf("echo;\n")
} }
}' $TESTDIR/posttest.dat` >> $CONSOLE_LOG 2>&1 }' $TESTDIR/posttest.dat` >> $CONSOLE_LOG 2>&1
########################################################################## ##########################################################################
# get a copy of /var/log/auth.log # get a copy of /var/log/auth.log
# #
for host in $IPSECHOSTS for host in $IPSECHOSTS
do do
eval HOSTLOGIN=root@\$ipv4_${host} eval HOSTLOGIN=root@\$ipv4_${host}
ssh $HOSTLOGIN grep pluto /var/log/auth.log \ ssh $HOSTLOGIN grep pluto /var/log/auth.log \
> $TESTRESULTDIR/${host}.auth.log > $TESTRESULTDIR/${host}.auth.log
echo >> $TESTRESULTDIR/${host}.auth.log echo >> $TESTRESULTDIR/${host}.auth.log
ssh $HOSTLOGIN grep charon /var/log/auth.log \ ssh $HOSTLOGIN grep charon /var/log/auth.log \
>> $TESTRESULTDIR/${host}.auth.log >> $TESTRESULTDIR/${host}.auth.log
done done
########################################################################## ##########################################################################
# stop tcpdump if necessary # stop tcpdump if necessary
# #
for host in $TCPDUMPHOSTS for host in $TCPDUMPHOSTS
do do
if [ "`eval echo \\\$TDUP_${host}`" = "true" ] if [ "`eval echo \\\$TDUP_${host}`" = "true" ]
then
echo "${host}# killall tcpdump" >> $CONSOLE_LOG
eval ssh root@\$ipv4_$host killall tcpdump
eval TDUP_${host}="false"
fi
done
##########################################################################
# copy default host config back if necessary
#
$DIR/scripts/restore-defaults $testname
##########################################################################
# write test status to html file
#
cecho "$STATUS"
if [ $STATUS = "passed" ]
then then
echo "${host}# killall tcpdump" >> $CONSOLE_LOG COLOR="green"
eval ssh root@\$ipv4_$host killall tcpdump else
eval TDUP_${host}="false" COLOR="red"
fi fi
done
cat >> $TESTRESULTSHTML << @EOF
##########################################################################
# copy default host config back if necessary
#
$DIR/scripts/restore-defaults $testname
##########################################################################
# write test status to html file
#
cecho "$STATUS"
if [ $STATUS = "passed" ]
then
COLOR="green"
else
COLOR="red"
fi
cat >> $TESTRESULTSHTML << @EOF
<tr> <tr>
<td>$testnumber</td> <td>$testnumber</td>
<td><a href="$testname/">$testname</a></td> <td><a href="$testname/">$testname</a></td>
@@ -467,6 +480,7 @@ do
</tr> </tr>
@EOF @EOF
done
done done