summaryrefslogtreecommitdiff
path: root/testing/do-tests
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@corsac.net>2017-09-01 17:21:25 +0200
committerYves-Alexis Perez <corsac@corsac.net>2017-09-01 17:21:25 +0200
commit11d6b62db969bdd808d0f56706cb18f113927a31 (patch)
tree8aa7d8fb611c3da6a3523cb78a082f62ffd0dac8 /testing/do-tests
parentbba25e2ff6c4a193acb54560ea4417537bd2954e (diff)
downloadvyos-strongswan-11d6b62db969bdd808d0f56706cb18f113927a31.tar.gz
vyos-strongswan-11d6b62db969bdd808d0f56706cb18f113927a31.zip
New upstream version 5.6.0
Diffstat (limited to 'testing/do-tests')
-rwxr-xr-xtesting/do-tests94
1 files changed, 69 insertions, 25 deletions
diff --git a/testing/do-tests b/testing/do-tests
index 60c34c798..e3fd9b464 100755
--- a/testing/do-tests
+++ b/testing/do-tests
@@ -49,6 +49,25 @@ passed_cnt="0"
subdir_cnt="0"
##############################################################################
+# parse optional arguments
+#
+while getopts "v" opt
+do
+ case "$opt" in
+ v)
+ verbose=YES
+ ;;
+ esac
+done
+shift $((OPTIND-1))
+
+
+function print_time()
+{
+ [ "$verbose" == "YES" ] && echo "$(date +%T.%N) ~ "
+}
+
+##############################################################################
# copy default tests to $BUILDDIR
#
@@ -207,12 +226,16 @@ for SUBDIR in $TESTS
do
SUBTESTS="`basename $SUBDIR`"
- if [ $SUBTESTS = $SUBDIR ]
- then
- SUBTESTS="`ls $DEFAULTTESTSDIR/$SUBDIR`"
- else
- SUBDIR="`dirname $SUBDIR`"
- fi
+ if [ $SUBTESTS = $SUBDIR ]
+ then
+ SUBTESTS="`ls $DEFAULTTESTSDIR/$SUBDIR`"
+ else
+ if [[ $SUBTESTS == *'*'* ]]
+ then
+ SUBTESTS="`basename -a $DEFAULTTESTSDIR/$SUBDIR`"
+ fi
+ SUBDIR="`dirname $SUBDIR`"
+ fi
if [ ! -d $TODAYDIR/$SUBDIR ]
then
@@ -326,7 +349,7 @@ 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
+ echo "$(print_time)${host}# $tcpdump_cmd" >> $CONSOLE_LOG
ssh $SSHCONF root@`eval echo \\\$ipv4_$host '$tcpdump_cmd'`
eval TDUP_${host}="true"
done
@@ -381,7 +404,7 @@ do
eval `awk -F "::" '{
if ($1 !~ /^#.*/ && $2 != "")
{
- printf("echo \"%s# %s\"; ", $1, $2)
+ printf("echo \"$(print_time)%s# %s\"; ", $1, $2)
printf("ssh \044SSHCONF root@\044ipv4_%s \"%s\"; ", $1, $2)
printf("echo;\n")
}
@@ -395,7 +418,7 @@ do
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
+ echo "$(print_time)${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
@@ -412,29 +435,50 @@ do
STATUS="passed"
eval `awk -F "::" '{
- host=$1
- command=$2
- pattern=$3
- hit=$4
- if (host !~ /^#.*/ && command != "")
- {
+ host=$1
+ command=$2
+ pattern=$3
+ hit=$4
+ if (host ~ /^#.*/ || command == "")
+ {
+ next
+ }
+ printf("cmd_err=\044(tempfile -p test -s err); ")
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)
+ printf("if [ \044TDUP_%s == \"true\" ]; then stop_tcpdump %s; fi; \n", host, host)
+ printf("cmd_out=\044(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_out=\044(ssh \044SSHCONF root@\044ipv4_%s %s 2>\044cmd_err | grep \"%s\"); ", host, command, pattern)
}
printf("cmd_exit=\044?; ")
+ printf("cmd_fail=0; ")
+ if (hit ~ /^[0-9]+$/)
+ {
+ printf("if [ \044(echo \"\044cmd_out\" | wc -l) -ne %d ] ", hit)
+ }
+ else
+ {
+ printf("if [ \044cmd_exit -eq 0 -a \"%s\" = \"NO\" ] ", hit)
+ printf("|| [ \044cmd_exit -ne 0 -a \"%s\" = \"YES\" ] ", hit)
+ }
+ printf("; then STATUS=\"failed\"; cmd_fail=1; fi; \n")
+
+ printf("if [ \044cmd_fail -ne 0 ]; then echo \"~~~~~~~ FAIL ~~~~~~~\"; fi; \n")
+ if (command == "tcpdump")
+ {
+ printf("echo \"$(print_time)%s# cat /tmp/tcpdump.log | grep \047%s\047 [%s]\"; ", host, pattern, hit)
+ }
+ else
+ {
+ printf("echo \"$(print_time)%s# %s | grep \047%s\047 [%s]\"; ", host, command, pattern, hit)
+ }
+ printf("if [ -n \"\044cmd_out\" ]; then echo \"\044cmd_out\"; fi; \n")
+ printf("cat \044cmd_err; rm -f -- \044cmd_err; \n")
+ printf("if [ \044cmd_fail -ne 0 ]; then echo \"~~~~~~~~~~~~~~~~~~~~\"; fi; \n")
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
@@ -718,7 +762,7 @@ do
eval `awk -F "::" '{
if ($1 !~ /^#.*/ && $2 != "")
{
- printf("echo \"%s# %s\"; ", $1, $2)
+ printf("echo \"$(print_time)%s# %s\"; ", $1, $2)
printf("ssh \044SSHCONF root@\044ipv4_%s \"%s\"; ", $1, $2)
printf("echo;\n")
}