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 <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1258
Message-Id: <20251008161357.5679-1-gert@greenie.muc.de>
URL: https://sourceforge.net/p/openvpn/mailman/message/59244071/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
| ... | ... |
@@ -660,6 +660,7 @@ if (BUILD_TESTING) |
| 660 | 660 |
"test_crypto" |
| 661 | 661 |
"test_misc" |
| 662 | 662 |
"test_ncp" |
| 663 |
+ "test_options_parse" |
|
| 663 | 664 |
"test_packet_id" |
| 664 | 665 |
"test_pkt" |
| 665 | 666 |
"test_provider" |
| ... | ... |
@@ -685,7 +686,6 @@ if (BUILD_TESTING) |
| 685 | 685 |
# Clang-cl (which is also MSVC) is wrongly detected to support wrap |
| 686 | 686 |
if (NOT MSVC AND "${LD_SUPPORTS_WRAP}")
|
| 687 | 687 |
list(APPEND unit_tests |
| 688 |
- "test_options_parse" |
|
| 689 | 688 |
"test_tls_crypt" |
| 690 | 689 |
) |
| 691 | 690 |
endif () |
| ... | ... |
@@ -827,19 +827,11 @@ if (BUILD_TESTING) |
| 827 | 827 |
src/compat/compat-strsep.c |
| 828 | 828 |
) |
| 829 | 829 |
|
| 830 |
- if (TARGET test_options_parse) |
|
| 831 |
- target_link_options(test_options_parse PRIVATE |
|
| 832 |
- -Wl,--wrap=add_option |
|
| 833 |
- -Wl,--wrap=remove_option |
|
| 834 |
- -Wl,--wrap=update_option |
|
| 835 |
- -Wl,--wrap=usage |
|
| 836 |
- ) |
|
| 837 |
- target_sources(test_options_parse PRIVATE |
|
| 838 |
- tests/unit_tests/openvpn/mock_get_random.c |
|
| 839 |
- src/openvpn/options_parse.c |
|
| 840 |
- src/openvpn/options_util.c |
|
| 830 |
+ target_sources(test_options_parse PRIVATE |
|
| 831 |
+ tests/unit_tests/openvpn/mock_get_random.c |
|
| 832 |
+ src/openvpn/options_parse.c |
|
| 833 |
+ src/openvpn/options_util.c |
|
| 841 | 834 |
) |
| 842 |
- endif () |
|
| 843 | 835 |
|
| 844 | 836 |
target_sources(test_packet_id PRIVATE |
| 845 | 837 |
tests/unit_tests/openvpn/mock_get_random.c |
| ... | ... |
@@ -5,11 +5,10 @@ EXTRA_DIST = input |
| 5 | 5 |
AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) Unit-Tests' |
| 6 | 6 |
|
| 7 | 7 |
test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \ |
| 8 |
- ncp_testdriver misc_testdriver pkt_testdriver ssl_testdriver \ |
|
| 8 |
+ ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \ |
|
| 9 | 9 |
user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver |
| 10 | 10 |
|
| 11 | 11 |
if HAVE_LD_WRAP_SUPPORT |
| 12 |
-test_binaries += options_parse_testdriver |
|
| 13 | 12 |
if !WIN32 |
| 14 | 13 |
test_binaries += tls_crypt_testdriver |
| 15 | 14 |
endif |
| ... | ... |
@@ -192,11 +191,7 @@ networking_testdriver_SOURCES = test_networking.c mock_msg.c \ |
| 192 | 192 |
endif |
| 193 | 193 |
|
| 194 | 194 |
options_parse_testdriver_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ |
| 195 |
-options_parse_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn \ |
|
| 196 |
- -Wl,--wrap=add_option \ |
|
| 197 |
- -Wl,--wrap=update_option \ |
|
| 198 |
- -Wl,--wrap=remove_option \ |
|
| 199 |
- -Wl,--wrap=usage |
|
| 195 |
+options_parse_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn |
|
| 200 | 196 |
options_parse_testdriver_SOURCES = test_options_parse.c \ |
| 201 | 197 |
mock_msg.c mock_msg.h test_common.h \ |
| 202 | 198 |
mock_get_random.c \ |
| ... | ... |
@@ -38,10 +38,10 @@ |
| 38 | 38 |
#include "mock_msg.h" |
| 39 | 39 |
|
| 40 | 40 |
void |
| 41 |
-__wrap_add_option(struct options *options, char *p[], bool is_inline, const char *file, |
|
| 42 |
- int line, const int level, const msglvl_t msglevel, |
|
| 43 |
- const unsigned int permission_mask, unsigned int *option_types_found, |
|
| 44 |
- struct env_set *es) |
|
| 41 |
+add_option(struct options *options, char *p[], bool is_inline, const char *file, |
|
| 42 |
+ int line, const int level, const msglvl_t msglevel, |
|
| 43 |
+ const unsigned int permission_mask, unsigned int *option_types_found, |
|
| 44 |
+ struct env_set *es) |
|
| 45 | 45 |
{
|
| 46 | 46 |
function_called(); |
| 47 | 47 |
check_expected(p); |
| ... | ... |
@@ -49,23 +49,23 @@ __wrap_add_option(struct options *options, char *p[], bool is_inline, const char |
| 49 | 49 |
} |
| 50 | 50 |
|
| 51 | 51 |
void |
| 52 |
-__wrap_remove_option(struct context *c, struct options *options, char *p[], bool is_inline, |
|
| 53 |
- const char *file, int line, const msglvl_t msglevel, |
|
| 54 |
- const unsigned int permission_mask, unsigned int *option_types_found, |
|
| 55 |
- struct env_set *es) |
|
| 52 |
+remove_option(struct context *c, struct options *options, char *p[], bool is_inline, |
|
| 53 |
+ const char *file, int line, const msglvl_t msglevel, |
|
| 54 |
+ const unsigned int permission_mask, unsigned int *option_types_found, |
|
| 55 |
+ struct env_set *es) |
|
| 56 | 56 |
{
|
| 57 | 57 |
} |
| 58 | 58 |
|
| 59 | 59 |
void |
| 60 |
-__wrap_update_option(struct context *c, struct options *options, char *p[], bool is_inline, |
|
| 61 |
- const char *file, int line, const int level, const msglvl_t msglevel, |
|
| 62 |
- const unsigned int permission_mask, unsigned int *option_types_found, |
|
| 63 |
- struct env_set *es, unsigned int *update_options_found) |
|
| 60 |
+update_option(struct context *c, struct options *options, char *p[], bool is_inline, |
|
| 61 |
+ const char *file, int line, const int level, const msglvl_t msglevel, |
|
| 62 |
+ const unsigned int permission_mask, unsigned int *option_types_found, |
|
| 63 |
+ struct env_set *es, unsigned int *update_options_found) |
|
| 64 | 64 |
{
|
| 65 | 65 |
} |
| 66 | 66 |
|
| 67 | 67 |
void |
| 68 |
-__wrap_usage(void) |
|
| 68 |
+usage(void) |
|
| 69 | 69 |
{
|
| 70 | 70 |
} |
| 71 | 71 |
|
| ... | ... |
@@ -270,34 +270,34 @@ test_read_config(void **state) |
| 270 | 270 |
p_expect_inlineopt[1] = "some text\nother text\n"; |
| 271 | 271 |
|
| 272 | 272 |
/* basic test */ |
| 273 |
- expect_function_call(__wrap_add_option); |
|
| 274 |
- expect_check(__wrap_add_option, p, check_tokens, p_expect_someopt); |
|
| 275 |
- expect_value(__wrap_add_option, is_inline, 0); |
|
| 276 |
- expect_function_call(__wrap_add_option); |
|
| 277 |
- expect_check(__wrap_add_option, p, check_tokens, p_expect_otheropt); |
|
| 278 |
- expect_value(__wrap_add_option, is_inline, 0); |
|
| 273 |
+ expect_function_call(add_option); |
|
| 274 |
+ expect_check(add_option, p, check_tokens, p_expect_someopt); |
|
| 275 |
+ expect_value(add_option, is_inline, 0); |
|
| 276 |
+ expect_function_call(add_option); |
|
| 277 |
+ expect_check(add_option, p, check_tokens, p_expect_otheropt); |
|
| 278 |
+ expect_value(add_option, is_inline, 0); |
|
| 279 | 279 |
read_single_config(&o, "someopt parm1 parm2\n otheropt 1 2"); |
| 280 | 280 |
|
| 281 | 281 |
/* -- gets stripped */ |
| 282 |
- expect_function_call(__wrap_add_option); |
|
| 283 |
- expect_check(__wrap_add_option, p, check_tokens, p_expect_someopt); |
|
| 284 |
- expect_value(__wrap_add_option, is_inline, 0); |
|
| 285 |
- expect_function_call(__wrap_add_option); |
|
| 286 |
- expect_check(__wrap_add_option, p, check_tokens, p_expect_otheropt); |
|
| 287 |
- expect_value(__wrap_add_option, is_inline, 0); |
|
| 282 |
+ expect_function_call(add_option); |
|
| 283 |
+ expect_check(add_option, p, check_tokens, p_expect_someopt); |
|
| 284 |
+ expect_value(add_option, is_inline, 0); |
|
| 285 |
+ expect_function_call(add_option); |
|
| 286 |
+ expect_check(add_option, p, check_tokens, p_expect_otheropt); |
|
| 287 |
+ expect_value(add_option, is_inline, 0); |
|
| 288 | 288 |
read_single_config(&o, "someopt parm1 parm2\n\t--otheropt 1 2"); |
| 289 | 289 |
|
| 290 | 290 |
/* inline options */ |
| 291 |
- expect_function_call(__wrap_add_option); |
|
| 292 |
- expect_check(__wrap_add_option, p, check_tokens, p_expect_inlineopt); |
|
| 293 |
- expect_value(__wrap_add_option, is_inline, 1); |
|
| 291 |
+ expect_function_call(add_option); |
|
| 292 |
+ expect_check(add_option, p, check_tokens, p_expect_inlineopt); |
|
| 293 |
+ expect_value(add_option, is_inline, 1); |
|
| 294 | 294 |
read_single_config(&o, "<inlineopt>\nsome text\nother text\n</inlineopt>"); |
| 295 | 295 |
|
| 296 | 296 |
p_expect_inlineopt[0] = "inlineopt"; |
| 297 | 297 |
p_expect_inlineopt[1] = A_TIMES_256 A_TIMES_256 A_TIMES_256 A_TIMES_256 A_TIMES_256 "\n"; |
| 298 |
- expect_function_call(__wrap_add_option); |
|
| 299 |
- expect_check(__wrap_add_option, p, check_tokens, p_expect_inlineopt); |
|
| 300 |
- expect_value(__wrap_add_option, is_inline, 1); |
|
| 298 |
+ expect_function_call(add_option); |
|
| 299 |
+ expect_check(add_option, p, check_tokens, p_expect_inlineopt); |
|
| 300 |
+ expect_value(add_option, is_inline, 1); |
|
| 301 | 301 |
read_single_config(&o, "<inlineopt>\n" A_TIMES_256 A_TIMES_256 A_TIMES_256 A_TIMES_256 A_TIMES_256 "\n</inlineopt>"); |
| 302 | 302 |
|
| 303 | 303 |
gc_free(&o.gc); |