]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
test_options_parse: Remove --wrap
authorFrank Lichtenheld <frank@lichtenheld.com>
Wed, 8 Oct 2025 16:13:52 +0000 (18:13 +0200)
committerGert Doering <gert@greenie.muc.de>
Wed, 8 Oct 2025 16:18:07 +0000 (18:18 +0200)
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>
CMakeLists.txt
tests/unit_tests/openvpn/Makefile.am
tests/unit_tests/openvpn/test_options_parse.c

index 37bfc0346ae789cf077b9f7567a7c9bf4769d289..9511bda4b3217e421347ce1680f88565f4ce6d70 100644 (file)
@@ -660,6 +660,7 @@ if (BUILD_TESTING)
         "test_crypto"
         "test_misc"
         "test_ncp"
+        "test_options_parse"
         "test_packet_id"
         "test_pkt"
         "test_provider"
@@ -685,7 +686,6 @@ if (BUILD_TESTING)
     # 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 @@ if (BUILD_TESTING)
         src/compat/compat-strsep.c
         )
 
-    if (TARGET test_options_parse)
-        target_link_options(test_options_parse PRIVATE
-            -Wl,--wrap=add_option
-            -Wl,--wrap=remove_option
-            -Wl,--wrap=update_option
-           -Wl,--wrap=usage
-        )
-        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
index 8e946653071f06c71ad93df854fc0fc897824659..05c0ea536bd22533ecffae66bf01ad7fb92bdc92 100644 (file)
@@ -5,11 +5,10 @@ EXTRA_DIST = input
 AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) Unit-Tests'
 
 test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \
-       ncp_testdriver misc_testdriver pkt_testdriver ssl_testdriver \
+       ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \
        user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver
 
 if HAVE_LD_WRAP_SUPPORT
-test_binaries += options_parse_testdriver
 if !WIN32
 test_binaries += tls_crypt_testdriver
 endif
@@ -192,11 +191,7 @@ networking_testdriver_SOURCES = test_networking.c mock_msg.c \
 endif
 
 options_parse_testdriver_CFLAGS  = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@
-options_parse_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn \
-       -Wl,--wrap=add_option \
-       -Wl,--wrap=update_option \
-       -Wl,--wrap=remove_option \
-       -Wl,--wrap=usage
+options_parse_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
 options_parse_testdriver_SOURCES = test_options_parse.c \
        mock_msg.c mock_msg.h test_common.h \
        mock_get_random.c \
index 0ae37f597ba9dbc88d1d3982a327c03cd71ffbd7..59a3f6df60a77bae04ed0e27e71a9082b38f1985 100644 (file)
 #include "mock_msg.h"
 
 void
-__wrap_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)
+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 @@ __wrap_add_option(struct options *options, char *p[], bool is_inline, const char
 }
 
 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 *option_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_types_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 msglvl_t msglevel,
-                     const unsigned int permission_mask, unsigned int *option_types_found,
-                     struct env_set *es, unsigned int *update_options_found)
+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_types_found,
+              struct env_set *es, unsigned int *update_options_found)
 {
 }
 
 void
-__wrap_usage(void)
+usage(void)
 {
 }
 
@@ -270,34 +270,34 @@ test_read_config(void **state)
     p_expect_inlineopt[1] = "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, "<inlineopt>\nsome text\nother text\n</inlineopt>");
 
     p_expect_inlineopt[0] = "inlineopt";
     p_expect_inlineopt[1] = 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, "<inlineopt>\n" A_TIMES_256 A_TIMES_256 A_TIMES_256 A_TIMES_256 A_TIMES_256 "\n</inlineopt>");
 
     gc_free(&o.gc);