Change in openvpn[master]: t_client.sh: Allow to skip tests
A message that is not in the archive (sent off-list or not yet received): gerrit.1707835634000.I13ea6752c8d102eabcc579e391828c05d5322899@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
to review the following change.
Change subject: t_client.sh: Allow to skip tests
......................................................................
t_client.sh: Allow to skip tests
Individual tests can define a script to run to test whether they should be skipped.
Included in this commit is an example check which checks whether we can do NTLM checks. This fails e.g. on recent versions of Fedora with mbedTLS (tested with Fedora 39) or when NTLM support is not compiled in.
---
M tests/Makefile.am
A tests/ntlm_support.c
M tests/t_client.sh.in
3 files changed, 76 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/21/521/1
tests/Makefile.am +14 -0
@@ -19,6 +19,8 @@ if !WIN32 test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh + +check_PROGRAMS = ntlm_support if HAVE_SITNL test_scripts += t_net.sh endif
@@ -36,3 +38,15 @@ dist_noinst_DATA = \ t_client.rc-sample + +ntlm_support_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat -I$(top_srcdir)/tests/unit_tests/openvpn @TEST_CFLAGS@ +ntlm_support_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn $(OPTIONAL_CRYPTO_LIBS) +ntlm_support_SOURCES = ntlm_support.c \ + unit_tests/openvpn/mock_msg.c unit_tests/openvpn/mock_msg.h \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/crypto.c \ + $(top_srcdir)/src/openvpn/crypto_openssl.c \ + $(top_srcdir)/src/openvpn/crypto_mbedtls.c \ + $(top_srcdir)/src/openvpn/otime.c \ + $(top_srcdir)/src/openvpn/packet_id.c \ + $(top_srcdir)/src/openvpn/platform.c
tests/ntlm_support.c new file +49 -0
49 lines not on this page · raw message
tests/t_client.sh.in +13 -0
@@ -291,12 +291,14 @@ # main test loop # ---------------------------------------------------------- SUMMARY_OK= +SUMMARY_SKIP= SUMMARY_FAIL= for SUF in $TEST_RUN_LIST do # get config variables eval test_prep=\"\$PREPARE_$SUF\" + eval test_check_skip=\"\$SKIP_$SUF\" eval test_postinit=\"\$POSTINIT_CMD_$SUF\" eval test_cleanup=\"\$CLEANUP_$SUF\" eval test_run_title=\"\$RUN_TITLE_$SUF\"
@@ -318,6 +320,15 @@ output_start "### test run $SUF: '$test_run_title' ###" fail_count=0 + if [ -n "$test_check_skip" ]; then + output "check whether we need to skip: '$test_check_skip'" + eval $test_check_skip || { + output "skip check failed, SKIP test $SUF." + SUMMARY_SKIP="$SUMMARY_SKIP $SUF" + echo -e "$outbuf" ; continue + } + fi + if [ -n "$test_prep" ]; then output "running preparation: '$test_prep'" eval $test_prep
@@ -455,8 +466,10 @@ done if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi +if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi echo "Test sets succeeded:$SUMMARY_OK." +echo "Test sets skipped:$SUMMARY_SKIP." echo "Test sets failed:$SUMMARY_FAIL." # remove trap handler
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899
Gerrit-Change-Number: 521
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
to look at the new patch set (#2).
Change subject: t_client.sh: Allow to skip tests
......................................................................
t_client.sh: Allow to skip tests
Individual tests can define a script to run to test whether they should be skipped.
Included in this commit is an example check which checks whether we can do NTLM checks. This fails e.g. on recent versions of Fedora with mbedTLS (tested with Fedora 39) or when NTLM support is not compiled in.
v2:
- ntlm_support:
- support OpenSSL 3
- allow to build without cmocka
---
M src/openvpn/error.h
M tests/Makefile.am
A tests/ntlm_support.c
M tests/t_client.sh.in
M tests/unit_tests/openvpn/mock_msg.c
5 files changed, 94 insertions(+), 1 deletion(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/21/521/2
src/openvpn/error.h +3 -0
@@ -33,6 +33,9 @@#if _WIN32#include <windows.h> +#else +/* for _exit() */ +#include <unistd.h> #endif /* #define ABORT_ON_ERROR */
tests/Makefile.am +14 -0
@@ -19,6 +19,8 @@ if !WIN32 test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh + +check_PROGRAMS = ntlm_support if HAVE_SITNL test_scripts += t_net.sh endif
@@ -36,3 +38,15 @@ dist_noinst_DATA = \ t_client.rc-sample + +ntlm_support_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat -I$(top_srcdir)/tests/unit_tests/openvpn -DNO_CMOCKA @TEST_CFLAGS@ +ntlm_support_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn $(OPTIONAL_CRYPTO_LIBS) +ntlm_support_SOURCES = ntlm_support.c \ + unit_tests/openvpn/mock_msg.c unit_tests/openvpn/mock_msg.h \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/crypto.c \ + $(top_srcdir)/src/openvpn/crypto_openssl.c \ + $(top_srcdir)/src/openvpn/crypto_mbedtls.c \ + $(top_srcdir)/src/openvpn/otime.c \ + $(top_srcdir)/src/openvpn/packet_id.c \ + $(top_srcdir)/src/openvpn/platform.c
tests/ntlm_support.c new file +51 -0
51 lines not on this page · raw message
tests/t_client.sh.in +13 -0
@@ -291,12 +291,14 @@ # main test loop # ---------------------------------------------------------- SUMMARY_OK= +SUMMARY_SKIP= SUMMARY_FAIL= for SUF in $TEST_RUN_LIST do # get config variables eval test_prep=\"\$PREPARE_$SUF\" + eval test_check_skip=\"\$SKIP_$SUF\" eval test_postinit=\"\$POSTINIT_CMD_$SUF\" eval test_cleanup=\"\$CLEANUP_$SUF\" eval test_run_title=\"\$RUN_TITLE_$SUF\"
@@ -318,6 +320,15 @@ output_start "### test run $SUF: '$test_run_title' ###" fail_count=0 + if [ -n "$test_check_skip" ]; then + output "check whether we need to skip: '$test_check_skip'" + eval $test_check_skip || { + output "skip check failed, SKIP test $SUF." + SUMMARY_SKIP="$SUMMARY_SKIP $SUF" + echo -e "$outbuf" ; continue + } + fi + if [ -n "$test_prep" ]; then output "running preparation: '$test_prep'" eval $test_prep
@@ -455,8 +466,10 @@ done if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi +if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi echo "Test sets succeeded:$SUMMARY_OK." +echo "Test sets skipped:$SUMMARY_SKIP." echo "Test sets failed:$SUMMARY_FAIL." # remove trap handler
tests/unit_tests/openvpn/mock_msg.c +13 -1
@@ -31,8 +31,9 @@#include <stdlib.h> #include <setjmp.h> #include <stdint.h> +#ifndef NO_CMOCKA #include <cmocka.h> - +#endif #include "errlevel.h" #include "error.h"
@@ -74,6 +75,8 @@va_end (arglist); } +/* Allow to use mock_msg.c outside of UT */ +#ifndef NO_CMOCKA void assert_failed (const char *filename,int line,const char *condition) {
@@ -81,6 +84,15 @@/* Keep compiler happy. Should not happen, mock_assert() does not return */ exit(1); } +#else /* ifndef NO_CMOCKA */ +void +assert_failed (const char *filename,int line,const char *condition) +{ +msg (M_FATAL ,"Assertion failed at %s:%d (%s)" , filename, line, condition ? condition :"" ); +_exit (1 ); +} +#endif +/* * Fail memory allocation. Don't use msg() because it tries
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899
Gerrit-Change-Number: 521
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: flichtenheld, plaisthos.
ordex has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/521?usp=email )
Change subject: t_client.sh: Allow to skip tests
......................................................................
Patch Set 2:
(3 comments)
Patchset:
PS2:
Feature ACK. I like having the possibility to run tests only when needed/possible.
File tests/t_client.sh.in:
http://gerrit.openvpn.net/c/openvpn/+/521/comment/d0f81f67_ff0f5ae9 :
PS2, Line 301: SKIP_
I am probably clueless about this, but where is $SKIP filled?
File tests/unit_tests/openvpn/mock_msg.c:
http://gerrit.openvpn.net/c/openvpn/+/521/comment/9ff035ac_ffa92d48 :
PS2, Line 94: endif
I wonder if mock_msg.c is the right place for assert_failed(). Maybe it should just be moved somewhere else. opinions?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899
Gerrit-Change-Number: 521
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 21 Feb 2024 09:16:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: ordex, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/521?usp=email )
Change subject: t_client.sh: Allow to skip tests
......................................................................
Patch Set 2:
(2 comments)
File tests/t_client.sh.in:
http://gerrit.openvpn.net/c/openvpn/+/521/comment/c1be2335_8f5e8256 :
PS2, Line 301: SKIP_
Quoted 1 line
I am probably clueless about this, but where is $SKIP filled?
Like all the other test settings this is defined in the t_client.rc. I can add an example to t_client.rc-sample
File tests/unit_tests/openvpn/mock_msg.c:
http://gerrit.openvpn.net/c/openvpn/+/521/comment/0cb16f2d_9efcdae7 :
PS2, Line 94: endif
Quoted 1 line
I wonder if
mock_msg.cis the right place forassert_failed(). […]
assert_failed is defined in error.c like all the other functions mocked here, so it seems like a natural place.
The alternatives I saw for my patch were:
- duplicate mock_msg.c outside of unit_tests/openvpn. But except for assert_failed this works perfectly fine.
- try to use original error.c. But that pulls in a lot of platform code. We could look into split out all the complex msg stuff from error.c into its own msg.c. Then we could use error.c in the tests and mock less stuff here.
- move assert_failed to its own mock_assert.c. The current solution seems slightly simpler. But that would obviously be a possible alternative if we don't like the NO_CMOCKA define.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899
Gerrit-Change-Number: 521
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Wed, 21 Feb 2024 10:47:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: ordex <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/521?usp=email )
Change subject: t_client.sh: Allow to skip tests
......................................................................
Patch Set 2: Code-Review-1
(5 comments)
Patchset:
PS2:
I think this is a useful patch but there seems to be a bit of friction to overcome :-)
File src/openvpn/error.h:
http://gerrit.openvpn.net/c/openvpn/+/521/comment/509f59c6_11cebc44 :
PS2, Line 39: #endif
I don't like this, for two reasons - we protect unistd.h via HAVE_UNISTD_H, not via "not windows", and also this is really a separate project, moving out includes from "syshead.h" to the parent C file because some compilers complain.
File tests/t_client.sh.in:
http://gerrit.openvpn.net/c/openvpn/+/521/comment/4d712547_a890cc8a :
PS2, Line 301: SKIP_
Quoted 1 line
Like all the other test settings this is defined in the t_client.rc. […]
Having an example would certainly help people setting this up for their first time.
http://gerrit.openvpn.net/c/openvpn/+/521/comment/71a3de91_936dd75e :
PS2, Line 325: eval $test_check_skip || {
while this certainly works, the || { style is quite different from the very traditional if/then/fi style of the rest of the script. So I'm a bit undecided what to think about it.
```
if eval $test_check_skip ; then :
else
output ...
...
fi
```is not as compact, but might be easier to grok?
File tests/unit_tests/openvpn/mock_msg.c:
http://gerrit.openvpn.net/c/openvpn/+/521/comment/4daebdcf_1d3501b2 :
PS2, Line 94: endif
Quoted 1 line
assert_failedis defined in error. […]
Not sure I understand why we have cmocka specific .c files with #ifdef NO_CMOCKA? Is this ever used outside the unit test context?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899
Gerrit-Change-Number: 521
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Wed, 28 Feb 2024 10:01:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: ordex <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, ordex, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/521?usp=email )
Change subject: t_client.sh: Allow to skip tests
......................................................................
Patch Set 2:
(4 comments)
File src/openvpn/error.h:
http://gerrit.openvpn.net/c/openvpn/+/521/comment/79ea4054_64ee021d :
PS2, Line 39: #endif
Quoted 1 line
I don't like this, for two reasons - we protect unistd. […]
Acknowledged
File tests/t_client.sh.in:
http://gerrit.openvpn.net/c/openvpn/+/521/comment/d9c095ee_2955765a :
PS2, Line 301: SKIP_
Quoted 1 line
Having an example would certainly help people setting this up for their first time.
Acknowledged
http://gerrit.openvpn.net/c/openvpn/+/521/comment/df742960_4d92cd9b :
PS2, Line 325: eval $test_check_skip || {
Quoted 1 line
while this certainly works, the
|| {style is quite different from the very traditional `if/then/f […]
Acknowledged
File tests/unit_tests/openvpn/mock_msg.c:
http://gerrit.openvpn.net/c/openvpn/+/521/comment/91fc1e95_73420afd :
PS2, Line 94: endif
Quoted 1 line
Not sure I understand why we have cmocka specific . […]
Yes, in this PR it is now used in t_client context, which is not a unit test context
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899
Gerrit-Change-Number: 521
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Wed, 28 Feb 2024 13:36:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: ordex <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, ordex, plaisthos.
Hello cron2, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
to look at the new patch set (#3).
The following approvals got outdated and were removed:
Code-Review-1 by cron2
Change subject: t_client.sh: Allow to skip tests
......................................................................
t_client.sh: Allow to skip tests
Individual tests can define a script to run to test whether they should be skipped.
Included in this commit is an example check which checks whether we can do NTLM checks. This fails e.g. on recent versions of Fedora with mbedTLS (tested with Fedora 39) or when NTLM support is not compiled in.
v2:
- ntlm_support:
- support OpenSSL 3
- allow to build without cmocka
v3:
- add example to t_client.rc-sample
- t_client.sh code style
- use syshead.h in error.h
---
M src/openvpn/error.h
M tests/Makefile.am
A tests/ntlm_support.c
M tests/t_client.rc-sample
M tests/t_client.sh.in
M tests/unit_tests/openvpn/mock_msg.c
6 files changed, 119 insertions(+), 17 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/21/521/3
src/openvpn/error.h +1 -9
@@ -25,15 +25,7 @@#define ERROR_H #include "basic.h" - -#include <errno.h> -#include <stdbool.h> - -#include <assert.h> - -#if _WIN32 -#include <windows.h> -#endif +#include "syshead.h" /* #define ABORT_ON_ERROR */
tests/Makefile.am +14 -0
@@ -19,6 +19,8 @@ if !WIN32 test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh + +check_PROGRAMS = ntlm_support if HAVE_SITNL test_scripts += t_net.sh endif
@@ -36,3 +38,15 @@ dist_noinst_DATA = \ t_client.rc-sample + +ntlm_support_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat -I$(top_srcdir)/tests/unit_tests/openvpn -DNO_CMOCKA @TEST_CFLAGS@ +ntlm_support_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn $(OPTIONAL_CRYPTO_LIBS) +ntlm_support_SOURCES = ntlm_support.c \ + unit_tests/openvpn/mock_msg.c unit_tests/openvpn/mock_msg.h \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/crypto.c \ + $(top_srcdir)/src/openvpn/crypto_openssl.c \ + $(top_srcdir)/src/openvpn/crypto_mbedtls.c \ + $(top_srcdir)/src/openvpn/otime.c \ + $(top_srcdir)/src/openvpn/packet_id.c \ + $(top_srcdir)/src/openvpn/platform.c
tests/ntlm_support.c new file +52 -0
52 lines not on this page · raw message
tests/t_client.rc-sample +25 -7
@@ -27,7 +27,7 @@ # # tests to run (list suffixes for config stanzas below) # -TEST_RUN_LIST="1 2" +TEST_RUN_LIST="1 2 2n" # # use "sudo" (etc) to give openvpn the necessary privileges
@@ -53,14 +53,24 @@ # # if something is not defined here, the corresponding test is not run # -# possible test options: +# common test options: # -# RUN_TITLE_x="what is being tested on here" (purely informational) -# OPENVPN_CONF_x = "how to call ./openvpn" [mandatory] +# RUN_TITLE_x = "what is being tested on here" (purely informational) +# OPENVPN_CONF_x = "how to call ./openvpn" [mandatory] # EXPECT_IFCONFIG4_x = "this IPv4 address needs to show up in ifconfig" # EXPECT_IFCONFIG6_x = "this IPv6 address needs to show up in ifconfig" -# PING4_HOSTS_x = "these hosts musts ping when openvpn is up (IPv4 fping)" -# PING6_HOSTS_x = "these hosts musts ping when openvpn is up (IPv6 fping6)" +# PING4_HOSTS_x = "these hosts musts ping when openvpn is up (IPv4 fping)" +# PING6_HOSTS_x = "these hosts musts ping when openvpn is up (IPv6 fping6)" +# +# hook test options: +# +# SKIP_x = "commands to execute before openvpn, skip test on failure" +# PREPARE_x = "commands to execute before openvpn" +# POSTINIT_CMD_x = "commands to execute after openvpn but before ping" +# CLEANUP_x = "commands to execute after the test" +# +# Note: all hooks are "eval"ed, so run in the original shell of the t_client.sh +# script, not a child process. # # Test 1: UDP / p2mp tun # specify IPv4+IPv6 addresses expected from server and ping targets
@@ -76,10 +86,18 @@ OPENVPN_CONF_2="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194" PING4_HOSTS_2="10.100.51.1 10.100.0.1" PING6_HOSTS_2="2001:db8::1 2001:db8:a051::1" -# # run command after openvpn initialization is done - here: delay 5 seconds POSTINIT_CMD_2="sleep 5" +# Test 2n: TCP / p2mp tun / via NTLM proxy +RUN_TITLE_2n="testing tun/tcp/ntlm-proxy" +OPENVPN_CONF_2n="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194 + --http-proxy 192.168.1.2 8080 $KEYBASE/t_client_auth.txt ntlm --http-proxy-option VERSION 1.1" +PING4_HOSTS_2n="10.100.51.1 10.100.0.1" +PING6_HOSTS_2n="2001:db8::1 2001:db8:a051::1" +# skip test if NTLM support is not available +SKIP_2n="${top_builddir}/tests/ntlm_support" + # Test 3: UDP / p2p tun # ...
tests/t_client.sh.in +14 -0
@@ -291,12 +291,14 @@ # main test loop # ---------------------------------------------------------- SUMMARY_OK= +SUMMARY_SKIP= SUMMARY_FAIL= for SUF in $TEST_RUN_LIST do # get config variables eval test_prep=\"\$PREPARE_$SUF\" + eval test_check_skip=\"\$SKIP_$SUF\" eval test_postinit=\"\$POSTINIT_CMD_$SUF\" eval test_cleanup=\"\$CLEANUP_$SUF\" eval test_run_title=\"\$RUN_TITLE_$SUF\"
@@ -318,6 +320,16 @@ output_start "### test run $SUF: '$test_run_title' ###" fail_count=0 + if [ -n "$test_check_skip" ]; then + output "check whether we need to skip: '$test_check_skip'" + if eval $test_check_skip; then : + else + output "skip check failed, SKIP test $SUF." + SUMMARY_SKIP="$SUMMARY_SKIP $SUF" + echo -e "$outbuf" ; continue + fi + fi + if [ -n "$test_prep" ]; then output "running preparation: '$test_prep'" eval $test_prep
@@ -455,8 +467,10 @@ done if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi +if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi echo "Test sets succeeded:$SUMMARY_OK." +echo "Test sets skipped:$SUMMARY_SKIP." echo "Test sets failed:$SUMMARY_FAIL." # remove trap handler
tests/unit_tests/openvpn/mock_msg.c +13 -1
@@ -31,8 +31,9 @@#include <stdlib.h> #include <setjmp.h> #include <stdint.h> +#ifndef NO_CMOCKA #include <cmocka.h> - +#endif #include "errlevel.h" #include "error.h"
@@ -74,6 +75,8 @@va_end (arglist); } +/* Allow to use mock_msg.c outside of UT */ +#ifndef NO_CMOCKA void assert_failed (const char *filename,int line,const char *condition) {
@@ -81,6 +84,15 @@/* Keep compiler happy. Should not happen, mock_assert() does not return */ exit(1); } +#else /* ifndef NO_CMOCKA */ +void +assert_failed (const char *filename,int line,const char *condition) +{ +msg (M_FATAL ,"Assertion failed at %s:%d (%s)" , filename, line, condition ? condition :"" ); +_exit (1 ); +} +#endif +/* * Fail memory allocation. Don't use msg() because it tries
Signature · 17 lines
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899 Gerrit-Change-Number: 521 Gerrit-PatchSet: 3 Gerrit-Owner: flichtenheld <[email protected]...> Gerrit-Reviewer: cron2 <[email protected]...> Gerrit-Reviewer: plaisthos <[email protected]...> Gerrit-CC: openvpn-devel <[email protected]> Gerrit-CC: ordex <[email protected]...> Gerrit-Attention: plaisthos <[email protected]...> Gerrit-Attention: cron2 <[email protected]...> Gerrit-Attention: ordex <[email protected]...> Gerrit-MessageType: newpatchset
Attention is currently required from: cron2, ordex, plaisthos.
Hello cron2, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
to look at the new patch set (#4).
Change subject: t_client.sh: Allow to skip tests
......................................................................
t_client.sh: Allow to skip tests
Individual tests can define a script to run to test whether they should be skipped.
Included in this commit is an example check which checks whether we can do NTLM checks. This fails e.g. on recent versions of Fedora with mbedTLS (tested with Fedora 39) or when NTLM support is not compiled in.
v2:
- ntlm_support:
- support OpenSSL 3
- allow to build without cmocka
v3:
- add example to t_client.rc-sample
- t_client.sh code style
- use syshead.h in error.h
---
M src/openvpn/error.h
M tests/Makefile.am
A tests/ntlm_support.c
M tests/t_client.rc-sample
M tests/t_client.sh.in
M tests/unit_tests/openvpn/mock_msg.c
6 files changed, 119 insertions(+), 15 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/21/521/4
src/openvpn/error.h +1 -7
@@ -25,16 +25,10 @@#define ERROR_H #include "basic.h" - -#include <errno.h> -#include <stdbool.h> +#include "syshead.h" #include <assert.h> -#if _WIN32 -#include <windows.h> -#endif -/* #define ABORT_ON_ERROR */ #if defined(ENABLE_PKCS11 ) || defined(ENABLE_MANAGEMENT )
tests/Makefile.am +14 -0
@@ -19,6 +19,8 @@ if !WIN32 test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh + +check_PROGRAMS = ntlm_support if HAVE_SITNL test_scripts += t_net.sh endif
@@ -36,3 +38,15 @@ dist_noinst_DATA = \ t_client.rc-sample + +ntlm_support_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat -I$(top_srcdir)/tests/unit_tests/openvpn -DNO_CMOCKA @TEST_CFLAGS@ +ntlm_support_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn $(OPTIONAL_CRYPTO_LIBS) +ntlm_support_SOURCES = ntlm_support.c \ + unit_tests/openvpn/mock_msg.c unit_tests/openvpn/mock_msg.h \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/crypto.c \ + $(top_srcdir)/src/openvpn/crypto_openssl.c \ + $(top_srcdir)/src/openvpn/crypto_mbedtls.c \ + $(top_srcdir)/src/openvpn/otime.c \ + $(top_srcdir)/src/openvpn/packet_id.c \ + $(top_srcdir)/src/openvpn/platform.c
tests/ntlm_support.c new file +52 -0
52 lines not on this page · raw message
tests/t_client.rc-sample +25 -7
@@ -27,7 +27,7 @@ # # tests to run (list suffixes for config stanzas below) # -TEST_RUN_LIST="1 2" +TEST_RUN_LIST="1 2 2n" # # use "sudo" (etc) to give openvpn the necessary privileges
@@ -53,14 +53,24 @@ # # if something is not defined here, the corresponding test is not run # -# possible test options: +# common test options: # -# RUN_TITLE_x="what is being tested on here" (purely informational) -# OPENVPN_CONF_x = "how to call ./openvpn" [mandatory] +# RUN_TITLE_x = "what is being tested on here" (purely informational) +# OPENVPN_CONF_x = "how to call ./openvpn" [mandatory] # EXPECT_IFCONFIG4_x = "this IPv4 address needs to show up in ifconfig" # EXPECT_IFCONFIG6_x = "this IPv6 address needs to show up in ifconfig" -# PING4_HOSTS_x = "these hosts musts ping when openvpn is up (IPv4 fping)" -# PING6_HOSTS_x = "these hosts musts ping when openvpn is up (IPv6 fping6)" +# PING4_HOSTS_x = "these hosts musts ping when openvpn is up (IPv4 fping)" +# PING6_HOSTS_x = "these hosts musts ping when openvpn is up (IPv6 fping6)" +# +# hook test options: +# +# SKIP_x = "commands to execute before openvpn, skip test on failure" +# PREPARE_x = "commands to execute before openvpn" +# POSTINIT_CMD_x = "commands to execute after openvpn but before ping" +# CLEANUP_x = "commands to execute after the test" +# +# Note: all hooks are "eval"ed, so run in the original shell of the t_client.sh +# script, not a child process. # # Test 1: UDP / p2mp tun # specify IPv4+IPv6 addresses expected from server and ping targets
@@ -76,10 +86,18 @@ OPENVPN_CONF_2="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194" PING4_HOSTS_2="10.100.51.1 10.100.0.1" PING6_HOSTS_2="2001:db8::1 2001:db8:a051::1" -# # run command after openvpn initialization is done - here: delay 5 seconds POSTINIT_CMD_2="sleep 5" +# Test 2n: TCP / p2mp tun / via NTLM proxy +RUN_TITLE_2n="testing tun/tcp/ntlm-proxy" +OPENVPN_CONF_2n="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194 + --http-proxy 192.168.1.2 8080 $KEYBASE/t_client_auth.txt ntlm --http-proxy-option VERSION 1.1" +PING4_HOSTS_2n="10.100.51.1 10.100.0.1" +PING6_HOSTS_2n="2001:db8::1 2001:db8:a051::1" +# skip test if NTLM support is not available +SKIP_2n="${top_builddir}/tests/ntlm_support" + # Test 3: UDP / p2p tun # ...
tests/t_client.sh.in +14 -0
@@ -291,12 +291,14 @@ # main test loop # ---------------------------------------------------------- SUMMARY_OK= +SUMMARY_SKIP= SUMMARY_FAIL= for SUF in $TEST_RUN_LIST do # get config variables eval test_prep=\"\$PREPARE_$SUF\" + eval test_check_skip=\"\$SKIP_$SUF\" eval test_postinit=\"\$POSTINIT_CMD_$SUF\" eval test_cleanup=\"\$CLEANUP_$SUF\" eval test_run_title=\"\$RUN_TITLE_$SUF\"
@@ -318,6 +320,16 @@ output_start "### test run $SUF: '$test_run_title' ###" fail_count=0 + if [ -n "$test_check_skip" ]; then + output "check whether we need to skip: '$test_check_skip'" + if eval $test_check_skip; then : + else + output "skip check failed, SKIP test $SUF." + SUMMARY_SKIP="$SUMMARY_SKIP $SUF" + echo -e "$outbuf" ; continue + fi + fi + if [ -n "$test_prep" ]; then output "running preparation: '$test_prep'" eval $test_prep
@@ -455,8 +467,10 @@ done if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi +if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi echo "Test sets succeeded:$SUMMARY_OK." +echo "Test sets skipped:$SUMMARY_SKIP." echo "Test sets failed:$SUMMARY_FAIL." # remove trap handler
tests/unit_tests/openvpn/mock_msg.c +13 -1
@@ -31,8 +31,9 @@#include <stdlib.h> #include <setjmp.h> #include <stdint.h> +#ifndef NO_CMOCKA #include <cmocka.h> - +#endif #include "errlevel.h" #include "error.h"
@@ -74,6 +75,8 @@va_end (arglist); } +/* Allow to use mock_msg.c outside of UT */ +#ifndef NO_CMOCKA void assert_failed (const char *filename,int line,const char *condition) {
@@ -81,6 +84,15 @@/* Keep compiler happy. Should not happen, mock_assert() does not return */ exit(1); } +#else /* ifndef NO_CMOCKA */ +void +assert_failed (const char *filename,int line,const char *condition) +{ +msg (M_FATAL ,"Assertion failed at %s:%d (%s)" , filename, line, condition ? condition :"" ); +_exit (1 ); +} +#endif +/* * Fail memory allocation. Don't use msg() because it tries
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899
Gerrit-Change-Number: 521
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: flichtenheld, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/521?usp=email )
Change subject: t_client.sh: Allow to skip tests
......................................................................
Patch Set 4: Code-Review-1
(4 comments)
Patchset:
PS4:
Took me longer than expected after v4, but I do have some more wishes... (thanks for bearing with me)
File tests/Makefile.am:
http://gerrit.openvpn.net/c/openvpn/+/521/comment/aabb9cc6_e1155271 :
PS4, Line 45: unit_tests/openvpn/mock_msg.c unit_tests/openvpn/mock_msg.h \
OK, so now I do better understand the -DNO_CMOCKA code in unit_tests/openvpn/mock_msg.c - but I'm none the happier. Unit test code is unit test code, and shouldn't be used by something else (= so when trying to understand code in unit_tests/ I don't really want to consider "oh, wait, this is also used by some other piece of code").
But I can't really can come up with a nice alternative that will not boil down to "just add another copy of msg() mocking into ntlm_support.c" (because crypto_load_provider() needs it).
File tests/t_client.rc-sample:
http://gerrit.openvpn.net/c/openvpn/+/521/comment/7c7d3b68_b8417006 :
PS4, Line 67: # SKIP_x = "commands to execute before openvpn, skip test on failure"
TBH, I do not like SKIP_x because it just tells me "well, yes, skip this test".
I'd suggest to rename it to something like SKIP_CONDITIONAL_x or PRE_TEST_x or so which better transports the message "ah, this is a command to run, and depending on the outcome, things will be skipped".
http://gerrit.openvpn.net/c/openvpn/+/521/comment/34ed3c96_6462fbf2 :
PS4, Line 70: # CLEANUP_x = "commands to execute after the test"
this is a very welcome addition to the last options that I forgot to properly document. Thanks ;-)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899
Gerrit-Change-Number: 521
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Wed, 06 Mar 2024 09:57:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: cron2, flichtenheld, ordex, plaisthos.
Hello cron2, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
to look at the new patch set (#5).
The following approvals got outdated and were removed:
Code-Review-1 by cron2
Change subject: t_client.sh: Allow to skip tests
......................................................................
t_client.sh: Allow to skip tests
Individual tests can define a script to run to test whether they should be skipped.
Included in this commit is an example check which checks whether we can do NTLM checks. This fails e.g. on recent versions of Fedora with mbedTLS (tested with Fedora 39) or when NTLM support is not compiled in.
v2:
- ntlm_support:
- support OpenSSL 3
- allow to build without cmocka
v3:
- add example to t_client.rc-sample
- t_client.sh code style
- use syshead.h in error.h
v5:
- rename SKIP_x to CHECK_SKIP_x
---
M src/openvpn/error.h
M tests/Makefile.am
A tests/ntlm_support.c
M tests/t_client.rc-sample
M tests/t_client.sh.in
M tests/unit_tests/openvpn/mock_msg.c
6 files changed, 119 insertions(+), 15 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/21/521/5
src/openvpn/error.h +1 -7
@@ -25,16 +25,10 @@#define ERROR_H #include "basic.h" - -#include <errno.h> -#include <stdbool.h> +#include "syshead.h" #include <assert.h> -#if _WIN32 -#include <windows.h> -#endif -/* #define ABORT_ON_ERROR */ #if defined(ENABLE_PKCS11 ) || defined(ENABLE_MANAGEMENT )
tests/Makefile.am +14 -0
@@ -19,6 +19,8 @@ if !WIN32 test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh + +check_PROGRAMS = ntlm_support if HAVE_SITNL test_scripts += t_net.sh endif
@@ -36,3 +38,15 @@ dist_noinst_DATA = \ t_client.rc-sample + +ntlm_support_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat -I$(top_srcdir)/tests/unit_tests/openvpn -DNO_CMOCKA @TEST_CFLAGS@ +ntlm_support_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn $(OPTIONAL_CRYPTO_LIBS) +ntlm_support_SOURCES = ntlm_support.c \ + unit_tests/openvpn/mock_msg.c unit_tests/openvpn/mock_msg.h \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/crypto.c \ + $(top_srcdir)/src/openvpn/crypto_openssl.c \ + $(top_srcdir)/src/openvpn/crypto_mbedtls.c \ + $(top_srcdir)/src/openvpn/otime.c \ + $(top_srcdir)/src/openvpn/packet_id.c \ + $(top_srcdir)/src/openvpn/platform.c
tests/ntlm_support.c new file +52 -0
52 lines not on this page · raw message
tests/t_client.rc-sample +25 -7
@@ -27,7 +27,7 @@ # # tests to run (list suffixes for config stanzas below) # -TEST_RUN_LIST="1 2" +TEST_RUN_LIST="1 2 2n" # # use "sudo" (etc) to give openvpn the necessary privileges
@@ -53,14 +53,24 @@ # # if something is not defined here, the corresponding test is not run # -# possible test options: +# common test options: # -# RUN_TITLE_x="what is being tested on here" (purely informational) -# OPENVPN_CONF_x = "how to call ./openvpn" [mandatory] +# RUN_TITLE_x = "what is being tested on here" (purely informational) +# OPENVPN_CONF_x = "how to call ./openvpn" [mandatory] # EXPECT_IFCONFIG4_x = "this IPv4 address needs to show up in ifconfig" # EXPECT_IFCONFIG6_x = "this IPv6 address needs to show up in ifconfig" -# PING4_HOSTS_x = "these hosts musts ping when openvpn is up (IPv4 fping)" -# PING6_HOSTS_x = "these hosts musts ping when openvpn is up (IPv6 fping6)" +# PING4_HOSTS_x = "these hosts musts ping when openvpn is up (IPv4 fping)" +# PING6_HOSTS_x = "these hosts musts ping when openvpn is up (IPv6 fping6)" +# +# hook test options: +# +# CHECK_SKIP_x = "commands to execute before openvpn, skip test on failure" +# PREPARE_x = "commands to execute before openvpn" +# POSTINIT_CMD_x = "commands to execute after openvpn but before ping" +# CLEANUP_x = "commands to execute after the test" +# +# Note: all hooks are "eval"ed, so run in the original shell of the t_client.sh +# script, not a child process. # # Test 1: UDP / p2mp tun # specify IPv4+IPv6 addresses expected from server and ping targets
@@ -76,10 +86,18 @@ OPENVPN_CONF_2="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194" PING4_HOSTS_2="10.100.51.1 10.100.0.1" PING6_HOSTS_2="2001:db8::1 2001:db8:a051::1" -# # run command after openvpn initialization is done - here: delay 5 seconds POSTINIT_CMD_2="sleep 5" +# Test 2n: TCP / p2mp tun / via NTLM proxy +RUN_TITLE_2n="testing tun/tcp/ntlm-proxy" +OPENVPN_CONF_2n="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194 + --http-proxy 192.168.1.2 8080 $KEYBASE/t_client_auth.txt ntlm --http-proxy-option VERSION 1.1" +PING4_HOSTS_2n="10.100.51.1 10.100.0.1" +PING6_HOSTS_2n="2001:db8::1 2001:db8:a051::1" +# skip test if NTLM support is not available +CHECK_SKIP_2n="${top_builddir}/tests/ntlm_support" + # Test 3: UDP / p2p tun # ...
tests/t_client.sh.in +14 -0
@@ -291,12 +291,14 @@ # main test loop # ---------------------------------------------------------- SUMMARY_OK= +SUMMARY_SKIP= SUMMARY_FAIL= for SUF in $TEST_RUN_LIST do # get config variables eval test_prep=\"\$PREPARE_$SUF\" + eval test_check_skip=\"\$CHECK_SKIP_$SUF\" eval test_postinit=\"\$POSTINIT_CMD_$SUF\" eval test_cleanup=\"\$CLEANUP_$SUF\" eval test_run_title=\"\$RUN_TITLE_$SUF\"
@@ -318,6 +320,16 @@ output_start "### test run $SUF: '$test_run_title' ###" fail_count=0 + if [ -n "$test_check_skip" ]; then + output "check whether we need to skip: '$test_check_skip'" + if eval $test_check_skip; then : + else + output "skip check failed, SKIP test $SUF." + SUMMARY_SKIP="$SUMMARY_SKIP $SUF" + echo -e "$outbuf" ; continue + fi + fi + if [ -n "$test_prep" ]; then output "running preparation: '$test_prep'" eval $test_prep
@@ -455,8 +467,10 @@ done if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi +if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi echo "Test sets succeeded:$SUMMARY_OK." +echo "Test sets skipped:$SUMMARY_SKIP." echo "Test sets failed:$SUMMARY_FAIL." # remove trap handler
tests/unit_tests/openvpn/mock_msg.c +13 -1
@@ -31,8 +31,9 @@#include <stdlib.h> #include <setjmp.h> #include <stdint.h> +#ifndef NO_CMOCKA #include <cmocka.h> - +#endif #include "errlevel.h" #include "error.h"
@@ -74,6 +75,8 @@va_end (arglist); } +/* Allow to use mock_msg.c outside of UT */ +#ifndef NO_CMOCKA void assert_failed (const char *filename,int line,const char *condition) {
@@ -81,6 +84,15 @@/* Keep compiler happy. Should not happen, mock_assert() does not return */ exit(1); } +#else /* ifndef NO_CMOCKA */ +void +assert_failed (const char *filename,int line,const char *condition) +{ +msg (M_FATAL ,"Assertion failed at %s:%d (%s)" , filename, line, condition ? condition :"" ); +_exit (1 ); +} +#endif +/* * Fail memory allocation. Don't use msg() because it tries
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899
Gerrit-Change-Number: 521
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: cron2, ordex, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/521?usp=email )
Change subject: t_client.sh: Allow to skip tests
......................................................................
Patch Set 4:
(3 comments)
File tests/t_client.rc-sample:
http://gerrit.openvpn.net/c/openvpn/+/521/comment/fe9c7617_bd6d46f5 :
PS4, Line 67: # SKIP_x = "commands to execute before openvpn, skip test on failure"
Quoted 1 line
TBH, I do not like
SKIP_xbecause it just tells me "well, yes, skip this test". […]
Changed to CHECK_SKIP
http://gerrit.openvpn.net/c/openvpn/+/521/comment/70edeb0f_bee08576 :
PS4, Line 70: # CLEANUP_x = "commands to execute after the test"
Quoted 1 line
this is a very welcome addition to the last options that I forgot to properly document. […]
Acknowledged
File tests/unit_tests/openvpn/mock_msg.c:
http://gerrit.openvpn.net/c/openvpn/+/521/comment/aeaf2450_604a1484 :
PS2, Line 94: endif
Quoted 1 line
Yes, in this PR it is now used in
t_clientcontext, which is not a unit test context
Acknowledged
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899
Gerrit-Change-Number: 521
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Wed, 06 Mar 2024 13:54:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: ordex <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, ordex, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/521?usp=email )
Change subject: t_client.sh: Allow to skip tests
......................................................................
Patch Set 5:
(1 comment)
Patchset:
PS4:
Quoted 1 line
Took me longer than expected after v4, but I do have some more wishes... […]
Acknowledged
Signature · 21 lines
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899 Gerrit-Change-Number: 521 Gerrit-PatchSet: 5 Gerrit-Owner: flichtenheld <[email protected]...> Gerrit-Reviewer: cron2 <[email protected]...> Gerrit-Reviewer: plaisthos <[email protected]...> Gerrit-CC: openvpn-devel <[email protected]> Gerrit-CC: ordex <[email protected]...> Gerrit-Attention: plaisthos <[email protected]...> Gerrit-Attention: cron2 <[email protected]...> Gerrit-Attention: ordex <[email protected]...> Gerrit-Comment-Date: Wed, 06 Mar 2024 13:55:06 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: cron2 <[email protected]...> Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/521?usp=email )
Change subject: t_client.sh: Allow to skip tests
......................................................................
Patch Set 5: Code-Review+2
(1 comment)
Patchset:
PS5:
thanks. t_client looks good, ntlm test we agreed on taking as it is and maybe someone will come up with good ideas how to improve later on.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899
Gerrit-Change-Number: 521
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Fri, 08 Mar 2024 10:27:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v5 1/1 t_client.sh: Allow to skip tests
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]...>
Individual tests can define a script to run to test whether they should be skipped.
Included in this commit is an example check which checks whether we can do NTLM checks. This fails e.g. on recent versions of Fedora with mbedTLS (tested with Fedora 39) or when NTLM support is not compiled in.
v2:
- ntlm_support:
- support OpenSSL 3
- allow to build without cmocka
v3:
- add example to t_client.rc-sample
- t_client.sh code style
- use syshead.h in error.h
v5:
- rename SKIP_x to CHECK_SKIP_x
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/521
This mail reflects revision 5 of this Change. Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/error.h +1 -7
@@ -25,16 +25,10 @@#define ERROR_H #include "basic.h" - -#include <errno.h> -#include <stdbool.h> +#include "syshead.h" #include <assert.h> -#if _WIN32 -#include <windows.h> -#endif -/* #define ABORT_ON_ERROR */ #if defined(ENABLE_PKCS11 ) || defined(ENABLE_MANAGEMENT )
tests/Makefile.am +14 -0
@@ -19,6 +19,8 @@ if !WIN32 test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh + +check_PROGRAMS = ntlm_support if HAVE_SITNL test_scripts += t_net.sh endif
@@ -36,3 +38,15 @@ dist_noinst_DATA = \ t_client.rc-sample + +ntlm_support_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat -I$(top_srcdir)/tests/unit_tests/openvpn -DNO_CMOCKA @TEST_CFLAGS@ +ntlm_support_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn $(OPTIONAL_CRYPTO_LIBS) +ntlm_support_SOURCES = ntlm_support.c \ + unit_tests/openvpn/mock_msg.c unit_tests/openvpn/mock_msg.h \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/crypto.c \ + $(top_srcdir)/src/openvpn/crypto_openssl.c \ + $(top_srcdir)/src/openvpn/crypto_mbedtls.c \ + $(top_srcdir)/src/openvpn/otime.c \ + $(top_srcdir)/src/openvpn/packet_id.c \ + $(top_srcdir)/src/openvpn/platform.c
tests/ntlm_support.c new file +52 -0
52 lines not on this page · raw message
tests/t_client.rc-sample +25 -7
@@ -27,7 +27,7 @@ # # tests to run (list suffixes for config stanzas below) # -TEST_RUN_LIST="1 2" +TEST_RUN_LIST="1 2 2n" # # use "sudo" (etc) to give openvpn the necessary privileges
@@ -53,14 +53,24 @@ # # if something is not defined here, the corresponding test is not run # -# possible test options: +# common test options: # -# RUN_TITLE_x="what is being tested on here" (purely informational) -# OPENVPN_CONF_x = "how to call ./openvpn" [mandatory] +# RUN_TITLE_x = "what is being tested on here" (purely informational) +# OPENVPN_CONF_x = "how to call ./openvpn" [mandatory] # EXPECT_IFCONFIG4_x = "this IPv4 address needs to show up in ifconfig" # EXPECT_IFCONFIG6_x = "this IPv6 address needs to show up in ifconfig" -# PING4_HOSTS_x = "these hosts musts ping when openvpn is up (IPv4 fping)" -# PING6_HOSTS_x = "these hosts musts ping when openvpn is up (IPv6 fping6)" +# PING4_HOSTS_x = "these hosts musts ping when openvpn is up (IPv4 fping)" +# PING6_HOSTS_x = "these hosts musts ping when openvpn is up (IPv6 fping6)" +# +# hook test options: +# +# CHECK_SKIP_x = "commands to execute before openvpn, skip test on failure" +# PREPARE_x = "commands to execute before openvpn" +# POSTINIT_CMD_x = "commands to execute after openvpn but before ping" +# CLEANUP_x = "commands to execute after the test" +# +# Note: all hooks are "eval"ed, so run in the original shell of the t_client.sh +# script, not a child process. # # Test 1: UDP / p2mp tun # specify IPv4+IPv6 addresses expected from server and ping targets
@@ -76,10 +86,18 @@ OPENVPN_CONF_2="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194" PING4_HOSTS_2="10.100.51.1 10.100.0.1" PING6_HOSTS_2="2001:db8::1 2001:db8:a051::1" -# # run command after openvpn initialization is done - here: delay 5 seconds POSTINIT_CMD_2="sleep 5" +# Test 2n: TCP / p2mp tun / via NTLM proxy +RUN_TITLE_2n="testing tun/tcp/ntlm-proxy" +OPENVPN_CONF_2n="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194 + --http-proxy 192.168.1.2 8080 $KEYBASE/t_client_auth.txt ntlm --http-proxy-option VERSION 1.1" +PING4_HOSTS_2n="10.100.51.1 10.100.0.1" +PING6_HOSTS_2n="2001:db8::1 2001:db8:a051::1" +# skip test if NTLM support is not available +CHECK_SKIP_2n="${top_builddir}/tests/ntlm_support" + # Test 3: UDP / p2p tun # ...
tests/t_client.sh.in +14 -0
@@ -291,12 +291,14 @@ # main test loop # ---------------------------------------------------------- SUMMARY_OK= +SUMMARY_SKIP= SUMMARY_FAIL= for SUF in $TEST_RUN_LIST do # get config variables eval test_prep=\"\$PREPARE_$SUF\" + eval test_check_skip=\"\$CHECK_SKIP_$SUF\" eval test_postinit=\"\$POSTINIT_CMD_$SUF\" eval test_cleanup=\"\$CLEANUP_$SUF\" eval test_run_title=\"\$RUN_TITLE_$SUF\"
@@ -318,6 +320,16 @@ output_start "### test run $SUF: '$test_run_title' ###" fail_count=0 + if [ -n "$test_check_skip" ]; then + output "check whether we need to skip: '$test_check_skip'" + if eval $test_check_skip; then : + else + output "skip check failed, SKIP test $SUF." + SUMMARY_SKIP="$SUMMARY_SKIP $SUF" + echo -e "$outbuf" ; continue + fi + fi + if [ -n "$test_prep" ]; then output "running preparation: '$test_prep'" eval $test_prep
@@ -455,8 +467,10 @@ done if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi +if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi echo "Test sets succeeded:$SUMMARY_OK." +echo "Test sets skipped:$SUMMARY_SKIP." echo "Test sets failed:$SUMMARY_FAIL." # remove trap handler
tests/unit_tests/openvpn/mock_msg.c +13 -1
@@ -31,8 +31,9 @@#include <stdlib.h> #include <setjmp.h> #include <stdint.h> +#ifndef NO_CMOCKA #include <cmocka.h> - +#endif #include "errlevel.h" #include "error.h"
@@ -74,6 +75,8 @@va_end (arglist); } +/* Allow to use mock_msg.c outside of UT */ +#ifndef NO_CMOCKA void assert_failed (const char *filename,int line,const char *condition) {
@@ -81,6 +84,15 @@/* Keep compiler happy. Should not happen, mock_assert() does not return */ exit(1); } +#else /* ifndef NO_CMOCKA */ +void +assert_failed (const char *filename,int line,const char *condition) +{ +msg (M_FATAL ,"Assertion failed at %s:%d (%s)" , filename, line, condition ? condition :"" ); +_exit (1 ); +} +#endif +/* * Fail memory allocation. Don't use msg() because it tries
[Openvpn-devel] [PATCH applied] Re: t_client.sh: Allow to skip tests
Thanks. This is a welcome addition for CI tests where we test functionality that might fail "if built with the wrong SSL library" (like, NTLM proxy) - and I could see a few more of this ("compression variants", etc)
The test looks larger than the actual t_client.sh(.in) + doc change as it brings an actual "can NTLM proxy work?" test program - as we discussed the handling of mock_msg.c/mock_msg.h could be improved, but we all haven't been able to come up with a really nice way.
Tested ntlm_support with an mbedTLS build, works as designed...
openvpn$ tests/ntlm_support
FATAL ERROR:MD4 not supported
openvpn$ echo $?
1
(Building this on top of a tree that has already been built without this patch leads to confused Makefiles and failures to build "ntlm_support" - but this goes away on a fresh checkout / autoreconf, so will not normally hit users)
Your patch has been applied to the master branch.
commit 0c7cf0694ee6f878168330e9a084c255c51a9e8b
Author: Frank Lichtenheld Date: Fri Mar 8 11:28:18 2024 +0100
t_client.sh: Allow to skip tests
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/search?l=mid&[email protected]...
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Re: [Openvpn-devel] [PATCH applied] Re: t_client.sh: Allow to skip tests
On Fri, Mar 08, 2024 at 12:51:33PM +0100, Gert Doering wrote:
[...]
Quoted 1 line
Your patch has been applied to the master branch.
Could we please cherry-pick this to release/2.6 as well?
Would make it much easier to use this capability in our buildbot infrastructure and the patch only affects tests anyway.
Quoted 18 lines
commit
0c7cf0694ee6f878168330e9a084c255c51a9e8bAuthor: Frank Lichtenheld Date: Fri Mar 8 11:28:18 2024 +0100t_client.sh: Allow to skip tests Signed-off-by: Frank Lichtenheld <[email protected]...> Acked-by: Gert Doering <[email protected]...> Message-Id: <[email protected]...> URL: https://www.mail-archive.com/search?l=mid&[email protected]... Signed-off-by: Gert Doering <[email protected]...>--
kind regards,Gert Doering
Signature · 1 line
Frank Lichtenheld
Re: [Openvpn-devel] [PATCH applied] Re: t_client.sh: Allow to skip tests
Hi,
Quoted 8 lines · Frank Lichtenheld
On Fri, Mar 08, 2024 at 12:51:33PM +0100, Gert Doering wrote:
[...]Quoted 1 line
Your patch has been applied to the master branch.
Could we please cherry-pick this to release/2.6 as well?
Would make it much easier to use this capability in our buildbot infrastructure and the patch only affects tests anyway.
I did toy with the idea, but was afraid it wouldn't work as so much of the new unit test infra is only in master - the t_client patch is trivial, but ntlm_support + mock_msg.
Turns out this went smoothly, so here we go...
[email protected]... ~/openvpn-26.git $ tests/ntlm_support [email protected]... ~/openvpn-26.git $ echo $?
0
(openssl build)
Quoted 5 lines
Quoted 5 lines
commit
0c7cf0694ee6f878168330e9a084c255c51a9e8bAuthor: Frank Lichtenheld Date: Fri Mar 8 11:28:18 2024 +0100
t_client.sh: Allow to skip tests
commit bbc77d1719d2d5b33e58abac5eba8b8e409561ab (HEAD -> release/2.6, vweb1/release/2.6)
Author: Frank Lichtenheld <[email protected]...> Date: Fri Mar 8 11:28:18 2024 +0100
t_client.sh: Allow to skip tests
(cherry picked from commit 0c7cf0694ee6f878168330e9a084c255c51a9e8b)
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...cron2 has uploaded a new patch set (#6) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/521?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: t_client.sh: Allow to skip tests
......................................................................
t_client.sh: Allow to skip tests
Individual tests can define a script to run to test whether they should be skipped.
Included in this commit is an example check which checks whether we can do NTLM checks. This fails e.g. on recent versions of Fedora with mbedTLS (tested with Fedora 39) or when NTLM support is not compiled in.
v2:
- ntlm_support:
- support OpenSSL 3
- allow to build without cmocka
v3:
- add example to t_client.rc-sample
- t_client.sh code style
- use syshead.h in error.h
v5:
- rename SKIP_x to CHECK_SKIP_x
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/search?l=mid&[email protected]...
---
M src/openvpn/error.h
M tests/Makefile.am
A tests/ntlm_support.c
M tests/t_client.rc-sample
M tests/t_client.sh.in
M tests/unit_tests/openvpn/mock_msg.c
6 files changed, 119 insertions(+), 15 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/21/521/6
src/openvpn/error.h +1 -7
@@ -25,16 +25,10 @@#define ERROR_H #include "basic.h" - -#include <errno.h> -#include <stdbool.h> +#include "syshead.h" #include <assert.h> -#if _WIN32 -#include <windows.h> -#endif -/* #define ABORT_ON_ERROR */ #if defined(ENABLE_PKCS11 ) || defined(ENABLE_MANAGEMENT )
tests/Makefile.am +14 -0
@@ -18,6 +18,8 @@ if !WIN32 test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh + +check_PROGRAMS = ntlm_support if HAVE_SITNL test_scripts += t_net.sh endif
@@ -35,3 +37,15 @@ dist_noinst_DATA = \ t_client.rc-sample + +ntlm_support_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat -I$(top_srcdir)/tests/unit_tests/openvpn -DNO_CMOCKA @TEST_CFLAGS@ +ntlm_support_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn $(OPTIONAL_CRYPTO_LIBS) +ntlm_support_SOURCES = ntlm_support.c \ + unit_tests/openvpn/mock_msg.c unit_tests/openvpn/mock_msg.h \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/crypto.c \ + $(top_srcdir)/src/openvpn/crypto_openssl.c \ + $(top_srcdir)/src/openvpn/crypto_mbedtls.c \ + $(top_srcdir)/src/openvpn/otime.c \ + $(top_srcdir)/src/openvpn/packet_id.c \ + $(top_srcdir)/src/openvpn/platform.c
tests/ntlm_support.c new file +52 -0
52 lines not on this page · raw message
tests/t_client.rc-sample +25 -7
@@ -27,7 +27,7 @@ # # tests to run (list suffixes for config stanzas below) # -TEST_RUN_LIST="1 2" +TEST_RUN_LIST="1 2 2n" # # use "sudo" (etc) to give openvpn the necessary privileges
@@ -53,14 +53,24 @@ # # if something is not defined here, the corresponding test is not run # -# possible test options: +# common test options: # -# RUN_TITLE_x="what is being tested on here" (purely informational) -# OPENVPN_CONF_x = "how to call ./openvpn" [mandatory] +# RUN_TITLE_x = "what is being tested on here" (purely informational) +# OPENVPN_CONF_x = "how to call ./openvpn" [mandatory] # EXPECT_IFCONFIG4_x = "this IPv4 address needs to show up in ifconfig" # EXPECT_IFCONFIG6_x = "this IPv6 address needs to show up in ifconfig" -# PING4_HOSTS_x = "these hosts musts ping when openvpn is up (IPv4 fping)" -# PING6_HOSTS_x = "these hosts musts ping when openvpn is up (IPv6 fping6)" +# PING4_HOSTS_x = "these hosts musts ping when openvpn is up (IPv4 fping)" +# PING6_HOSTS_x = "these hosts musts ping when openvpn is up (IPv6 fping6)" +# +# hook test options: +# +# CHECK_SKIP_x = "commands to execute before openvpn, skip test on failure" +# PREPARE_x = "commands to execute before openvpn" +# POSTINIT_CMD_x = "commands to execute after openvpn but before ping" +# CLEANUP_x = "commands to execute after the test" +# +# Note: all hooks are "eval"ed, so run in the original shell of the t_client.sh +# script, not a child process. # # Test 1: UDP / p2mp tun # specify IPv4+IPv6 addresses expected from server and ping targets
@@ -76,10 +86,18 @@ OPENVPN_CONF_2="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194" PING4_HOSTS_2="10.100.51.1 10.100.0.1" PING6_HOSTS_2="2001:db8::1 2001:db8:a051::1" -# # run command after openvpn initialization is done - here: delay 5 seconds POSTINIT_CMD_2="sleep 5" +# Test 2n: TCP / p2mp tun / via NTLM proxy +RUN_TITLE_2n="testing tun/tcp/ntlm-proxy" +OPENVPN_CONF_2n="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194 + --http-proxy 192.168.1.2 8080 $KEYBASE/t_client_auth.txt ntlm --http-proxy-option VERSION 1.1" +PING4_HOSTS_2n="10.100.51.1 10.100.0.1" +PING6_HOSTS_2n="2001:db8::1 2001:db8:a051::1" +# skip test if NTLM support is not available +CHECK_SKIP_2n="${top_builddir}/tests/ntlm_support" + # Test 3: UDP / p2p tun # ...
tests/t_client.sh.in +14 -0
@@ -291,12 +291,14 @@ # main test loop # ---------------------------------------------------------- SUMMARY_OK= +SUMMARY_SKIP= SUMMARY_FAIL= for SUF in $TEST_RUN_LIST do # get config variables eval test_prep=\"\$PREPARE_$SUF\" + eval test_check_skip=\"\$CHECK_SKIP_$SUF\" eval test_postinit=\"\$POSTINIT_CMD_$SUF\" eval test_cleanup=\"\$CLEANUP_$SUF\" eval test_run_title=\"\$RUN_TITLE_$SUF\"
@@ -318,6 +320,16 @@ output_start "### test run $SUF: '$test_run_title' ###" fail_count=0 + if [ -n "$test_check_skip" ]; then + output "check whether we need to skip: '$test_check_skip'" + if eval $test_check_skip; then : + else + output "skip check failed, SKIP test $SUF." + SUMMARY_SKIP="$SUMMARY_SKIP $SUF" + echo -e "$outbuf" ; continue + fi + fi + if [ -n "$test_prep" ]; then output "running preparation: '$test_prep'" eval $test_prep
@@ -455,8 +467,10 @@ done if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi +if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi echo "Test sets succeeded:$SUMMARY_OK." +echo "Test sets skipped:$SUMMARY_SKIP." echo "Test sets failed:$SUMMARY_FAIL." # remove trap handler
tests/unit_tests/openvpn/mock_msg.c +13 -1
@@ -31,8 +31,9 @@#include <stdlib.h> #include <setjmp.h> #include <stdint.h> +#ifndef NO_CMOCKA #include <cmocka.h> - +#endif #include "errlevel.h" #include "error.h"
@@ -74,6 +75,8 @@va_end (arglist); } +/* Allow to use mock_msg.c outside of UT */ +#ifndef NO_CMOCKA void assert_failed (const char *filename,int line,const char *condition) {
@@ -81,6 +84,15 @@/* Keep compiler happy. Should not happen, mock_assert() does not return */ exit(1); } +#else /* ifndef NO_CMOCKA */ +void +assert_failed (const char *filename,int line,const char *condition) +{ +msg (M_FATAL ,"Assertion failed at %s:%d (%s)" , filename, line, condition ? condition :"" ); +_exit (1 ); +} +#endif +/* * Fail memory allocation. Don't use msg() because it tries
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899
Gerrit-Change-Number: 521
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/521?usp=email )
Change subject: t_client.sh: Allow to skip tests
......................................................................
t_client.sh: Allow to skip tests
Individual tests can define a script to run to test whether they should be skipped.
Included in this commit is an example check which checks whether we can do NTLM checks. This fails e.g. on recent versions of Fedora with mbedTLS (tested with Fedora 39) or when NTLM support is not compiled in.
v2:
- ntlm_support:
- support OpenSSL 3
- allow to build without cmocka
v3:
- add example to t_client.rc-sample
- t_client.sh code style
- use syshead.h in error.h
v5:
- rename SKIP_x to CHECK_SKIP_x
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/search?l=mid&[email protected]...
---
M src/openvpn/error.h
M tests/Makefile.am
A tests/ntlm_support.c
M tests/t_client.rc-sample
M tests/t_client.sh.in
M tests/unit_tests/openvpn/mock_msg.c
6 files changed, 119 insertions(+), 15 deletions(-)
src/openvpn/error.h +1 -7
@@ -25,16 +25,10 @@#define ERROR_H #include "basic.h" - -#include <errno.h> -#include <stdbool.h> +#include "syshead.h" #include <assert.h> -#if _WIN32 -#include <windows.h> -#endif -/* #define ABORT_ON_ERROR */ #if defined(ENABLE_PKCS11 ) || defined(ENABLE_MANAGEMENT )
tests/Makefile.am +14 -0
@@ -18,6 +18,8 @@ if !WIN32 test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh + +check_PROGRAMS = ntlm_support if HAVE_SITNL test_scripts += t_net.sh endif
@@ -35,3 +37,15 @@ dist_noinst_DATA = \ t_client.rc-sample + +ntlm_support_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat -I$(top_srcdir)/tests/unit_tests/openvpn -DNO_CMOCKA @TEST_CFLAGS@ +ntlm_support_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn $(OPTIONAL_CRYPTO_LIBS) +ntlm_support_SOURCES = ntlm_support.c \ + unit_tests/openvpn/mock_msg.c unit_tests/openvpn/mock_msg.h \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/crypto.c \ + $(top_srcdir)/src/openvpn/crypto_openssl.c \ + $(top_srcdir)/src/openvpn/crypto_mbedtls.c \ + $(top_srcdir)/src/openvpn/otime.c \ + $(top_srcdir)/src/openvpn/packet_id.c \ + $(top_srcdir)/src/openvpn/platform.c
tests/ntlm_support.c new file +52 -0
52 lines not on this page · raw message
tests/t_client.rc-sample +25 -7
@@ -27,7 +27,7 @@ # # tests to run (list suffixes for config stanzas below) # -TEST_RUN_LIST="1 2" +TEST_RUN_LIST="1 2 2n" # # use "sudo" (etc) to give openvpn the necessary privileges
@@ -53,14 +53,24 @@ # # if something is not defined here, the corresponding test is not run # -# possible test options: +# common test options: # -# RUN_TITLE_x="what is being tested on here" (purely informational) -# OPENVPN_CONF_x = "how to call ./openvpn" [mandatory] +# RUN_TITLE_x = "what is being tested on here" (purely informational) +# OPENVPN_CONF_x = "how to call ./openvpn" [mandatory] # EXPECT_IFCONFIG4_x = "this IPv4 address needs to show up in ifconfig" # EXPECT_IFCONFIG6_x = "this IPv6 address needs to show up in ifconfig" -# PING4_HOSTS_x = "these hosts musts ping when openvpn is up (IPv4 fping)" -# PING6_HOSTS_x = "these hosts musts ping when openvpn is up (IPv6 fping6)" +# PING4_HOSTS_x = "these hosts musts ping when openvpn is up (IPv4 fping)" +# PING6_HOSTS_x = "these hosts musts ping when openvpn is up (IPv6 fping6)" +# +# hook test options: +# +# CHECK_SKIP_x = "commands to execute before openvpn, skip test on failure" +# PREPARE_x = "commands to execute before openvpn" +# POSTINIT_CMD_x = "commands to execute after openvpn but before ping" +# CLEANUP_x = "commands to execute after the test" +# +# Note: all hooks are "eval"ed, so run in the original shell of the t_client.sh +# script, not a child process. # # Test 1: UDP / p2mp tun # specify IPv4+IPv6 addresses expected from server and ping targets
@@ -76,10 +86,18 @@ OPENVPN_CONF_2="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194" PING4_HOSTS_2="10.100.51.1 10.100.0.1" PING6_HOSTS_2="2001:db8::1 2001:db8:a051::1" -# # run command after openvpn initialization is done - here: delay 5 seconds POSTINIT_CMD_2="sleep 5" +# Test 2n: TCP / p2mp tun / via NTLM proxy +RUN_TITLE_2n="testing tun/tcp/ntlm-proxy" +OPENVPN_CONF_2n="$OPENVPN_BASE_P2MP --dev tun --proto tcp --remote $REMOTE --port 51194 + --http-proxy 192.168.1.2 8080 $KEYBASE/t_client_auth.txt ntlm --http-proxy-option VERSION 1.1" +PING4_HOSTS_2n="10.100.51.1 10.100.0.1" +PING6_HOSTS_2n="2001:db8::1 2001:db8:a051::1" +# skip test if NTLM support is not available +CHECK_SKIP_2n="${top_builddir}/tests/ntlm_support" + # Test 3: UDP / p2p tun # ...
tests/t_client.sh.in +14 -0
@@ -291,12 +291,14 @@ # main test loop # ---------------------------------------------------------- SUMMARY_OK= +SUMMARY_SKIP= SUMMARY_FAIL= for SUF in $TEST_RUN_LIST do # get config variables eval test_prep=\"\$PREPARE_$SUF\" + eval test_check_skip=\"\$CHECK_SKIP_$SUF\" eval test_postinit=\"\$POSTINIT_CMD_$SUF\" eval test_cleanup=\"\$CLEANUP_$SUF\" eval test_run_title=\"\$RUN_TITLE_$SUF\"
@@ -318,6 +320,16 @@ output_start "### test run $SUF: '$test_run_title' ###" fail_count=0 + if [ -n "$test_check_skip" ]; then + output "check whether we need to skip: '$test_check_skip'" + if eval $test_check_skip; then : + else + output "skip check failed, SKIP test $SUF." + SUMMARY_SKIP="$SUMMARY_SKIP $SUF" + echo -e "$outbuf" ; continue + fi + fi + if [ -n "$test_prep" ]; then output "running preparation: '$test_prep'" eval $test_prep
@@ -455,8 +467,10 @@ done if [ -z "$SUMMARY_OK" ] ; then SUMMARY_OK=" none"; fi +if [ -z "$SUMMARY_SKIP" ] ; then SUMMARY_SKIP=" none"; fi if [ -z "$SUMMARY_FAIL" ] ; then SUMMARY_FAIL=" none"; fi echo "Test sets succeeded:$SUMMARY_OK." +echo "Test sets skipped:$SUMMARY_SKIP." echo "Test sets failed:$SUMMARY_FAIL." # remove trap handler
tests/unit_tests/openvpn/mock_msg.c +13 -1
@@ -31,8 +31,9 @@#include <stdlib.h> #include <setjmp.h> #include <stdint.h> +#ifndef NO_CMOCKA #include <cmocka.h> - +#endif #include "errlevel.h" #include "error.h"
@@ -74,6 +75,8 @@va_end (arglist); } +/* Allow to use mock_msg.c outside of UT */ +#ifndef NO_CMOCKA void assert_failed (const char *filename,int line,const char *condition) {
@@ -81,6 +84,15 @@/* Keep compiler happy. Should not happen, mock_assert() does not return */ exit(1); } +#else /* ifndef NO_CMOCKA */ +void +assert_failed (const char *filename,int line,const char *condition) +{ +msg (M_FATAL ,"Assertion failed at %s:%d (%s)" , filename, line, condition ? condition :"" ); +_exit (1 ); +} +#endif +/* * Fail memory allocation. Don't use msg() because it tries
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/521?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I13ea6752c8d102eabcc579e391828c05d5322899
Gerrit-Change-Number: 521
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-MessageType: merged