Browse code

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

The current script is performing a test on 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 top of that, print a simple OK for every test that is succesful.

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>

Antonio Quartulli authored on 2019/06/16 08:02:13
Showing 2 changed files
... ...
@@ -125,14 +125,12 @@ else
125 125
         echo "      must be set correctly in 't_client.rc'. SKIP." >&2
126 126
         exit 77
127 127
     else
128
-        # We have to use sudo. Make sure that we (hopefully) do not have
129
-        # to ask the users password during the test. This is done to
130
-        # prevent timing issues, e.g. when the waits for openvpn to start
131
-	    if $RUN_SUDO $KILL_EXEC -0 $$
128
+        # check that we can run the unit-test binary with sudo
129
+	    if $RUN_SUDO $UNIT_TEST test
132 130
         then
133
-	        echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
131
+	        echo "$0: $RUN_SUDO $UNIT_TEST succeeded, good."
134 132
         else
135
-	        echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
133
+	        echo "$0: $RUN_SUDO $UNIT_TEST failed, cannot go on. SKIP." >&2
136 134
 	        exit 77
137 135
         fi
138 136
     fi
... ...
@@ -172,7 +170,7 @@ for i in $(seq 0 $MAX_TEST); do
172 172
             exit 1
173 173
         fi
174 174
     done
175
-
175
+    echo "Test $i: OK"
176 176
 done
177 177
 
178 178
 # remove interface for good
... ...
@@ -185,6 +185,12 @@ main(int argc, char *argv[])
185 185
         return -1;
186 186
     }
187 187
 
188
+    /* the t_net script can use this command to perform a dry-run test */
189
+    if (strcmp(argv[1], "test") == 0)
190
+    {
191
+        return 0;
192
+    }
193
+
188 194
     if (argc > 3)
189 195
     {
190 196
         iface = argv[2];