]> git.ipfire.org Git - thirdparty/strongswan.git/blobdiff - testing/do-tests
ikev1: Get and set the lifetimes of the selected proposal/transform
[thirdparty/strongswan.git] / testing / do-tests
index ba2abb655f7166e6a528f289fc19fa602490b038..fad3af8cd57d49c1de9d8a44613bd76a657014b7 100755 (executable)
@@ -48,6 +48,29 @@ failed_cnt="0"
 passed_cnt="0"
 subdir_cnt="0"
 
+##############################################################################
+# parse optional arguments
+#
+while getopts "vt" opt
+do
+       case "$opt" in
+       v)
+               verbose=YES
+               timestamps=YES
+               ;;
+       t)
+               timestamps=YES
+               ;;
+       esac
+done
+shift $((OPTIND-1))
+
+
+function print_time()
+{
+       [ "$timestamps" == "YES" ] && echo "$(date +%T.%N) ~ "
+}
+
 ##############################################################################
 # copy default tests to $BUILDDIR
 #
@@ -330,7 +353,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
@@ -385,7 +408,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")
            }
@@ -399,7 +422,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
@@ -425,20 +448,22 @@ do
                        next
                }
                printf("cmd_err=\044(tempfile -p test -s err); ")
+               printf("cmd_out=\044(tempfile -p test -s out); ")
                if (command == "tcpdump")
                {
                        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)
+                       printf("ssh \044SSHCONF root@\044ipv4_%s cat /tmp/tcpdump.log > \044cmd_out; ", host)
                }
                else
                {
-                       printf("cmd_out=\044(ssh \044SSHCONF root@\044ipv4_%s %s 2>\044cmd_err | grep \"%s\"); ",  host, command, pattern)
+                       printf("ssh \044SSHCONF root@\044ipv4_%s %s >\044cmd_out 2>\044cmd_err; ",  host, command)
                }
+               printf("cmd_res=\044(cat \044cmd_out | grep \"%s\"); ", pattern)
                printf("cmd_exit=\044?; ")
                printf("cmd_fail=0; ")
                if (hit ~ /^[0-9]+$/)
                {
-                       printf("if [ \044(echo \"\044cmd_out\" | wc -l) -ne %d ] ", hit)
+                       printf("if [ \044(echo \"\044cmd_res\" | wc -l) -ne %d ] ", hit)
                }
                else
                {
@@ -450,15 +475,20 @@ do
                printf("if [ \044cmd_fail -ne 0 ]; then echo \"~~~~~~~ FAIL ~~~~~~~\"; fi; \n")
                if (command == "tcpdump")
                {
-                       printf("echo \"%s# cat /tmp/tcpdump.log | grep \047%s\047  [%s]\"; ", host, pattern, hit)
+                       printf("echo \"$(print_time)%s# cat /tmp/tcpdump.log | grep \047%s\047  [%s]\"; ", host, pattern, hit)
                }
                else
                {
-                       printf("echo \"%s# %s | grep \047%s\047  [%s]\"; ", host, command, pattern, hit)
+                       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("if [ -n \"\044cmd_res\" ]; then echo \"\044cmd_res\"; fi; \n")
+               printf("cat \044cmd_err; \n")
+               printf("if [ \044cmd_fail -ne 0 ]; then \n")
+               printf("if [ -s \044cmd_out ]; then echo \"~~ output ~~~~~~~~~~\"; \n")
+               printf("if [ \"\044verbose\" == \"YES\" ]; then cat \044cmd_out;\n")
+               printf("else cat \044cmd_out | head; fi; fi; \n")
+               printf("echo \"~~~~~~~~~~~~~~~~~~~~\"; fi; \n")
+               printf("rm -f -- \044cmd_out \044cmd_err; \n")
                printf("echo; ")
        }' $TESTDIR/evaltest.dat` >> $CONSOLE_LOG 2>&1
 
@@ -663,21 +693,25 @@ do
        do
            eval HOSTLOGIN=root@\$ipv4_${host}
 
-           for file in clients.conf eap.conf radiusd.conf proxy.conf users
+               RADIUS_DIR=/etc/freeradius/3.0
+               RADIUS_EAP_FILE=mods-enabled/eap
+               RADIUS_EAP_NAME=eap
+               if [ "$BASEIMGSUITE" == "jessie" ]
+               then
+                       RADIUS_DIR=/etc/freeradius
+                       RADIUS_EAP_FILE=eap.conf
+                       RADIUS_EAP_NAME=eap.conf
+               fi
+
+               for file in clients.conf radiusd.conf proxy.conf users sites-enabled/default sites-enabled/inner-tunnel $RADIUS_EAP_FILE
            do
-               scp $SSHCONF $HOSTLOGIN:/etc/freeradius/$file \
-                   $TESTRESULTDIR/${host}.$file  > /dev/null 2>&1
+               scp $SSHCONF $HOSTLOGIN:$RADIUS_DIR/$file \
+                   $TESTRESULTDIR/${host}.$(basename $file) > /dev/null 2>&1
            done
 
-               scp $SSHCONF $HOSTLOGIN:/etc/strongswan.conf \
-                   $TESTRESULTDIR/${host}.strongswan.conf  > /dev/null 2>&1
-
            scp $SSHCONF $HOSTLOGIN:/var/log/freeradius/radius.log \
                $TESTRESULTDIR/${host}.radius.log  > /dev/null 2>&1
 
-           ssh $SSHCONF $HOSTLOGIN grep imcv /var/log/daemon.log \
-               >> $TESTRESULTDIR/${host}.daemon.log 2>/dev/null
-
            chmod a+r $TESTRESULTDIR/*
            cat >> $TESTRESULTDIR/index.html <<@EOF
     <h3>$host</h3>
@@ -687,14 +721,14 @@ do
          <ul>
            <li><a href="$host.clients.conf">clients.conf</a></li>
            <li><a href="$host.radiusd.conf">radiusd.conf</a></li>
-           <li><a href="$host.strongswan.conf">strongswan.conf</a></li>
+           <li><a href="$host.$RADIUS_EAP_NAME">$RADIUS_EAP_NAME</a></li>
          </ul>
        </td>
        <td valign="top">
          <ul>
-           <li><a href="$host.eap.conf">eap.conf</a></li>
+           <li><a href="$host.default">sites-enabled/default</a></li>
+           <li><a href="$host.inner-tunnel">sites-enabled/inner-tunnel</a></li>
            <li><a href="$host.radius.log">radius.log</a></li>
-           <li><a href="$host.daemon.log">daemon.log</a></li>
          </ul>
       </td>
        <td valign="top">
@@ -743,7 +777,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")
            }
@@ -757,8 +791,10 @@ do
        do
                eval HOSTLOGIN=root@\$ipv4_${host}
                IPSECSTATE=`ssh $SSHCONF $HOSTLOGIN 'ip xfrm state'`
+               # ignore IPv4/v6 states created with IPComp SAs
+               IPSECSTATEISSUE=`echo "$IPSECSTATE" | grep 'proto.*spi' | grep -v 'proto 4'`
                IPSECPOLICY=`ssh $SSHCONF $HOSTLOGIN 'ip xfrm policy'`
-               if [ -n "$IPSECSTATE" -o -n "$IPSECPOLICY" ]
+               if [ -n "$IPSECSTATEISSUE" -o -n "$IPSECPOLICY" ]
                then
                        echo -e "\n$host# ip xfrm state [NO]" >> $CONSOLE_LOG
                        echo "$IPSECSTATE" >> $CONSOLE_LOG
@@ -806,7 +842,7 @@ do
        for host in $IPSECHOSTS
        do
            eval HOSTLOGIN=root@\$ipv4_${host}
-           ssh $SSHCONF $HOSTLOGIN "grep -s -E 'charon|last message repeated|imcv' \
+           ssh $SSHCONF $HOSTLOGIN "grep -s -E 'systemd|swanctl|charon|last message repeated|imcv' \
                /var/log/daemon.log" >> $TESTRESULTDIR/${host}.daemon.log
        done