From: "cron2 (Code Review)" Date: Wed, 8 Oct 2025 16:24:26 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <6cde8893d037f8b861bdba0076c9a16f63133a19-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="8Ydj/d28Ldo="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: test_options_parse: Remove --wrap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: plaisthos , openvpn-devel --8Ydj/d28Ldo= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/12= 58?usp=3Demail ) Change subject: test_options_parse: Remove --wrap ...................................................................... test_options_parse: Remove --wrap After removing --wrap from some other tests in a previous commit I got confused here myself. --wrap is really only needed when you have the original function linked in. Somehow I thought the call ordering and mocking logic needed this. But this is wrong, so no need to use --wrap here since we currently do not link any of those functions. Change-Id: I60df1e61ed89be52e9d032b5b49133a784f9811e Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1258 Message-Id: <20251008161357.5679-1-gert@...1296...> URL: https://sourceforge.net/p/openvpn/mailman/message/59244071/ Signed-off-by: Gert Doering --- M CMakeLists.txt M tests/unit_tests/openvpn/Makefile.am M tests/unit_tests/openvpn/test_options_parse.c 3 files changed, 38 insertions(+), 51 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37bfc03..9511bda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -660,6 +660,7 @@ "test_crypto" "test_misc" "test_ncp" + "test_options_parse" "test_packet_id" "test_pkt" "test_provider" @@ -685,7 +686,6 @@ # Clang-cl (which is also MSVC) is wrongly detected to support wrap if (NOT MSVC AND "${LD_SUPPORTS_WRAP}") list(APPEND unit_tests - "test_options_parse" "test_tls_crypt" ) endif () @@ -827,19 +827,11 @@ src/compat/compat-strsep.c ) - if (TARGET test_options_parse) - target_link_options(test_options_parse PRIVATE - -Wl,--wrap=3Dadd_option - -Wl,--wrap=3Dremove_option - -Wl,--wrap=3Dupdate_option - -Wl,--wrap=3Dusage + target_sources(test_options_parse PRIVATE + tests/unit_tests/openvpn/mock_get_random.c + src/openvpn/options_parse.c + src/openvpn/options_util.c ) - target_sources(test_options_parse PRIVATE - tests/unit_tests/openvpn/mock_get_random.c - src/openvpn/options_parse.c - src/openvpn/options_util.c - ) - endif () target_sources(test_packet_id PRIVATE tests/unit_tests/openvpn/mock_get_random.c diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvp= n/Makefile.am index 8e94665..05c0ea5 100644 --- a/tests/unit_tests/openvpn/Makefile.am +++ b/tests/unit_tests/openvpn/Makefile.am @@ -5,11 +5,10 @@ AM_TESTSUITE_SUMMARY_HEADER =3D ' for $(PACKAGE_STRING) Unit-Tests' test_binaries =3D argv_testdriver buffer_testdriver crypto_testdriver pack= et_id_testdriver auth_token_testdriver \ - ncp_testdriver misc_testdriver pkt_testdriver ssl_testdriver \ + ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ss= l_testdriver \ user_pass_testdriver push_update_msg_testdriver provider_testdriver socke= t_testdriver if HAVE_LD_WRAP_SUPPORT -test_binaries +=3D options_parse_testdriver if !WIN32 test_binaries +=3D tls_crypt_testdriver endif @@ -192,11 +191,7 @@ endif options_parse_testdriver_CFLAGS =3D -I$(top_srcdir)/src/openvpn -I$(top_s= rcdir)/src/compat @TEST_CFLAGS@ -options_parse_testdriver_LDFLAGS =3D @TEST_LDFLAGS@ -L$(top_srcdir)/src/op= envpn \ - -Wl,--wrap=3Dadd_option \ - -Wl,--wrap=3Dupdate_option \ - -Wl,--wrap=3Dremove_option \ - -Wl,--wrap=3Dusage +options_parse_testdriver_LDFLAGS =3D @TEST_LDFLAGS@ -L$(top_srcdir)/src/op= envpn options_parse_testdriver_SOURCES =3D test_options_parse.c \ mock_msg.c mock_msg.h test_common.h \ mock_get_random.c \ diff --git a/tests/unit_tests/openvpn/test_options_parse.c b/tests/unit_tes= ts/openvpn/test_options_parse.c index 0ae37f5..59a3f6d 100644 --- a/tests/unit_tests/openvpn/test_options_parse.c +++ b/tests/unit_tests/openvpn/test_options_parse.c @@ -38,10 +38,10 @@ #include "mock_msg.h" void -__wrap_add_option(struct options *options, char *p[], bool is_inline, cons= t char *file, - int line, const int level, const msglvl_t msglevel, - const unsigned int permission_mask, unsigned int *option= _types_found, - struct env_set *es) +add_option(struct options *options, char *p[], bool is_inline, const char = *file, + int line, const int level, const msglvl_t msglevel, + const unsigned int permission_mask, unsigned int *option_types_= found, + struct env_set *es) { function_called(); check_expected(p); @@ -49,23 +49,23 @@ } void -__wrap_remove_option(struct context *c, struct options *options, char *p[]= , bool is_inline, - const char *file, int line, const msglvl_t msglevel, - const unsigned int permission_mask, unsigned int *opt= ion_types_found, - struct env_set *es) +remove_option(struct context *c, struct options *options, char *p[], bool = is_inline, + const char *file, int line, const msglvl_t msglevel, + const unsigned int permission_mask, unsigned int *option_typ= es_found, + struct env_set *es) { } void -__wrap_update_option(struct context *c, struct options *options, char *p[]= , bool is_inline, - const char *file, int line, const int level, const ms= glvl_t msglevel, - const unsigned int permission_mask, unsigned int *opt= ion_types_found, - struct env_set *es, unsigned int *update_options_foun= d) +update_option(struct context *c, struct options *options, char *p[], bool = is_inline, + const char *file, int line, const int level, const msglvl_t = msglevel, + const unsigned int permission_mask, unsigned int *option_typ= es_found, + struct env_set *es, unsigned int *update_options_found) { } void -__wrap_usage(void) +usage(void) { } @@ -270,34 +270,34 @@ p_expect_inlineopt[1] =3D "some text\nother text\n"; /* basic test */ - expect_function_call(__wrap_add_option); - expect_check(__wrap_add_option, p, check_tokens, p_expect_someopt); - expect_value(__wrap_add_option, is_inline, 0); - expect_function_call(__wrap_add_option); - expect_check(__wrap_add_option, p, check_tokens, p_expect_otheropt); - expect_value(__wrap_add_option, is_inline, 0); + expect_function_call(add_option); + expect_check(add_option, p, check_tokens, p_expect_someopt); + expect_value(add_option, is_inline, 0); + expect_function_call(add_option); + expect_check(add_option, p, check_tokens, p_expect_otheropt); + expect_value(add_option, is_inline, 0); read_single_config(&o, "someopt parm1 parm2\n otheropt 1 2"); /* -- gets stripped */ - expect_function_call(__wrap_add_option); - expect_check(__wrap_add_option, p, check_tokens, p_expect_someopt); - expect_value(__wrap_add_option, is_inline, 0); - expect_function_call(__wrap_add_option); - expect_check(__wrap_add_option, p, check_tokens, p_expect_otheropt); - expect_value(__wrap_add_option, is_inline, 0); + expect_function_call(add_option); + expect_check(add_option, p, check_tokens, p_expect_someopt); + expect_value(add_option, is_inline, 0); + expect_function_call(add_option); + expect_check(add_option, p, check_tokens, p_expect_otheropt); + expect_value(add_option, is_inline, 0); read_single_config(&o, "someopt parm1 parm2\n\t--otheropt 1 2"); /* inline options */ - expect_function_call(__wrap_add_option); - expect_check(__wrap_add_option, p, check_tokens, p_expect_inlineopt); - expect_value(__wrap_add_option, is_inline, 1); + expect_function_call(add_option); + expect_check(add_option, p, check_tokens, p_expect_inlineopt); + expect_value(add_option, is_inline, 1); read_single_config(&o, "\nsome text\nother text\n"); p_expect_inlineopt[0] =3D "inlineopt"; p_expect_inlineopt[1] =3D A_TIMES_256 A_TIMES_256 A_TIMES_256 A_TIMES_= 256 A_TIMES_256 "\n"; - expect_function_call(__wrap_add_option); - expect_check(__wrap_add_option, p, check_tokens, p_expect_inlineopt); - expect_value(__wrap_add_option, is_inline, 1); + expect_function_call(add_option); + expect_check(add_option, p, check_tokens, p_expect_inlineopt); + expect_value(add_option, is_inline, 1); read_single_config(&o, "\n" A_TIMES_256 A_TIMES_256 A_TIMES= _256 A_TIMES_256 A_TIMES_256 "\n"); gc_free(&o.gc); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1258?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: merged Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I60df1e61ed89be52e9d032b5b49133a784f9811e Gerrit-Change-Number: 1258 Gerrit-PatchSet: 2 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --8Ydj/d28Ldo= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

test_options_parse: Remove --wrap

After r= emoving --wrap from some other tests in
a previous commit I got confused= here myself.
--wrap is really only needed when you have the
original= function linked in. Somehow I thought
the call ordering and mocking log= ic needed this.

But this is wrong, so no need to use --wrap here
= since we currently do not link any of those
functions.

Change-Id:= I60df1e61ed89be52e9d032b5b49133a784f9811e
Signed-off-by: Frank Lichtenh= eld <frank@...2641...>
Acked-by: Gert Doering <gert@...1296...&= gt;
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1258
Message-I= d: <20251008161357.5679-1-gert@...1296...>
URL: https://sourceforg= e.net/p/openvpn/mailman/message/59244071/
Signed-off-by: Gert Doering &l= t;gert@...1296...>
---
M CMakeLists.txt
M tests/unit_tests/open= vpn/Makefile.am
M tests/unit_tests/openvpn/test_options_parse.c
3 fil= es changed, 38 insertions(+), 51 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 37bfc= 03..9511bda 100644
--- a/CMakeLists.txt
+++= b/CMakeLists.txt
@@ -660,6 +660,7 @@
= "test_crypto"
"test_misc"<= /span>
"test_ncp"
+ "test_options_parse"
= "test_packet_id"
"te= st_pkt"
"test_provider"
<= span>@@ -685,7 +686,6 @@

# Clang-cl (which is also MSV= C) is wrongly detected to support wrap
if (NOT MSVC AN= D "${LD_SUPPORTS_WRAP}")
list(APPEND uni= t_tests
- &q= uot;test_options_parse"
"test_tls_cr= ypt"
)
endif ()
@@ -827,19 +827,11 @@
src/compat/compa= t-strsep.c
)

- if (TARGET test_options_parse)=
- target_link_options(= test_options_parse PRIVATE
- -Wl,--wrap=3Dadd_option
- -Wl,--wrap=3Dremove_option
- -Wl,--wrap=3Dupdate_option<= /span>
- -Wl,--wrap=3Dusag= e
+ target_sources= (test_options_parse PRIVATE
+ tests/unit_tests/openvpn/mock_get_random.c
+ src/openvpn/options_parse.c<= /span>
+ src/openvpn/= options_util.c
)
- target_sources(test_options_parse PRIVATE
- tests/unit_test= s/openvpn/mock_get_random.c
- src/openvpn/options_parse.c
- src/openvpn/options_util.c
- )

- endif ()

target_sources(test_packet_id PRIVATE

tests/= unit_tests/openvpn/mock_get_random.c
diff --git a/tests/uni= t_tests/openvpn/Makefile.am b/tests/unit_tests/openvpn/Makefile.amindex 8e94665..05c0ea5 100644
--- a/tests/unit_test= s/openvpn/Makefile.am
+++ b/tests/unit_tests/openvpn/Makefi= le.am
@@ -5,11 +5,10 @@
AM_TESTSUITE_SUMMA= RY_HEADER =3D ' for $(PACKAGE_STRING) Unit-Tests'
=
test_binaries =3D argv_testdriver buffer_testdriver crypt= o_testdriver packet_id_testdriver auth_token_testdriver \
- ncp_testdriver misc_testdriver pkt_tes= tdriver ssl_testdriver \
+ ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdrive= r ssl_testdriver \
user_pass_testdriver push_update_msg_t= estdriver provider_testdriver socket_testdriver
if HAVE_LD_WRAP_SUPPORT
-test_binaries +=3D options_parse_testdriver
if != WIN32
test_binaries +=3D tls_crypt_testdriver
endif

@@ -192,11 +191,7 @@
endif

options_parse_testdriver_CFLAGS =3D -I$(top= _srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@
-options_parse_testdriver_LDFLAGS = =3D @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn \

- -Wl,--wrap=3Dadd_option \
- -Wl,--wrap=3Dupdate_option \
- -Wl,--wrap=3Dremove_option \
- -Wl,--wrap=3Dusage<= br>+options_parse_testdriver_LD= FLAGS =3D @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
optio= ns_parse_testdriver_SOURCES =3D test_options_parse.c \
mo= ck_msg.c mock_msg.h test_common.h \
mock_get_random.c \
diff --git a/tests/unit_tests/openvpn/test_options_parse.c b= /tests/unit_tests/openvpn/test_options_parse.c
index 0ae37f= 5..59a3f6d 100644
--- a/tests/unit_tests/openvpn/test_optio= ns_parse.c
+++ b/tests/unit_tests/openvpn/test_options_pars= e.c
@@ -38,10 +38,10 @@
#include "moc= k_msg.h"

void
-__wrap_add_option(struct options *options, = char *p[], bool is_inline, const char *file,
- int line, const int level, const m= sglvl_t msglevel,
- = const unsigned int permission_mask, unsigned int *option_type= s_found,
- = struct env_set *es)
+add_option(struct options *options, char *p[], bool is_inline, const c= har *file,
+ = int line, const int level, const msglvl_t msglevel,
+ const unsigned int permission_= mask, unsigned int *option_types_found,
+ struct env_set *es)
{
function_called();
check_expected(p);<= /span>
@@ -49,23 +49,23 @@
}

void
-__= wrap_remove_option(struct context *c, struct options *options, char *p[], b= ool is_inline,
- = const char *file, int line, const msglvl_t msglevel,- const uns= igned int permission_mask, unsigned int *option_types_found,
- struct env_set = *es)

+remove_option(s= truct context *c, struct options *options, char *p[], bool is_inline,
+ const char = *file, int line, const msglvl_t msglevel,
+ const unsigned int permission_mask, uns= igned int *option_types_found,
+ struct env_set *es)
{
<= span> }


void
-__wrap_update_option(struct context *c, struct op= tions *options, char *p[], bool is_inline,
- const char *file, int line, const= int level, const msglvl_t msglevel,
- const unsigned int permission_mask, uns= igned int *option_types_found,
- struct env_set *es, unsigned int *update_opti= ons_found)
+update_op= tion(struct context *c, struct options *options, char *p[], bool is_inline,=
+ const= char *file, int line, const int level, const msglvl_t msglevel,
= + const unsigned i= nt permission_mask, unsigned int *option_types_found,
+ struct env_set *es, unsigne= d int *update_options_found)
{
}
void
-__wrap_usage(void)
+usage(void)
{
}
=
@@ -270,34 +270,34 @@
p_expect_inlin= eopt[1] =3D "some text\nother text\n";
/* basic test */
- expect_function_call(__wrap_add_option);
- expect_check(__wrap_add_option, p, chec= k_tokens, p_expect_someopt);
- expect_value(__wrap_add_option, is_inline, 0);
- expect_function_call(__wrap_add_opt= ion);
- expect_check= (__wrap_add_option, p, check_tokens, p_expect_otheropt);
- expect_value(__wrap_add_option, is_i= nline, 0);
+ expec= t_function_call(add_option);
+ expect_check(add_option, p, check_tokens, p_expect_someopt);
+ expect_value(add_= option, is_inline, 0);
+ expect_check(add_option, p, check_tokens, p_expect= _otheropt);
+ expe= ct_value(add_option, is_inline, 0);
read_single_config= (&o, "someopt parm1 parm2\n otheropt 1 2");
=
/* -- gets stripped */
- expect_function_call(__wrap_add_option);=
- expect_check(__wrap_add_= option, p, check_tokens, p_expect_someopt);
- expect_value(__wrap_add_option, is_inline, 0);
- expect_function_call= (__wrap_add_option);
- = expect_check(__wrap_add_option, p, check_tokens, p_expect_otheropt);

- expect_value(__wrap_a= dd_option, is_inline, 0);
+ expect_function_call(add_option);
+ expect_check(add_option, p, check_tokens, p_exp= ect_someopt);
+ ex= pect_value(add_option, is_inline, 0);
+ expect_function_call(add_option);
+ expect_check(add_option, p, check_t= okens, p_expect_otheropt);
+ expect_value(add_option, is_inline, 0);
rea= d_single_config(&o, "someopt parm1 parm2\n\t--otheropt 1 2");=

/* inline options */
- expect_function_call(__wrap_add_= option);

- expect_ch= eck(__wrap_add_option, p, check_tokens, p_expect_inlineopt);
- expect_value(__wrap_add_option, = is_inline, 1);
+ e= xpect_function_call(add_option);
+ expect_check(add_option, p, check_tokens, p_expect_inlineo= pt);
+ expect_valu= e(add_option, is_inline, 1);
read_single_config(&o= , "<inlineopt>\nsome text\nother text\n</inlineopt>")= ;

p_expect_inlineopt[0] =3D "in= lineopt";
p_expect_inlineopt[1] =3D A_TIMES_256 A= _TIMES_256 A_TIMES_256 A_TIMES_256 A_TIMES_256 "\n";
- expect_function_call(__wrap_ad= d_option);
- expect_= check(__wrap_add_option, p, check_tokens, p_expect_inlineopt);
- expect_value(__wrap_add_option= , is_inline, 1);
+ = expect_function_call(add_option);
+ expect_check(add_option, p, check_tokens, p_expect_inlin= eopt);
+ expect_va= lue(add_option, is_inline, 1);
read_single_config(&= ;o, "<inlineopt>\n" A_TIMES_256 A_TIMES_256 A_TIMES_256 A_T= IMES_256 A_TIMES_256 "\n</inlineopt>");

gc_free(&o.gc);

To view, visit change 1258. To unsubscribe, or for help writing mail filters= , visit settings= .

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I60df1e61ed89be52e9d032b5b49= 133a784f9811e
Gerrit-Change-Number: 1258
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --8Ydj/d28Ldo=--