[Openvpn-devel,2/2] t_net.sh: properly perform sudo check and print test steps

Message ID 20190615230213.14888-2-a@unstable.cc
State Accepted
Headers show
Series [Openvpn-devel,1/2] t_net.sh: make bash dep explicit and run only if SITNL is compiled | expand

Commit Message

Antonio Quartulli June 15, 2019, 1:02 p.m. UTC
From: Antonio Quartulli <antonio@openvpn.net>

The current script is performing a tes ton the "kill" command, but this
is not useful to the t_net.sh script as it never really executes it.

Rather test that "sudo <unit-test-binary>" really works.

<unit-test-binary> has to be added to the sudoers file if this test
has to be performend unattanded. The path is:
./unit_tests/openvpn/networking_testdriver

On to pof that, print a simple OK for every test that is succesful.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
---
 tests/t_net.sh                             | 12 +++++-------
 tests/unit_tests/openvpn/test_networking.c |  6 ++++++
 2 files changed, 11 insertions(+), 7 deletions(-)

Comments

Gert Doering June 15, 2019, 10:35 p.m. UTC | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

"because it makes sense" :-) - for added point, the declarations of
KILL_EXEC= and CC= could also be removed.  And the comment about 
Solaris...  dead code...

Your patch has been applied to the master branch.

commit 6f89dac0ed8b84bc581ceda710c506be2287f2b5
Author: Antonio Quartulli
Date:   Sun Jun 16 01:02:13 2019 +0200

     t_net.sh: properly perform sudo check and print test steps

     Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20190615230213.14888-2-a@unstable.cc>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18548.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/tests/t_net.sh b/tests/t_net.sh
index 1940ec92..70e8517d 100755
--- a/tests/t_net.sh
+++ b/tests/t_net.sh
@@ -125,14 +125,12 @@  else
         echo "      must be set correctly in 't_client.rc'. SKIP." >&2
         exit 77
     else
-        # We have to use sudo. Make sure that we (hopefully) do not have
-        # to ask the users password during the test. This is done to
-        # prevent timing issues, e.g. when the waits for openvpn to start
-	    if $RUN_SUDO $KILL_EXEC -0 $$
+        # check that we can run the unit-test binary with sudo
+	    if $RUN_SUDO $UNIT_TEST test
         then
-	        echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
+	        echo "$0: $RUN_SUDO $UNIT_TEST succeeded, good."
         else
-	        echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
+	        echo "$0: $RUN_SUDO $UNIT_TEST failed, cannot go on. SKIP." >&2
 	        exit 77
         fi
     fi
@@ -172,7 +170,7 @@  for i in $(seq 0 $MAX_TEST); do
             exit 1
         fi
     done
-
+    echo "Test $i: OK"
 done
 
 # remove interface for good
diff --git a/tests/unit_tests/openvpn/test_networking.c b/tests/unit_tests/openvpn/test_networking.c
index 66035011..6c50da92 100644
--- a/tests/unit_tests/openvpn/test_networking.c
+++ b/tests/unit_tests/openvpn/test_networking.c
@@ -185,6 +185,12 @@  main(int argc, char *argv[])
         return -1;
     }
 
+    /* the t_net script can use this command to perform a dry-run test */
+    if (strcmp(argv[1], "test") == 0)
+    {
+        return 0;
+    }
+
     if (argc > 3)
     {
         iface = argv[2];