Skip to content

Commit d242890

Browse files
flichtenheldcron2
authored andcommitted
unit_tests: Remove useless wrapping for argv/buffer tests
If not using mock() or check_expected(), and not linking the original function, then there is no need for wrapping support. Change-Id: I937105abeb5e8f796bf6bbe8432972adb60b3e2a Signed-off-by: Frank Lichtenheld <[email protected]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1243 Message-Id: <[email protected]> URL: https://sourceforge.net/p/openvpn/mailman/message/59243508/ Signed-off-by: Gert Doering <[email protected]>
1 parent ebf781b commit d242890

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

CMakeLists.txt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ if (BUILD_TESTING)
654654
endif ()
655655

656656
set(unit_tests
657+
"test_argv"
657658
"test_auth_token"
658659
"test_buffer"
659660
"test_crypto"
@@ -684,7 +685,6 @@ if (BUILD_TESTING)
684685
# Clang-cl (which is also MSVC) is wrongly detected to support wrap
685686
if (NOT MSVC AND "${LD_SUPPORTS_WRAP}")
686687
list(APPEND unit_tests
687-
"test_argv"
688688
"test_tls_crypt"
689689
)
690690
endif ()
@@ -887,13 +887,10 @@ if (BUILD_TESTING)
887887
src/openvpn/list.c
888888
)
889889

890-
if (TARGET test_argv)
891-
target_link_options(test_argv PRIVATE -Wl,--wrap=parse_line)
892-
target_sources(test_argv PRIVATE
893-
tests/unit_tests/openvpn/mock_get_random.c
894-
src/openvpn/argv.c
895-
)
896-
endif ()
890+
target_sources(test_argv PRIVATE
891+
tests/unit_tests/openvpn/mock_get_random.c
892+
src/openvpn/argv.c
893+
)
897894

898895
if (TARGET test_cryptoapi)
899896
target_sources(test_cryptoapi PRIVATE

tests/unit_tests/openvpn/Makefile.am

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ EXTRA_DIST = input
44

55
AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) Unit-Tests'
66

7-
test_binaries = crypto_testdriver packet_id_testdriver auth_token_testdriver \
7+
test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \
88
ncp_testdriver misc_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 += argv_testdriver buffer_testdriver
1312
if !WIN32
1413
test_binaries += tls_crypt_testdriver
1514
endif
@@ -36,7 +35,7 @@ check_PROGRAMS += networking_testdriver
3635
endif
3736

3837
argv_testdriver_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@
39-
argv_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn -Wl,--wrap=parse_line
38+
argv_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
4039
argv_testdriver_SOURCES = test_argv.c \
4140
mock_msg.c mock_msg.h test_common.h \
4241
mock_get_random.c \
@@ -46,7 +45,7 @@ argv_testdriver_SOURCES = test_argv.c \
4645
$(top_srcdir)/src/openvpn/argv.c
4746

4847
buffer_testdriver_CFLAGS = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@
49-
buffer_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn -Wl,--wrap=parse_line
48+
buffer_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
5049
buffer_testdriver_SOURCES = test_buffer.c \
5150
mock_msg.c mock_msg.h test_common.h \
5251
mock_get_random.c \

tests/unit_tests/openvpn/test_argv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#define SCRIPT_CMD "\"" PATH1 PATH2 "\"" PARAM1 "\"" PARAM2 "\""
2323

2424
int
25-
__wrap_parse_line(const char *line, char **p, const int n, const char *file, const int line_num,
26-
msglvl_t msglevel, struct gc_arena *gc)
25+
parse_line(const char *line, char **p, const int n, const char *file, const int line_num,
26+
msglvl_t msglevel, struct gc_arena *gc)
2727
{
2828
p[0] = PATH1 PATH2;
2929
p[1] = PARAM1;

0 commit comments

Comments
 (0)