Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1755?usp=email

to look at the new patch set (#2).


Change subject: t_client.sh.in: Add support for expected test failures
......................................................................

t_client.sh.in: Add support for expected test failures

Allow to mark tests that must fail. The EXPECT_FAIL
message must contain a message that can be found in
the log output. OpenVPN must not start up successfully,
so this does not allow to test for failures that only
affect the traffic over the link.

This is based on work by Gert Doering for the t_server
test infrastructure.

Change-Id: I6c51bcdda5666e0dab2adcdaff28408c9bfcb844
Signed-off-by: Frank Lichtenheld <[email protected]>
---
M tests/t_client.sh.in
1 file changed, 48 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/1755/2

diff --git a/tests/t_client.sh.in b/tests/t_client.sh.in
index c3e98a8..7b7f5de 100755
--- a/tests/t_client.sh.in
+++ b/tests/t_client.sh.in
@@ -320,6 +320,7 @@
     eval expect_ifconfig6=\"\$EXPECT_IFCONFIG6_$SUF\"
     eval ping4_hosts=\"\$PING4_HOSTS_$SUF\"
     eval ping6_hosts=\"\$PING6_HOSTS_$SUF\"
+    eval expect_fail=\"\$EXPECT_FAIL_$SUF\"
     eval fping_args=\"\$FPING_EXTRA_ARGS \$FPING_ARGS_$SUF\"

     # If EXCEPT_IFCONFIG* variables for this test are missing, run an --up
@@ -331,6 +332,9 @@
     fi

     output_start "### test run $SUF: '$test_run_title' ###"
+    if [ -n "$expect_fail" ] ; then
+        output "### expect failure: '$expect_fail'";
+    fi
     fail_count=0

     if [ -n "$test_check_skip" ]; then
@@ -377,23 +381,57 @@
     ovpn_init_success=0
     while [ $ovpn_init_check -gt 0 ];
     do
-       sleep 1  # Wait for OpenVPN to initialize and have had time to write 
the pid file
-       grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log 
>/dev/null
-       if [ $? -eq 0 ]; then
-           ovpn_init_check=0
-           ovpn_init_success=1
-       fi
-       ovpn_init_check=$(( $ovpn_init_check - 1 ))
+        sleep 1  # Wait for OpenVPN to initialize and have had time to write 
the pid file
+        if [ -n "$expect_fail" ]
+        then
+            grep "$expect_fail" $LOGDIR/$SUF:openvpn.log # >/dev/null
+            if [ $? -eq 0 ]; then
+                ovpn_init_check=0
+                ovpn_init_success=1
+                sleep 5         # give openvpn time to quit
+            fi
+        else
+            grep "Initialization Sequence Completed" $LOGDIR/$SUF:openvpn.log 
>/dev/null
+            if [ $? -eq 0 ]; then
+                ovpn_init_check=0
+                ovpn_init_success=1
+            fi
+        fi
+        ovpn_init_check=$(( $ovpn_init_check - 1 ))
     done

-    opid=`cat $pidfile`
+    opid=`[ -e $pidfile ] && cat $pidfile`
     if [ -n "$opid" ]; then
         output "  OpenVPN running with PID $opid"
     else
-        output "  Could not read OpenVPN PID file"
+        if [ -z "$expect_fail" ]        # print this only if unexpected
+        then
+            output "  Could not read OpenVPN PID file"
+        fi
     fi

-    # If OpenVPN did not start
+    # did we expect a failure?
+    if [ -n "$expect_fail" ]
+    then
+        if [ -n "$opid" ]               # OpenVPN did start!
+        then
+            output "$0: OpenVPN did start up, expected failure"
+            $RUN_SUDO $KILL_EXEC $opid $sudopid
+            output "tail -5 $SUF:openvpn.log"
+            output "`tail -5 $LOGDIR/$SUF:openvpn.log`"
+            fail "skip rest of sub-tests for test run $SUF."
+            trap - 0 1 2 3 15
+            SUMMARY_FAIL="$SUMMARY_FAIL $SUF"
+            exit_code=32
+            printf "$outbuf" ; continue
+        else
+            output "test run $SUF: all tests OK (saw expected failure)."
+            SUMMARY_OK="$SUMMARY_OK $SUF"
+            continue
+        fi
+    fi
+
+    # If OpenVPN did not start but should have
     if [ $ovpn_init_success -ne 1 -o -z "$opid" ]; then
         output "$0:  OpenVPN did not initialize in a reasonable time"
         if [ -n "$opid" ]; then

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1755?usp=email
To unsubscribe, or for help writing mail filters, visit 
http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6c51bcdda5666e0dab2adcdaff28408c9bfcb844
Gerrit-Change-Number: 1755
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to