From patchwork Wed Aug 26 18:53:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5283 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:4306:b0:87d:ab56:3700 with SMTP id q6csp7681717mae; Wed, 26 Aug 2026 11:54:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AHgh+RrVR2t24LVK7pEn3IUoJfzbr/y0pflsWnsq21CnMdeIOwBN++6bZIaKe6VOe1XNBcb9aYc1P+cOup4=@openvpn.net X-Received: by 2002:a05:6820:8585:10b0:69d:a4f0:4191 with SMTP id 006d021491bc7-6b1a03c602cmr7149667eaf.12.1787770443617; Wed, 26 Aug 2026 11:54:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1787770443; cv=none; d=google.com; s=arc-20260327; b=soOdkBwzUc359bfdOEpCKoOfWBSCudOhGnjwIIIU5O1xTwsu7IPiejkkcK8aXsUdcz 5nccVPm0oiMSSWlXF0CtbZz0FmrTpyc25i5xxm+BPCBC/lUR77sIUwiQJkG5AwmeESWI r414xxpPfOEaGvrrYewiXePrqLnvQkB3bb5r/R3+laeRmbkoOR6UEmSfg8N/2iPHaoEw 8OthdEK4hsZRLPgxeWE3ZTmpN6AxRN1S5/MxjNsNtLP0KZDv18UGx1NpNUdK2XhiXy5R UDh7WyBBx8DGbDkHQFkBjlg1XieWEJQ1o5hA7w9hfhl6zHxdBBvHcSUEN7ZU6shP55ph vr5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; 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=JRuqD1U5+LYYhiiAmHyC9rwTezZnKx3wlYNM/0zFqLs=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=Cu7iTBJvxtvBL6smO3kocae1bEmGf6CJns8+KMpdbN2l89qL1OFE0Fid4Ou75d9kVN eJKPlPYy7Pqra2aeTDoRnb7bmHdZfb33aG2KT9NvLFouza50b4RmOh0c3SaMnZcxCtzC Q3eE+RAR9BaYsInTnV3d5QGaHqV3NXXKB33Hkal6KwlPCRyQ52zuvRmhxx/d3uGYfoN4 h0ysZ4AL9jdi3LJLLLLvkb2y9/K6V4w4j4QMqGGorDRuaZWXWijoCeBXpRFA18WW2r1y RMfUm3bZ/21euDe9u/s/Iec1EAHPzk772BxPLjBQMv0mUi6CjjQLx0DPfMW3/hCsO9O+ i3/A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=bmOgrMQA; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=L5yjNIUX; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=NbT0p9Vk; 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 586e51a60fabf-465adc63a8esi4321693fac.54.2026.08.26.11.54.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2026 11:54:03 -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=bmOgrMQA; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=L5yjNIUX; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=NbT0p9Vk; 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=JRuqD1U5+LYYhiiAmHyC9rwTezZnKx3wlYNM/0zFqLs=; b=bmOgrMQALV5MZGLQiD4TYtdghO GaEtcjJB+VQicgIZVTAAK39DzgLFIsKsR+rstoa0BGO6N1R8rWL9wyX3oLU0HvHQXxz2KfYzG6bhX QD1MW/MIZV32fsOZFDsMp+au0yRKXj6sxKvexXrxBmtakw0z60rA/Tsy3UIjrInLr1iI=; Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1wzIl6-0006qH-9w; Wed, 26 Aug 2026 18:54:00 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1wzIl3-0006p5-It for openvpn-devel@lists.sourceforge.net; Wed, 26 Aug 2026 18:53:57 +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=i4BY9Jra03+yuQDjXMIFmu/fCxT2uOkp/NKR2jFwrPg=; b=L5yjNIUXVs4dUlrtUFPH1mQbxu cxdfDGl8pB0mYua+61d6AId08knTQJXsqxuJJ8bwOjKtI1EjnyKzsXH/VkJqBggy6dkP9qL11Mbw1 /BNHj4KR9/bFI+hjHCW6KzFhMFLCP5yGAf+Hsz7On6ZgbOHSsxAB5ziLnWyrWuku9AVo=; 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=i4BY9Jra03+yuQDjXMIFmu/fCxT2uOkp/NKR2jFwrPg=; b=NbT0p9Vk4smp+8pC0OHFK+iS/u 2k03Y3DvBTJsNEGyZRgOZs1WluCgvvMto/dp68Th8xpYt13Yo1o+GjVpVeFD6ZPiV1Jwal8xZA3EW 1WNMx8gt3CTkdDP/7IVEy10wZQtbhxT0IYNuz4jybDsd4VN7bPjaKKWz1qxKxfub6qYo=; Received: from [193.149.48.129] (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 1wzIki-0006PP-6m for openvpn-devel@lists.sourceforge.net; Wed, 26 Aug 2026 18:53:37 +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 67QIrTF1018195 for ; Wed, 26 Aug 2026 20:53:29 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 67QIrToP018194 for openvpn-devel@lists.sourceforge.net; Wed, 26 Aug 2026 20:53:29 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 26 Aug 2026 20:53:24 +0200 Message-ID: <20260826185329.18177-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.53.0 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: Arne Schwabe This allows these mocks to be reused by other unit tests that need to include push_util.c/h functions. Change-Id: Ic1ed693f73029f5b5609f717333fdaaabe42acbd Signed-off-by: Arne Schwabe Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn [...] 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: 1wzIki-0006PP-6m Subject: [Openvpn-devel] [PATCH v6] Move mocks from test_push_update_msg into its own compile unit 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: 1874613180726548329 X-GMAIL-MSGID: 1874613180726548329 From: Arne Schwabe This allows these mocks to be reused by other unit tests that need to include push_util.c/h functions. Change-Id: Ic1ed693f73029f5b5609f717333fdaaabe42acbd Signed-off-by: Arne Schwabe Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1853 --- 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/+/1853 This mail reflects revision 6 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c3324d..6eb5954 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -930,6 +930,7 @@ target_sources(test_push_update_msg PRIVATE tests/unit_tests/openvpn/mock_msg.c tests/unit_tests/openvpn/mock_get_random.c + tests/unit_tests/openvpn/mock_push_dependencies.c src/openvpn/options_util.c src/openvpn/otime.c src/openvpn/list.c diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvpn/Makefile.am index 6db611e..5954902 100644 --- a/tests/unit_tests/openvpn/Makefile.am +++ b/tests/unit_tests/openvpn/Makefile.am @@ -400,6 +400,7 @@ push_update_msg_testdriver_SOURCES = test_push_update_msg.c \ mock_msg.c \ mock_get_random.c \ + mock_push_dependencies.c \ $(top_srcdir)/src/openvpn/buffer.c \ $(top_srcdir)/src/openvpn/platform.c \ $(top_srcdir)/src/openvpn/options_util.c \ diff --git a/tests/unit_tests/openvpn/mock_push_dependencies.c b/tests/unit_tests/openvpn/mock_push_dependencies.c new file mode 100644 index 0000000..112bcfd --- /dev/null +++ b/tests/unit_tests/openvpn/mock_push_dependencies.c @@ -0,0 +1,69 @@ +/* + * OpenVPN -- An application to securely tunnel IP networks + * over a single UDP port, with support for SSL/TLS-based + * session authentication and key exchange, + * packet encryption, packet authentication, and + * packet compression. + * + * Copyright (C) 2002-2026 OpenVPN Inc + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +/* Set of mocked function/globals to get unit tests to + * compile that use the push_util.c file */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "error.h" +#include "options.h" + +void +throw_signal_soft(const int signum, const char *signal_text) +{ + msg(M_WARN, "Offending option received from server"); +} + +uint64_t +pull_permission_mask(const struct context *c) +{ + uint64_t flags = OPT_P_UP | OPT_P_ROUTE_EXTRAS | OPT_P_SOCKBUF | OPT_P_SOCKFLAGS + | OPT_P_SETENV | OPT_P_SHAPER | OPT_P_TIMER | OPT_P_COMP | OPT_P_PERSIST + | OPT_P_MESSAGES | OPT_P_EXPLICIT_NOTIFY | OPT_P_ECHO | OPT_P_PULL_MODE + | OPT_P_PEER_ID | OPT_P_NCP | OPT_P_PUSH_MTU | OPT_P_ROUTE | OPT_P_DHCPDNS; + return flags; +} + +void +unlearn_ifconfig(struct multi_context *m, struct multi_instance *mi) +{ +} + +void +unlearn_ifconfig_ipv6(struct multi_context *m, struct multi_instance *mi) +{ +} + +void +update_vhash(struct multi_context *m, struct multi_instance *mi, const char *new_ip, const char *new_ipv6) +{ +} + +bool +options_postprocess_pull(struct options *options, struct env_set *es) +{ + return true; +} diff --git a/tests/unit_tests/openvpn/test_push_update_msg.c b/tests/unit_tests/openvpn/test_push_update_msg.c index 2653749..a93f916 100644 --- a/tests/unit_tests/openvpn/test_push_update_msg.c +++ b/tests/unit_tests/openvpn/test_push_update_msg.c @@ -12,48 +12,6 @@ #include "push_util.c" -/* mocks */ - -void -throw_signal_soft(const int signum, const char *signal_text) -{ - msg(M_WARN, "Offending option received from server"); -} - -uint64_t -pull_permission_mask(const struct context *c) -{ - uint64_t flags = OPT_P_UP | OPT_P_ROUTE_EXTRAS | OPT_P_SOCKBUF | OPT_P_SOCKFLAGS - | OPT_P_SETENV | OPT_P_SHAPER | OPT_P_TIMER | OPT_P_COMP | OPT_P_PERSIST - | OPT_P_MESSAGES | OPT_P_EXPLICIT_NOTIFY | OPT_P_ECHO | OPT_P_PULL_MODE - | OPT_P_PEER_ID | OPT_P_NCP | OPT_P_PUSH_MTU | OPT_P_ROUTE | OPT_P_DHCPDNS; - return flags; -} - -void -unlearn_ifconfig(struct multi_context *m, struct multi_instance *mi) -{ - return; -} - -void -unlearn_ifconfig_ipv6(struct multi_context *m, struct multi_instance *mi) -{ - return; -} - -void -update_vhash(struct multi_context *m, struct multi_instance *mi, const char *new_ip, const char *new_ipv6) -{ - return; -} - -bool -options_postprocess_pull(struct options *options, struct env_set *es) -{ - return true; -} - /* * Counters to track route accumulation across continuation messages. * Used to verify the bug where update_options_found resets per message.