From patchwork Wed Oct 8 16:13:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4487 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:7d42:b0:72f:f16c:e055 with SMTP id fr2csp1055566mab; Wed, 8 Oct 2025 09:14:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW/L5+cxB8GVoQXPAc9ghRgNYonqO1w/all7FLg6o8VfZWaAPlKsfD6cnrhOTK6Et8iDL5lecajHeY=@openvpn.net X-Google-Smtp-Source: AGHT+IE3H+F51TrIwrWasuHvFXY131oefs1MAT2J3HlZT1UL+LtYQgewPHqHDL2A6UjFciPTb7GQ X-Received: by 2002:a05:6808:4a49:20b0:441:8385:21c4 with SMTP id 5614622812f47-44183852b94mr985651b6e.26.1759940051801; Wed, 08 Oct 2025 09:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1759940051; cv=none; d=google.com; s=arc-20240605; b=J4hQLiELAFq30ZO6om/oCTmKEV5YcoRnbjy37huW2SRvKG/z66sr0EgtVPCvCrPyi1 Z9LDyykzCSpgBez+2yK1USlLkb8RYk3XwaNGqqQcDBdNaKEM4XAdCo0ap3S3x+20n53v 5xTmiLFpKB8EmH9zQRCWGcdSRkZFE1GO5Wj24E3kg+Z3io9iDGOPXxvvd+JbtrnfkrV7 NRJHYNC8Z/rorcc4PvPy/1Ln4ru6vzyERMSPExXjrPyZF5+Y/FlAFCFWofOCfqBlB8+P 0yM4j5uYpNqKMn4XlEsNgt5yfNZz/Tioad5NvhBW9FmYuHW+2Y9FXNKtCXMsacLF++a+ F4Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=xinjx+oY27p5tUdY2udJUBZ9bm/PibXRI3wjwiiQCSo=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=f8AYXJ+xFrs0R5cV3ZgRXquios1mAYo402gAkUOC5FZq2xGWAn5nLGuy1wzLYW6G3D LwE1YgM141yBlAdyf4KXddKACAy5kwDISzOMt7Z77IEyvCSwqgxpffEauBZGHPtBFSyD r3fxNVSvIDTwiG1Zwezyb+cljH0Owyy4ogIbNCLYOXm9HdOqLzrcVTJwiQsAc4EHRHhZ 7cd1OxoUqjD+l4I/qGSFBSL9+oM67PLuo/IZu8iVPuhPTRBtefME6oIk84Ue49PIa0Y1 ZucyRTh4DETtc2EDgZ83uTppYmz2Ypsh6Pv7F3ddBvu2nIdL9R9dh7wDHFspTF4N8gki x7Cw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=a22pV6Xn; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Rw31Ed6a; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=HTaK8sNr; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 006d021491bc7-64e1802ea2asi4354531eaf.3.2025.10.08.09.14.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Oct 2025 09:14:11 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=a22pV6Xn; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Rw31Ed6a; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=HTaK8sNr; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xinjx+oY27p5tUdY2udJUBZ9bm/PibXRI3wjwiiQCSo=; b=a22pV6XnLXG/vHEAwKKxET2N32 Cyv2z81FgAUxThOiFL3gCT77sxVyxVE5qOAzi1sqiSGYc5IKMJ6K3l1rtXC4CPcIeYgTDOL7XRA+5 UUhqw9569v3PoUnrl/BIha/ONhuxyaBDXcxoHPSn4EllnCRrW4JM4SuXmbC7/FTBYMus=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1v6Wno-0001E6-DQ; Wed, 08 Oct 2025 16:14:08 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1v6Wnm-0001Dy-Fn for openvpn-devel@lists.sourceforge.net; Wed, 08 Oct 2025 16:14:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=As1mLh3Wno/cehWyv1sHF5tARZqWYIhyT+wHeEZyf2c=; b=Rw31Ed6asTBY9dH6lVWHgzUxTU n+FSOfEvXQaD6TFla1PXLXuj+3uh858NJnnI86XbuvfNckGtgsfB5K2WLVG4tcyi02JiCZuISW5dO pE5WklYMUdJLvmppVGfAZx4joJlS/w4ZnFOC8XnDSCAdeaH4sKEwt8MeyiOSIALv2eak=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=As1mLh3Wno/cehWyv1sHF5tARZqWYIhyT+wHeEZyf2c=; b=HTaK8sNr+XYLc445sb40CrTXfO kFBNAkXBgiLQNZH5YYOx6ybEP6re4AZIc7MpMzEhBlldPb6lXUYyCI8dRAIu7gAKpyoKvIDbwlz1k in8K2R3mjBQ31quX4WdwSkUkwQ1ozOg5abFj4gLlg3x2IiCklNil9Di3EJv6+8LArs7w=; Received: from [193.149.48.134] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1v6Wnl-0004Hl-CN for openvpn-devel@lists.sourceforge.net; Wed, 08 Oct 2025 16:14:06 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 598GDwP3005695 for ; Wed, 8 Oct 2025 18:13:58 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 598GDw5U005694 for openvpn-devel@lists.sourceforge.net; Wed, 8 Oct 2025 18:13:58 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 8 Oct 2025 18:13:52 +0200 Message-ID: <20251008161357.5679-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.49.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-1.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Frank Lichtenheld 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 orde [...] Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1v6Wnl-0004Hl-CN Subject: [Openvpn-devel] [PATCH v1] test_options_parse: Remove --wrap X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1845430899452275065?= X-GMAIL-MSGID: =?utf-8?q?1845430899452275065?= From: Frank Lichtenheld 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 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1258 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering 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=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 diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvpn/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 = ' 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 @@ 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 \ diff --git a/tests/unit_tests/openvpn/test_options_parse.c b/tests/unit_tests/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, 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 @@ } 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 @@ 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, "\nsome text\nother text\n"); 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, "\n" A_TIMES_256 A_TIMES_256 A_TIMES_256 A_TIMES_256 A_TIMES_256 "\n"); gc_free(&o.gc);