From: "mattock (Code Review)" Date: Thu, 23 Jan 2025 14:08:46 +0000 In-Reply-To: References: Reply-To: samuli@...515..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., gert@...1296... Message-ID: <9d5494c70f567f972bd7266989b35f597388775c-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="h6pXzPKE3To="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Add lwip support to t_server_null List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , cron2 , flichtenheld Cc: openvpn-devel --h6pXzPKE3To= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: cron2, flichtenheld, plaisthos. Hello cron2, flichtenheld, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/811?usp=3Demail to look at the new patch set (#10). Change subject: Add lwip support to t_server_null ...................................................................... Add lwip support to t_server_null Change-Id: Ie63f302402f469c3aa48ac146ca6b8c029f0d250 Signed-off-by: Samuli Sepp=C3=A4nen --- M doc/t_server_null.rst A tests/lwip_client_up.sh M tests/t_server_null_client.sh M tests/t_server_null_default.rc 4 files changed, 163 insertions(+), 13 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/11/811/10 diff --git a/doc/t_server_null.rst b/doc/t_server_null.rst index 5fe9080..473a7bd 100644 --- a/doc/t_server_null.rst +++ b/doc/t_server_null.rst @@ -16,7 +16,7 @@ * Parallelized for fairly high performance * Mostly operating-system agnostic -* Tested on Fedora Linux 38/39/40 and FreeBSD 14 +* Tested on Fedora Linux 38/39/40, FreeBSD 14, NetBSD 10.0 and OpenBSD 7.5 * POSIX-compliant * Tested and known to work with Bash, Dash, Ksh, Yash and FreeBSD's defaul= t /bin/sh * Uses the sample certificates and keys @@ -31,6 +31,7 @@ * Test cases (client configurations) and server setups (server configurati= ons) are stored in a configuration file, i.e. data and code have been separ= ated * Configuration file format is nearly identical to t_client.rc configurati= on * Supports a set of default tests, overriding default test settings and ad= ding local tests +* Supports client ping tests if ovpnlwip is available Prerequisites ------------- @@ -60,8 +61,9 @@ #. Server instances start #. Brief wait #. Client instances start -#. Tests run +#. ovpnlwip ping tests run #. Client instances stop +#. Test results are collected #. Brief wait #. Server instances stop @@ -77,7 +79,8 @@ * t_server_null_client.sh - * Waits until servers have launched. Then launch all clients, wait f= or them to exit and then check test results by parsing the client log files= . Each client kills itself after some delay using an "--up" script. + * Waits until servers have launched. Then launch all clients, run ov= pnlwip ping tests (if any), wait for clients to exit and then check test re= sults by parsing the client log files. Each client kills itself after some = delay using an "--up" script. + Configuration ------------- @@ -116,6 +119,19 @@ TEST_RUN_LIST=3D"1 2 5 9" +Client ping tests that use ovpnlwip can be added similarly: + + TEST_NAME_9L=3D"t_server_null_client.sh-openvpn_current_udp_custom_lwip" + SHOULD_PASS_9L=3D"yes" + CLIENT_EXEC_9L=3D"${CLIENT_EXEC}" + CLIENT_CONF_9L=3D"${CLIENT_CONF_BASE_LWIP} --remote 127.0.0.1 1194 udp -= -proto udp" + +Note that all ovpnlwip test names need to include a "_lwip" suffix: withou= t it +ping tests won't get activated. Also note that the *tests* directory needs= to +have the lwipovpn executable or ovpnlwip tests will get skipped. The ovpnl= wip +ping tests get the IP addresses to ping from the \*.ips files created by t= he +lwip_client_up.sh script --up script. + Stress-testing the --dev null test suite ---------------------------------------- diff --git a/tests/lwip_client_up.sh b/tests/lwip_client_up.sh new file mode 100755 index 0000000..a6b4d24 --- /dev/null +++ b/tests/lwip_client_up.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# +# Determine the OpenVPN PID from its pid file. This works reliably even wh= en +# the OpenVPN process is backgrounded for parallel tests. +MY_PPID=3D`cat $pid` + +# Add this client's VPN IP and PID to a file. This enables +# t_server_null_client.sh to kill this OpenVPN client after fping tests ha= ve +# finished. +echo "$ifconfig_local,$MY_PPID" >> ./$test_name.lwip + +# Wait long enough to allow fping tests to finish. Also ensure that this +# OpenVPN client is killed even if t_server_null_client.sh failed to do it. +(sleep 15 +echo "ERROR: t_server_null_client.sh failed to kill OpenVPN client with PI= D $MY_PPID in test $test_name. Killing it in lwip_client_up.sh." +kill -15 $MY_PPID +) & diff --git a/tests/t_server_null_client.sh b/tests/t_server_null_client.sh index 2210e63..1745de5 100755 --- a/tests/t_server_null_client.sh +++ b/tests/t_server_null_client.sh @@ -1,5 +1,17 @@ #!/bin/sh +should_run_test() { + test_name=3D"$1" + + if echo "$test_name"|grep -q _lwip; then + if [ "$has_lwipovpn" =3D "no" ]; then + return 1 + fi + fi + + return 0 +} + launch_client() { test_name=3D$1 log=3D"${test_name}.log" @@ -13,10 +25,65 @@ "${client_exec}" \ $client_conf \ --writepid "${pid}" \ - --setenv pid $pid \ + --setenv pid "$pid" \ + --setenv test_name "$test_name" \ --log "${t_server_null_logdir}/${log}" & } +ping_and_kill() { + if fping -q -c 5 $1; then + echo "PASS: fping lwipovpn client $target" + else + echo "FAIL: fping lwipovpn client $target" + + # This function runs multiple times in parallel in subshells. That + # makes it hard to implement "fail the test suite if any single fp= ing + # test fails" using exit codes or variables given the limitations = of + # "wait". Therefore we use a marker file here, which solves the + # problem trivially. + touch ./lwip_failed + fi + kill -15 $2 +} + +ping_lwip_clients() { + if [ "$has_lwipovpn" =3D "yes" ]; then + lwip_client_count=3D$(echo "$lwip_test_names"|wc -w|tr -d " ") + else + lwip_client_count=3D0 + fi + + if [ $lwip_client_count -eq 0 ]; then + return 0 + fi + + count=3D0 + maxcount=3D10 + while [ $count -le $maxcount ]; do + lwip_client_ips=3D$(cat ./*.lwip 2>/dev/null|wc -l) + if [ $lwip_client_ips -lt $lwip_client_count ]; then + echo "Waiting for LWIP clients to start up ($count/$maxcount)" + count=3D$(( count + 1)) + sleep 1 + else + echo "$lwip_client_ips/$lwip_client_count LWIP clients up" + break + fi + done + + wait_pids=3D"" + for line in $(cat ./*.lwip 2>/dev/null); do + target_ip=3D$(echo $line|cut -d "," -f 1) + client_pid=3D$(echo $line|cut -d "," -f 2) + ping_and_kill $target_ip $client_pid & + wait_pids=3D"$wait_pids $!" + done + + wait $wait_pids + + test -e ./lwip_failed && return 1 || return 0 +} + wait_for_results() { tests_running=3D"yes" @@ -77,7 +144,7 @@ server_max_wait=3D15 while [ $count -lt $server_max_wait ]; do servers_up=3D0 - server_count=3D$(echo $TEST_SERVER_LIST|wc -w) + server_count=3D$(echo "$TEST_SERVER_LIST"|wc -w|tr -d " ") =20 # We need to trim single-quotes because some shells return quoted valu= es # and some don't. Using "set -o posix" which would resolve this proble= m is @@ -85,8 +152,8 @@ # # While inactive server configurations may get checked they won't incr= ease # the active server count as the processes won't be running. - for i in `set|grep 'SERVER_NAME_'|cut -d "=3D" -f 2|tr -d "[\']"`; do - server_pid=3D$(cat $i.pid 2> /dev/null) + for i in $(set|grep 'SERVER_NAME_'|cut -d "=3D" -f 2|tr -d "[\']"); do + server_pid=3D$(cat "$i.pid" 2> /dev/null) if [ -z "$server_pid" ] ; then continue fi @@ -111,6 +178,19 @@ fi done +# Check for presence of the lwipovpn executable +if test -r "$LWIPOVPN_PATH"; then + has_lwipovpn=3D"yes" +else + has_lwipovpn=3D"no" + echo "WARNING: lwipovpn executable is missing: lwip tests will be skip= ped" +fi + +# Remove existing LWIP client IP files. This is to avoid pinging non-exist= ent +# IP addresses when tests are disabled. +rm -f ./*.lwip +rm -f ./lwip_failed + # Wait a while to let server processes to settle down sleep 1 @@ -118,6 +198,7 @@ # is used later to determine when all OpenVPN clients have exited and it is # safe to check the test results. test_names=3D"" +lwip_test_names=3D"" for SUF in $TEST_RUN_LIST do eval test_name=3D\"\$TEST_NAME_$SUF\" @@ -125,9 +206,20 @@ eval client_conf=3D\"\$CLIENT_CONF_$SUF\" test_names=3D"${test_names} ${test_name}" - (launch_client "${test_name}" "${client_exec}" "${client_conf}") + + if echo "$test_name"|grep -q _lwip; then + lwip_test_names=3D"${lwip_test_names} ${test_name}" + fi + + if should_run_test "$test_name"; then + (launch_client "${test_name}" "${client_exec}" "${client_conf}") + fi done +ping_lwip_clients +retval=3D$? + + # Wait until all OpenVPN clients have exited (wait_for_results) @@ -137,7 +229,9 @@ eval test_name=3D\"\$TEST_NAME_$SUF\" eval should_pass=3D\"\$SHOULD_PASS_$SUF\" - get_client_test_result "${test_name}" "${should_pass}" + if should_run_test "$test_name"; then + get_client_test_result "${test_name}" "${should_pass}" + fi done exit $retval diff --git a/tests/t_server_null_default.rc b/tests/t_server_null_default.rc index cbf4877..e7bf5bc 100755 --- a/tests/t_server_null_default.rc +++ b/tests/t_server_null_default.rc @@ -20,6 +20,15 @@ SERVER_KEY=3D"${sample_keys}/server.key" TA=3D"${sample_keys}/ta.key" +# This parameter can't be overridden in t_server_null.rc because that gets +# loaded too late. However, you can use +# +# LWIPOVPN_PATH=3D/some/path/to/lwipovpn make check +# +# to run the tests using lwipovpn in a custom location +# +LWIPOVPN_PATH=3D"${LWIPOVPN_PATH:-lwipovpn}" + # Used to detect if graceful kill of any server instance failed during the= test # run SERVER_KILL_FAIL_FILE=3D".t_server_null_server.kill_failed" @@ -28,7 +37,7 @@ MAX_CLIENTS=3D"10" CLIENT_MATCH=3D"Test-Client" SERVER_EXEC=3D"${top_builddir}/src/openvpn/openvpn" -SERVER_BASE_OPTS=3D"--daemon --local 127.0.0.1 --dev tun --topology subnet= --max-clients $MAX_CLIENTS --persist-tun --verb 3" +SERVER_BASE_OPTS=3D"--daemon --local 127.0.0.1 --dev tun --topology subnet= --max-clients $MAX_CLIENTS --persist-tun --verb 3 --duplicate-cn" SERVER_CIPHER_OPTS=3D"" SERVER_CERT_OPTS=3D"--ca ${CA} --dh ${DH} --cert ${SERVER_CERT} --key ${SE= RVER_KEY} --tls-auth ${TA} 0" SERVER_CONF_BASE=3D"${SERVER_BASE_OPTS} ${SERVER_CIPHER_OPTS} ${SERVER_CER= T_OPTS}" @@ -49,23 +58,37 @@ # Test client configurations CLIENT_EXEC=3D"${top_builddir}/src/openvpn/openvpn" -CLIENT_BASE_OPTS=3D"--client --dev null --ifconfig-noexec --nobind --remot= e-cert-tls server --persist-tun --verb 3 --resolv-retry infinite --connect-= retry-max 3 --server-poll-timeout 5 --explicit-exit-notify 3 --script-secur= ity 2 --up ${srcdir}/null_client_up.sh" +CLIENT_BASE_OPTS=3D"--client --nobind --remote-cert-tls server --persist-t= un --verb 3 --resolv-retry infinite --connect-retry-max 3 --server-poll-tim= eout 5 --explicit-exit-notify 3 --script-security 2" +CLIENT_NULL_OPTS=3D"--dev null --ifconfig-noexec --up ${srcdir}/null_clien= t_up.sh" +CLIENT_LWIP_OPTS=3D"--dev null --dev-node unix:${LWIPOVPN_PATH} --up ${src= dir}/lwip_client_up.sh" + CLIENT_CIPHER_OPTS=3D"" CLIENT_CERT_OPTS=3D"--ca ${CA} --cert ${CLIENT_CERT} --key ${CLIENT_KEY} -= -tls-auth ${TA} 1" -TEST_RUN_LIST=3D"1 2 3" -CLIENT_CONF_BASE=3D"${CLIENT_BASE_OPTS} ${CLIENT_CIPHER_OPTS} ${CLIENT_CER= T_OPTS}" +TEST_RUN_LIST=3D"1 1L 2 2L 3" +CLIENT_CONF_BASE=3D"${CLIENT_NULL_OPTS} ${CLIENT_BASE_OPTS} ${CLIENT_CIPHE= R_OPTS} ${CLIENT_CERT_OPTS}" +CLIENT_CONF_BASE_LWIP=3D"${CLIENT_LWIP_OPTS} ${CLIENT_BASE_OPTS} ${CLIENT_= CIPHER_OPTS} ${CLIENT_CERT_OPTS}" TEST_NAME_1=3D"t_server_null_client.sh-openvpn_current_udp" SHOULD_PASS_1=3D"yes" CLIENT_EXEC_1=3D"${CLIENT_EXEC}" CLIENT_CONF_1=3D"${CLIENT_CONF_BASE} --remote 127.0.0.1 1194 udp --proto u= dp" +TEST_NAME_1L=3D"t_server_null_client.sh-openvpn_current_udp_lwip" +SHOULD_PASS_1L=3D"yes" +CLIENT_EXEC_1L=3D"${CLIENT_EXEC}" +CLIENT_CONF_1L=3D"${CLIENT_CONF_BASE_LWIP} --remote 127.0.0.1 1194 udp --p= roto udp" + TEST_NAME_2=3D"t_server_null_client.sh-openvpn_current_tcp" SHOULD_PASS_2=3D"yes" CLIENT_EXEC_2=3D"${CLIENT_EXEC}" CLIENT_CONF_2=3D"${CLIENT_CONF_BASE} --remote 127.0.0.1 1195 tcp --proto t= cp" +TEST_NAME_2L=3D"t_server_null_client.sh-openvpn_current_tcp_lwip" +SHOULD_PASS_2L=3D"yes" +CLIENT_EXEC_2L=3D"${CLIENT_EXEC}" +CLIENT_CONF_2L=3D"${CLIENT_CONF_BASE_LWIP} --remote 127.0.0.1 1195 tcp --p= roto tcp" + TEST_NAME_3=3D"t_server_null_client.sh-openvpn_current_udp_fail" SHOULD_PASS_3=3D"no" CLIENT_EXEC_3=3D"${CLIENT_EXEC}" -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/811?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ie63f302402f469c3aa48ac146ca6b8c029f0d250 Gerrit-Change-Number: 811 Gerrit-PatchSet: 10 Gerrit-Owner: mattock Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: cron2 Gerrit-Attention: flichtenheld Gerrit-MessageType: newpatchset --h6pXzPKE3To= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: cron2, flichtenheld, plaisthos. <= /p>

mattock uploaded patch set #10 to this change.

View Change=

Add lwip support to t_server_null

Change-Id: Ie63f302402f469c3a= a48ac146ca6b8c029f0d250
Signed-off-by: Samuli Sepp=C3=A4nen <samuli.s= eppanen@...277...>
---
M doc/t_server_null.rst
A tests/lwip_cli= ent_up.sh
M tests/t_server_null_client.sh
M tests/t_server_null_defau= lt.rc
4 files changed, 163 insertions(+), 13 deletions(-)

<= pre style=3D"font-family: monospace,monospace; white-space: pre-wrap;">git = pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/11/811/10= diff --git a/doc/t_server_null.rst b/doc/t_server_null.rst
= index 5fe9080..473a7bd 100644
--- a/doc/t_server_null.rst
+++ b/doc/t_server_null.rst
@@ -16,7 +16,7 @= @

* Parallelized for fairly high perform= ance
* Mostly operating-system agnostic
-* Tested on Fedora Linux 38/39/40 and Fr= eeBSD 14
+* Tested on= Fedora Linux 38/39/40, FreeBSD 14, NetBSD 10.0 and OpenBSD 7.5
<= span> * POSIX-compliant

* Tested and known to work with Ba= sh, Dash, Ksh, Yash and FreeBSD's default /bin/sh
* Us= es the sample certificates and keys
@@ -31,6 +31,7 @@
* Test cases (client configurations) and server setups (server = configurations) are stored in a configuration file, i.e. data and code have= been separated
* Configuration file format is nearly iden= tical to t_client.rc configuration
* Supports a set of def= ault tests, overriding default test settings and adding local tests<= br>+* Supports client ping test= s if ovpnlwip is available

Prerequisites=
-------------
@@ -60,8 +61,9 @@ #. Server instances start
#. Brief wait
= #. Client instances start
-#. Tests run
+#. ovpnlwip ping tests run
#. Client instances stop
+#. Test results are co= llected
#. Brief wait
#. Server instances= stop

@@ -77,7 +79,8 @@
=
* t_server_null_client.sh
- * Waits until servers hav= e launched. Then launch all clients, wait for them to exit and then check t= est results by parsing the client log files. Each client kills itself after= some delay using an "--up" script.
+ * Waits until servers have launched. Then l= aunch all clients, run ovpnlwip ping tests (if any), wait for clients to ex= it and then check test results by parsing the client log files. Each client= kills itself after some delay using an "--up" script.
= +

<= span> Configuration

-------------
@@ -116,= 6 +119,19 @@

TEST_RUN_LIST=3D"1 2= 5 9"

+Client ping tests that use ovpnlwip can be added similarly:=
+
+ TEST_NAME_9L=3D"t_server_null_client.s= h-openvpn_current_udp_custom_lwip"
+ SHOULD_PASS_9L=3D"yes"
+ CLIENT_EXEC_9L=3D"${CLIENT_EXEC}&= quot;
+ CLIENT_CONF_= 9L=3D"${CLIENT_CONF_BASE_LWIP} --remote 127.0.0.1 1194 udp --proto udp= "
+
+Note that all ovpnlwip test name= s need to include a "_lwip" suffix: without it

+ping tests won't get activated. Al= so note that the *tests* directory needs to
+have the lwipovpn executable or ovpnlwip tests will= get skipped. The ovpnlwip
+ping tests get the IP addresses to ping from the \*.ips files create= d by the
+lwip_client= _up.sh script --up script.
+
Stress-testing the --dev null test suite ----------------------------------------
diff --git a/tests/lwip_client_up.sh b/tests/lwip_client_up.sh
new file mode 100755
index 0000000..a6b4d24
--- /dev/null
+++ b/tests/lwip_client_up.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
= +#
+# Determine the O= penVPN PID from its pid file. This works reliably even when
+# the OpenVPN process is background= ed for parallel tests.

+
+# Add this clie= nt's VPN IP and PID to a file. This enables
+# t_server_null_client.sh to kill this OpenVPN = client after fping tests have
+# finished.
+echo "$ifconfig_local,$MY_PPID" >> ./$test_name.lwip
+
+# Wait long enough to allow fping tests t= o finish. Also ensure that this
+# OpenVPN client is killed even if t_server_null_client.sh fail= ed to do it.
+(sleep = 15
+echo "ERROR:= t_server_null_client.sh failed to kill OpenVPN client with PID $MY_PPID in= test $test_name. Killing it in lwip_client_up.sh."
+kill -15 $MY_PPID
+) &
diff --git a/tes= ts/t_server_null_client.sh b/tests/t_server_null_client.sh
= index 2210e63..1745de5 100755
--- a/tests/t_server_null_cli= ent.sh
+++ b/tests/t_server_null_client.sh
= @@ -1,5 +1,17 @@
#!/bin/sh

+should_run_test() {

+ test_name=3D"$1"
+
+ if echo "$test_name"|grep -= q _lwip; then
+ = if [ "$has_lwipovpn" =3D "no" ]; then
+ return 1

+ fi

+ fi
+
+ return 0
+}
+
launc= h_client() {
test_name=3D$1
log= =3D"${test_name}.log"
@@ -13,10 +25,65 @@<= br> "${client_exec}" \
$client= _conf \
--writepid "${pid}" \
= - --setenv pid $pid \
+ --setenv pid &qu= ot;$pid" \
+ = --setenv test_name "$test_name" \
--= log "${t_server_null_logdir}/${log}" &
}

+ping_= and_kill() {
+ if = fping -q -c 5 $1; then
+ else
+ echo "FAIL: fping lwipovpn c= lient $target"
+=
+ # This func= tion runs multiple times in parallel in subshells. That
+ # makes it hard to implement &q= uot;fail the test suite if any single fping
+ # test fails" using exit codes or vari= ables given the limitations of
+ # "wait". Therefore we use a marker file here= , which solves the
+ = # problem trivially.
+ touch ./lwip_failed
+ fi
+}=
+
+ping_lwip_clients() {
+ if [ "$has_lwipovpn" = =3D "yes" ]; then
+ lwip_client_count=3D$(echo "$lwip_test_names"|wc = -w|tr -d " ")
+ else
+ = lwip_client_count=3D0
++ if [ $lwip_client_count -= eq 0 ]; then
+ = return 0
+ fi
+
+ count=3D0
+ maxcount=3D10
+ while [ $count -le $maxcount ]; do
= + lwip_client_ips=3D$(ca= t ./*.lwip 2>/dev/null|wc -l)
+ if [ $lwip_client_ips -lt $lwip_client_count ]; then
+ echo &quo= t;Waiting for LWIP clients to start up ($count/$maxcount)"
<= span style=3D"color: hsl(120, 100%, 40%);">+ count=3D$(( count += 1))

+ sle= ep 1
+ else
+ echo "= ;$lwip_client_ips/$lwip_client_count LWIP clients up"
+ break
+ fi
+ done
+
+ = wait_pids=3D""
+ for line in $(cat ./*.lwip 2>/dev/null); do
+ target_ip=3D$(echo $line|cut = -d "," -f 1)
+ ping_and_kill $target_i= p $client_pid &
+= wait_pids=3D"$wait_pids $!"
+ done
+
+ = wait $wait_pids
+
+ test -e ./lwip_fail= ed && return 1 || return 0
+}
+
wait_for_results() {
tests_running=3D&q= uot;yes"

@@ -77,7 +144,7 @@ server_max_wait=3D15
while [ $count -lt $server_m= ax_wait ]; do
servers_up=3D0
- server_count=3D$(echo $TEST_SERVER_LIST|wc = -w)
+ server_count= =3D$(echo "$TEST_SERVER_LIST"|wc -w|tr -d " ")
# We need to trim single-quotes because some= shells return quoted values
# and some don't. Usi= ng "set -o posix" which would resolve this problem is
<= span>@@ -85,8 +152,8 @@

#
# While= inactive server configurations may get checked they won't increase
# the active server count as the processes won't be r= unning.
- for i in `= set|grep 'SERVER_NAME_'|cut -d "=3D" -f 2|tr -d "[\&= #39;]"`; do
- = server_pid=3D$(cat $i.pid 2> /dev/null)
+ for i in $(set|grep 'SERVER_NAME_'|cu= t -d "=3D" -f 2|tr -d "[\']"); do
+ server_pid=3D$(cat "$i.p= id" 2> /dev/null)
if [ -z "$server_pi= d" ] ; then
continue
= fi
@@ -111,6 +178,19 @@
fi=
done

+# Check for presence of the lwipovpn executable
+if test -r "$LWIPOVPN_PATH&q= uot;; then

+ has_l= wipovpn=3D"yes"
+else
+ has_l= wipovpn=3D"no"
+ echo "WARNING: lwipovpn executable is missing: lwip tests wil= l be skipped"
+f= i
+
+# Remove existing LWIP client IP file= s. This is to avoid pinging non-existent
+# IP addresses when tests are disabled.
+rm -f ./*.lwip

+rm -f ./lwip_failed
+
# Wait a while to let= server processes to settle down
sleep 1
=
@@ -118,6 +198,7 @@
# is used later to de= termine when all OpenVPN clients have exited and it is
# s= afe to check the test results.
test_names=3D""
+lwip_test_names=3D&qu= ot;"
for SUF in $TEST_RUN_LIST
do
eval test_name=3D\"\$TEST_NAME_$SUF\"@@ -125,9 +206,20 @@
eval client_conf=3D\"= ;\$CLIENT_CONF_$SUF\"

test_name= s=3D"${test_names} ${test_name}"
- (launch_client "${test_name}" "${cl= ient_exec}" "${client_conf}")
+
+ if echo "$test_name"|grep -q _lwip; then
+ lwip_test_names=3D"${= lwip_test_names} ${test_name}"

+ fi
+ if should_ru= n_test "$test_name"; then
+ (launch_client "${test_name}" "${cli= ent_exec}" "${client_conf}")
+ fi
done

+ping_lwip_clients=
+retval=3D$?
+

+
# Wait until all OpenVPN clients ha= ve exited
(wait_for_results)

<= span>@@ -137,7 +229,9 @@

eval test_name=3D\"\$TES= T_NAME_$SUF\"
eval should_pass=3D\"\$SHOULD_= PASS_$SUF\"

- get_client_test_result "${test_name}" "${sh= ould_pass}"
+ = if should_run_test "$test_name"; then
+ get_client_test_result "${test_na= me}" "${should_pass}"
+ fi
done

<= span> exit $retval

diff --git a/tests/t_server_null_default= .rc b/tests/t_server_null_default.rc
index cbf4877..e7bf5bc= 100755
--- a/tests/t_server_null_default.rc
+++ b/tests/t_server_null_default.rc

@@ -20,6 +20,15 @@
SERVER_KEY=3D"${sample_keys}/server.key" TA=3D"${sample_keys}/ta.key"
+# This parameter can't be= overridden in t_server_null.rc because that gets
+# loaded too late. However, you can use
+#
+# LWIPOVPN_PATH=3D/some/path/to/lwipovpn = make check
+#<= br>+# to run the tests using lw= ipovpn in a custom location
+#
+LWIPOVPN_P= ATH=3D"${LWIPOVPN_PATH:-lwipovpn}"
+
# Used to detect if graceful kil= l of any server instance failed during the test
# run
SERVER_KILL_FAIL_FILE=3D".t_server_null_server.kill_faile= d"
@@ -28,7 +37,7 @@
MAX_CLIENTS=3D&q= uot;10"
CLIENT_MATCH=3D"Test-Client"=
SERVER_EXEC=3D"${top_builddir}/src/openvpn/openvpn"
-SERVER_BASE_OPTS=3D"= ;--daemon --local 127.0.0.1 --dev tun --topology subnet --max-clients $MAX_= CLIENTS --persist-tun --verb 3"
+SERVER_BASE_OPTS=3D"--daemon --local 127.0.0.1 --dev = tun --topology subnet --max-clients $MAX_CLIENTS --persist-tun --verb 3 --d= uplicate-cn"
SERVER_CIPHER_OPTS=3D""=
SERVER_CERT_OPTS=3D"--ca ${CA} --dh ${DH} --cert ${SERVER_C= ERT} --key ${SERVER_KEY} --tls-auth ${TA} 0"
SERVER_C= ONF_BASE=3D"${SERVER_BASE_OPTS} ${SERVER_CIPHER_OPTS} ${SERVER_CERT_OP= TS}"
@@ -49,23 +58,37 @@

<= span> # Test client configurations

CLIENT_EXEC=3D"${t= op_builddir}/src/openvpn/openvpn"
-CLIENT_BASE_OPTS=3D"--client --dev null --ifconfig-no= exec --nobind --remote-cert-tls server --persist-tun --verb 3 --resolv-retr= y infinite --connect-retry-max 3 --server-poll-timeout 5 --explicit-exit-no= tify 3 --script-security 2 --up ${srcdir}/null_client_up.sh"+CLIENT_BASE_OPTS=3D"--cl= ient --nobind --remote-cert-tls server --persist-tun --verb 3 --resolv-retr= y infinite --connect-retry-max 3 --server-poll-timeout 5 --explicit-exit-no= tify 3 --script-security 2"
+CLIENT_NULL_OPTS=3D"--dev null --ifconfig-noexec --up ${s= rcdir}/null_client_up.sh"
+CLIENT_LWIP_OPTS=3D"--dev null --dev-node unix:${LWIPOVPN_P= ATH} --up ${srcdir}/lwip_client_up.sh"
+
CLIENT_CIPHER_OPTS=3D""=
CLIENT_CERT_OPTS=3D"--ca ${CA} --cert ${CLIENT_CERT}= --key ${CLIENT_KEY} --tls-auth ${TA} 1"

<= span style=3D"color: hsl(0, 100%, 40%);">-TEST_RUN_LIST=3D"1 2 3"=

-CLIENT_CONF_BASE=3D&q= uot;${CLIENT_BASE_OPTS} ${CLIENT_CIPHER_OPTS} ${CLIENT_CERT_OPTS}"
+TEST_RUN_LIST=3D"1= 1L 2 2L 3"
+CLI= ENT_CONF_BASE=3D"${CLIENT_NULL_OPTS} ${CLIENT_BASE_OPTS} ${CLIENT_CIPH= ER_OPTS} ${CLIENT_CERT_OPTS}"
+CLIENT_CONF_BASE_LWIP=3D"${CLIENT_LWIP_OPTS} ${CLIENT_B= ASE_OPTS} ${CLIENT_CIPHER_OPTS} ${CLIENT_CERT_OPTS}"
=
TEST_NAME_1=3D"t_server_null_client.sh-openvpn_curre= nt_udp"
SHOULD_PASS_1=3D"yes"
CLIENT_EXEC_1=3D"${CLIENT_EXEC}"

CLIENT_CONF= _1=3D"${CLIENT_CONF_BASE} --remote 127.0.0.1 1194 udp --proto udp"= ;

+= TEST_NAME_1L=3D"t_server_null_client.sh-openvpn_current_udp_lwip"=
+SHOULD_PASS_1L=3D&q= uot;yes"
+CLIENT= _EXEC_1L=3D"${CLIENT_EXEC}"
+CLIENT_CONF_1L=3D"${CLIENT_CONF_BASE_LWIP} --remote = 127.0.0.1 1194 udp --proto udp"
+
TEST_NAME_2=3D"t_server_null_client= .sh-openvpn_current_tcp"
SHOULD_PASS_2=3D"yes&qu= ot;
CLIENT_EXEC_2=3D"${CLIENT_EXEC}"
<= span> CLIENT_CONF_2=3D"${CLIENT_CONF_BASE} --remote 127.0.0.1 1195 tcp= --proto tcp"


+TEST_NAME_2L=3D"t_server_null_client.sh-openvpn_curre= nt_tcp_lwip"
+SH= OULD_PASS_2L=3D"yes"
+CLIENT_EXEC_2L=3D"${CLIENT_EXEC}"
+CLIENT_CONF_2L=3D"${CLIENT_CONF_BAS= E_LWIP} --remote 127.0.0.1 1195 tcp --proto tcp"
+
TEST_NAME_3=3D"t_s= erver_null_client.sh-openvpn_current_udp_fail"
SHOULD= _PASS_3=3D"no"
CLIENT_EXEC_3=3D"${CLIENT_EX= EC}"

To view, visit change 811. To unsu= bscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie63f302402f469c3aa48ac146ca= 6b8c029f0d250
Gerrit-Change-Number: 811
Gerrit-PatchSet: 10
Gerrit-Owner: mattock <samuli@...515...>=
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: cron2 <gert@...1296...>= ;
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newpatchset
--h6pXzPKE3To=--