Skip to content

Commit 8f3e3de

Browse files
flichtenheldcron2
authored andcommitted
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 <[email protected]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1258 Message-Id: <[email protected]> URL: https://sourceforge.net/p/openvpn/mailman/message/59244071/ Signed-off-by: Gert Doering <[email protected]>
1 parent a06b9b2 commit 8f3e3de

File tree

3 files changed

+38
-51
lines changed

3 files changed

+38
-51
lines changed

CMakeLists.txt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ if (BUILD_TESTING)
660660
"test_crypto"
661661
"test_misc"
662662
"test_ncp"
663+
"test_options_parse"
663664
"test_packet_id"
664665
"test_pkt"
665666
"test_provider"
@@ -685,7 +686,6 @@ if (BUILD_TESTING)
685686
# Clang-cl (which is also MSVC) is wrongly detected to support wrap
686687
if (NOT MSVC AND "${LD_SUPPORTS_WRAP}")
687688
list(APPEND unit_tests
688-
"test_options_parse"
689689
"test_tls_crypt"
690690
)
691691
endif ()
@@ -827,19 +827,11 @@ if (BUILD_TESTING)
827827
src/compat/compat-strsep.c
828828
)
829829

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
841834
)
842-
endif ()
843835

844836
target_sources(test_packet_id PRIVATE
845837
tests/unit_tests/openvpn/mock_get_random.c

tests/unit_tests/openvpn/Makefile.am

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ EXTRA_DIST = input
55
AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) Unit-Tests'
66

77
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 \
99
user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver
1010

1111
if HAVE_LD_WRAP_SUPPORT
12-
test_binaries += options_parse_testdriver
1312
if !WIN32
1413
test_binaries += tls_crypt_testdriver
1514
endif
@@ -192,11 +191,7 @@ networking_testdriver_SOURCES = test_networking.c mock_msg.c \
192191
endif
193192

194193
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
194+
options_parse_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
200195
options_parse_testdriver_SOURCES = test_options_parse.c \
201196
mock_msg.c mock_msg.h test_common.h \
202197
mock_get_random.c \

tests/unit_tests/openvpn/test_options_parse.c

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,34 @@
3838
#include "mock_msg.h"
3939

4040
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)
4545
{
4646
function_called();
4747
check_expected(p);
4848
check_expected(is_inline);
4949
}
5050

5151
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)
5656
{
5757
}
5858

5959
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)
6464
{
6565
}
6666

6767
void
68-
__wrap_usage(void)
68+
usage(void)
6969
{
7070
}
7171

@@ -270,34 +270,34 @@ test_read_config(void **state)
270270
p_expect_inlineopt[1] = "some text\nother text\n";
271271

272272
/* 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);
279279
read_single_config(&o, "someopt parm1 parm2\n otheropt 1 2");
280280

281281
/* -- 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);
288288
read_single_config(&o, "someopt parm1 parm2\n\t--otheropt 1 2");
289289

290290
/* 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);
294294
read_single_config(&o, "<inlineopt>\nsome text\nother text\n</inlineopt>");
295295

296296
p_expect_inlineopt[0] = "inlineopt";
297297
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);
301301
read_single_config(&o, "<inlineopt>\n" A_TIMES_256 A_TIMES_256 A_TIMES_256 A_TIMES_256 A_TIMES_256 "\n</inlineopt>");
302302

303303
gc_free(&o.gc);

0 commit comments

Comments
 (0)