From patchwork Mon Jan 22 12:45:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "plaisthos (Code Review)" X-Patchwork-Id: 3585 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7301:2802:b0:101:b91e:57cc with SMTP id hj2csp2549505dyb; Mon, 22 Jan 2024 04:46:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEgkcA1kzQTh3Umh7L4aA4q7r10+DYgfabU1Xp77pHW1cgvJDq6BmN6bO+IiceHaLBtqksU X-Received: by 2002:a17:90a:f196:b0:290:3e14:5670 with SMTP id bv22-20020a17090af19600b002903e145670mr5307865pjb.3.1705927568362; Mon, 22 Jan 2024 04:46:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705927568; cv=none; d=google.com; s=arc-20160816; b=Tn9A9cRaHhw4ciCf8qI1y58m/lDOkX7QBKShLrQa75pgqiCGUaP/TXZcbfRMB2fPBh BeiJQ/FzcFtW6T5exTKrm94lovQ2YbeENr9/OPMBQiEc63q+mbZBL4bVTbZ2heuABBgU nwykDYmLKXC6sV2R3RyVMpYtCsUSFQQM33YZieJvYGVslOpdJz7Z7v51Sw8RwbjP/ql7 XHTJyRX27pul6uq+YQbcy6ARdmmzb/26gCuBVoDBXnSmuD0dcwhSTaWXBpLHSOUr4rng KcIe3NXfzalQANoAMBlz4n7NxK/gqXL6cv41hEmsIDU+oIJ3al2HMEiKjs8/EEFvBzZQ /TQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :mime-version:message-id:references:auto-submitted:to:date:from :dkim-signature:dkim-signature:dkim-signature; bh=xETmtTK6PBmXgy1U7fP/cNixqFhl75D7tve7QpOf8fg=; fh=lm0MLPW7DntlrDqRECIiC9JlE1uPxhepE0URYHIf+eE=; b=QPbH3UJ4k0Rb4T62+OO9uj3xKVrbJOWiMR+9sq0RWXsVEr1/ZvPcCFoJrMtjrw60y3 lt8oLeixIt391mHom5DLPcx8zCU/YBBjeLlGrT9o5s8E5whg0Dgqr0CYNgpR74wIhqTJ 3xn0Ej4S12/MwsICnX4/xw+VaouyVGv5OzKRs1aazyfCyYj+3bcSpYWjhAJw2bNZPiSY iRegnO+SOmxZ7Pcab/A7WSVj1uex7LYQQVVqI9jLvaheQcaa3B1XFGBNWEYRtwagMIN8 rIeIOpGFEhd8l8P+q0aDVDWqJetoqx2EM71mPHxwgeqWWgTYAvjImxbcK4jgomAHfiDY gEzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=i2oZ9Pu4; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=IXrPOJuG; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b="gjh41k/T"; 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=openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id w23-20020a17090a8a1700b002905eeccaf4si4860037pjn.187.2024.01.22.04.46.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2024 04:46:08 -0800 (PST) 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=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=i2oZ9Pu4; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=IXrPOJuG; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b="gjh41k/T"; 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=openvpn.net Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rRtgL-0001qM-A6; Mon, 22 Jan 2024 12:45:41 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rRtgF-0001qE-Eq for openvpn-devel@lists.sourceforge.net; Mon, 22 Jan 2024 12:45:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:To:Date: From:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=WqGdDPg2q5g6L1Z1bCeszYd/29hlEIqPDva+HKmQIio=; b=i2oZ9Pu44yYAiYPW+sBpf3jg2m rHebAzYPG+4h6zLJA6JDiehrcfUJNpR1FC7bfyg7GnEJvjsdHBJI1b6rN3rxF9Nt1xWqEXqPvX8kn cWcmVuqV7HIJy0KhPc7dWEGQm9dYyd+M4v9Xr/mciGGIOZXK9lWJTQEB9CPVp9ZMjxWo=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:To:Date:From:Sender:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=WqGdDPg2q5g6L1Z1bCeszYd/29hlEIqPDva+HKmQIio=; b=I XrPOJuG4gJcucIScevWFArmLuXXIpIUbNKUfkwspMuUKixWCTNM+OmMYEcvCRxpuax7BP+1P1BkEf 4Igg0CHONCJFaCEFUGXB2ZKV1CYRlfYzJRPq1Mr7c4HZByJ+T6gpk8+dNUlRfti/PwGVP5cq65kOA Y4lCt+FQC3TMC9nE=; Received: from mail-wm1-f49.google.com ([209.85.128.49]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1rRtg9-0001Ir-LS for openvpn-devel@lists.sourceforge.net; Mon, 22 Jan 2024 12:45:32 +0000 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-40eacb6067dso11776725e9.1 for ; Mon, 22 Jan 2024 04:45:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1705927515; x=1706532315; darn=lists.sourceforge.net; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from:from:to:cc :subject:date:message-id:reply-to; bh=WqGdDPg2q5g6L1Z1bCeszYd/29hlEIqPDva+HKmQIio=; b=gjh41k/TB/xp/yHTMBibD6ZaJTJKFRtwkZacCfq5SRbEinQWHEsjVMOqVedzm79Btt yesnZ6LirCjslviN1kgDsEnb0sPS/9zEOBq/B7ELLn5SiTVKyfGF1rjjiYNmfdGDzsfk e5je+6+NKZrlT7toHdT3MilZWVmFyure6OdRULkis3ckFUGBDaBI4z/WhurPdcT2PbGb MHqvSd7ZZt8n6081uR2TgQBBrbk2ADF0+HbbzR5FBIZ+m7TErmsbxdX6FhI/vqjcud4i VjhLfJypdla2iMgeM14oupTEcCgcslqo8a0zM3BmK03HhotduoqiZ4/dNp3b4xr1/dIM iCEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705927515; x=1706532315; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WqGdDPg2q5g6L1Z1bCeszYd/29hlEIqPDva+HKmQIio=; b=PBEvh2nDdhYPkV9MS4MY/sVOOtVJa3vFkJ8wiYZkOD551OPtxwPiY+iYZ5vCmbIeck ep4noJn+VImUaqxkwqPpUi1oHu9j4O5pXzHxw4JtBKkKOFbUXSBuAomAHLnK+hlIaOMa hGYHcFAtdtHYP5afJNJeZsslAYffLApD2WiqFkvFrdbUqKhWnXZSSB9s2hFQ4LRNbFU9 7X+zN5KQD48QCMYRegzdrFwRokCQXteZSdTQ4Vb4Jydil9YQwwWsMA+cEapi3silI8Do SH9ooKK7ACaWXwrVaiNss4ADanTUV8DuLDHpYaYJBCaet8dccmY/HdRB5VlRvTQYo5Oj zgvw== X-Gm-Message-State: AOJu0YyizzQ6eY0tGx9KUv6eBkFgNXhmoGY9kX3Q80HFpJ/Gc4hFnRv/ pbHmdoKdZ0bgelhaVXDSNd5YhhgL9HfIao4hzjlrM3mdlOPa9XPHt8qSoYZpSW1vnOZT3m/sp0Y e X-Received: by 2002:a05:600c:2055:b0:40e:5137:95f0 with SMTP id p21-20020a05600c205500b0040e513795f0mr1263379wmg.132.1705927515180; Mon, 22 Jan 2024 04:45:15 -0800 (PST) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id 7-20020a05600c248700b0040e526bd5fdsm3376478wms.1.2024.01.22.04.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 04:45:14 -0800 (PST) From: "plaisthos (Code Review)" X-Google-Original-From: "plaisthos (Code Review)" X-Gerrit-PatchSet: 1 Date: Mon, 22 Jan 2024 12:45:14 +0000 To: flichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: I5c06dc13e9d8ab73997f79b13c30ee8949e5e993 X-Gerrit-Change-Number: 504 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 3ccfa5260413d37f9852e9fa37d0a15071fb7cb3 References: Message-ID: <655fdf55f86eecce95679ac7f4f6c646b1327076-HTML@gerrit.openvpn.net> MIME-Version: 1.0 User-Agent: Gerrit/3.8.2 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", 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: Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.49 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.49 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Headers-End: 1rRtg9-0001Ir-LS Subject: [Openvpn-devel] [M] Change in openvpn[master]: Ensure that all unit tests use unbuffered stdout and stderr 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: , Reply-To: arne-openvpn@rfc2549.org, openvpn-devel@lists.sourceforge.net, frank@lichtenheld.com Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1788794705651736706?= X-GMAIL-MSGID: =?utf-8?q?1788794705651736706?= X-getmail-filter-classifier: gerrit message type newchange Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/504?usp=email to review the following change. Change subject: Ensure that all unit tests use unbuffered stdout and stderr ...................................................................... Ensure that all unit tests use unbuffered stdout and stderr stderr is normally always unbuffered but stdout can be buffered. Especially, when stdout is redirected it will become buffered while it is normally unbuffered when connected to a terminal. This mean that if the unit exits prematurely, the output in the buffered output will be lost. As the unit test x_msg mock implementation prints even fatal on stdout we ensure with this setup method that stdout is also unbuffered. Change-Id: I5c06dc13e9d8ab73997f79b13c30ee8949e5e993 --- M tests/unit_tests/openvpn/test_argv.c M tests/unit_tests/openvpn/test_auth_token.c M tests/unit_tests/openvpn/test_buffer.c A tests/unit_tests/openvpn/test_common.h M tests/unit_tests/openvpn/test_crypto.c M tests/unit_tests/openvpn/test_cryptoapi.c M tests/unit_tests/openvpn/test_misc.c M tests/unit_tests/openvpn/test_ncp.c M tests/unit_tests/openvpn/test_networking.c M tests/unit_tests/openvpn/test_packet_id.c M tests/unit_tests/openvpn/test_pkcs11.c M tests/unit_tests/openvpn/test_pkt.c M tests/unit_tests/openvpn/test_provider.c M tests/unit_tests/openvpn/test_ssl.c M tests/unit_tests/openvpn/test_tls_crypt.c 15 files changed, 70 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/04/504/1 diff --git a/tests/unit_tests/openvpn/test_argv.c b/tests/unit_tests/openvpn/test_argv.c index 1b18ac0..33b3dec 100644 --- a/tests/unit_tests/openvpn/test_argv.c +++ b/tests/unit_tests/openvpn/test_argv.c @@ -12,6 +12,7 @@ #include "argv.h" #include "buffer.h" +#include "test_common.h" /* Defines for use in the tests and the mock parse_line() */ #define PATH1 "/s p a c e" @@ -252,6 +253,7 @@ int main(void) { + openvpn_unit_test_setup(); const struct CMUnitTest tests[] = { cmocka_unit_test(argv_printf__multiple_spaces_in_format__parsed_as_one), cmocka_unit_test(argv_printf_cat__multiple_spaces_in_format__parsed_as_one), diff --git a/tests/unit_tests/openvpn/test_auth_token.c b/tests/unit_tests/openvpn/test_auth_token.c index a027330..3a3cb69 100644 --- a/tests/unit_tests/openvpn/test_auth_token.c +++ b/tests/unit_tests/openvpn/test_auth_token.c @@ -35,6 +35,7 @@ #include #include "auth_token.c" +#include "test_common.h" struct test_context { struct tls_multi multi; @@ -407,6 +408,7 @@ int main(void) { + openvpn_unit_test_setup(); const struct CMUnitTest tests[] = { cmocka_unit_test_setup_teardown(auth_token_basic_test, setup, teardown), cmocka_unit_test_setup_teardown(auth_token_fail_invalid_key, setup, teardown), diff --git a/tests/unit_tests/openvpn/test_buffer.c b/tests/unit_tests/openvpn/test_buffer.c index ee84c1f..52ffb54 100644 --- a/tests/unit_tests/openvpn/test_buffer.c +++ b/tests/unit_tests/openvpn/test_buffer.c @@ -32,6 +32,7 @@ #include "buffer.h" #include "buffer.c" +#include "test_common.h" static void test_buffer_strprefix(void **state) @@ -356,6 +357,7 @@ int main(void) { + openvpn_unit_test_setup(); const struct CMUnitTest tests[] = { cmocka_unit_test(test_buffer_strprefix), cmocka_unit_test(test_buffer_printf_catrunc), diff --git a/tests/unit_tests/openvpn/test_common.h b/tests/unit_tests/openvpn/test_common.h new file mode 100644 index 0000000..e1bdf37 --- /dev/null +++ b/tests/unit_tests/openvpn/test_common.h @@ -0,0 +1,39 @@ +/* + * 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) 2016-2021 Fox Crypto B.V. + * + * 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include + +/** + * Sets up the environment for unit tests like making both stderr and stdout + * non-buffered to avoid messages getting lost if the program exits early. + * + * This has a openvpn prefix to avoid confusion with cmocka's unit_test_setup_* + * methods + */ +void +openvpn_unit_test_setup() +{ + assert_int_equal(setvbuf(stdout, NULL, _IONBF, BUFSIZ), 0); + assert_int_equal(setvbuf(stderr, NULL, _IONBF, BUFSIZ), 0); +} diff --git a/tests/unit_tests/openvpn/test_crypto.c b/tests/unit_tests/openvpn/test_crypto.c index 08c9c44..01c16c9 100644 --- a/tests/unit_tests/openvpn/test_crypto.c +++ b/tests/unit_tests/openvpn/test_crypto.c @@ -39,6 +39,7 @@ #include "ssl_backend.h" #include "mss.h" +#include "test_common.h" static const char testtext[] = "Dummy text to test PEM encoding"; @@ -445,6 +446,7 @@ int main(void) { + openvpn_unit_test_setup(); const struct CMUnitTest tests[] = { cmocka_unit_test(crypto_pem_encode_decode_loopback), cmocka_unit_test(crypto_translate_cipher_names), diff --git a/tests/unit_tests/openvpn/test_cryptoapi.c b/tests/unit_tests/openvpn/test_cryptoapi.c index d90bfc3..bfe1e11 100644 --- a/tests/unit_tests/openvpn/test_cryptoapi.c +++ b/tests/unit_tests/openvpn/test_cryptoapi.c @@ -31,6 +31,7 @@ #include "integer.h" #include "xkey_common.h" #include "cert_data.h" +#include "test_common.h" #if defined(HAVE_XKEY_PROVIDER) && defined (ENABLE_CRYPTOAPI) #include @@ -486,6 +487,7 @@ int main(void) { + openvpn_unit_test_setup(); const struct CMUnitTest tests[] = { cmocka_unit_test(test_parse_hexstring), cmocka_unit_test(import_certs), diff --git a/tests/unit_tests/openvpn/test_misc.c b/tests/unit_tests/openvpn/test_misc.c index 43ae96b..193f131 100644 --- a/tests/unit_tests/openvpn/test_misc.c +++ b/tests/unit_tests/openvpn/test_misc.c @@ -36,6 +36,7 @@ #include "ssl_util.h" #include "options_util.h" +#include "test_common.h" static void test_compat_lzo_string(void **state) @@ -117,5 +118,6 @@ int main(void) { + openvpn_unit_test_setup(); return cmocka_run_group_tests(misc_tests, NULL, NULL); } diff --git a/tests/unit_tests/openvpn/test_ncp.c b/tests/unit_tests/openvpn/test_ncp.c index 72a1c3b..ecf1e39 100644 --- a/tests/unit_tests/openvpn/test_ncp.c +++ b/tests/unit_tests/openvpn/test_ncp.c @@ -35,6 +35,7 @@ #include #include "ssl_ncp.c" +#include "test_common.h" /* Defines for use in the tests and the mock parse_line() */ @@ -272,6 +273,7 @@ int main(void) { + openvpn_unit_test_setup(); #if defined(ENABLE_CRYPTO_OPENSSL) OpenSSL_add_all_algorithms(); #endif diff --git a/tests/unit_tests/openvpn/test_networking.c b/tests/unit_tests/openvpn/test_networking.c index 0434707..0199812 100644 --- a/tests/unit_tests/openvpn/test_networking.c +++ b/tests/unit_tests/openvpn/test_networking.c @@ -1,6 +1,7 @@ #include "config.h" #include "syshead.h" #include "networking.h" +#include "test_common.h" #include @@ -223,6 +224,7 @@ int main(int argc, char *argv[]) { + openvpn_unit_test_setup(); int test; if (argc < 2) diff --git a/tests/unit_tests/openvpn/test_packet_id.c b/tests/unit_tests/openvpn/test_packet_id.c index 2a2a973..ff3f788 100644 --- a/tests/unit_tests/openvpn/test_packet_id.c +++ b/tests/unit_tests/openvpn/test_packet_id.c @@ -35,6 +35,7 @@ #include "packet_id.h" #include "reliable.h" +#include "test_common.h" struct test_packet_id_write_data { struct { @@ -273,6 +274,7 @@ int main(void) { + openvpn_unit_test_setup(); const struct CMUnitTest tests[] = { cmocka_unit_test_setup_teardown(test_packet_id_write_short, test_packet_id_write_setup, diff --git a/tests/unit_tests/openvpn/test_pkcs11.c b/tests/unit_tests/openvpn/test_pkcs11.c index b6c130e..81cdf88 100644 --- a/tests/unit_tests/openvpn/test_pkcs11.c +++ b/tests/unit_tests/openvpn/test_pkcs11.c @@ -37,11 +37,13 @@ #include #include +#include "test_common.h" #define token_name "Test Token" #define PIN "12345" #define HASHSIZE 20 + struct management *management; /* global */ /* replacement for crypto_print_openssl_errors() */ @@ -459,6 +461,7 @@ int main(void) { + openvpn_unit_test_setup(); const struct CMUnitTest tests[] = { cmocka_unit_test_setup_teardown(test_pkcs11_ids, setup_pkcs11, teardown_pkcs11), diff --git a/tests/unit_tests/openvpn/test_pkt.c b/tests/unit_tests/openvpn/test_pkt.c index 7f05184..1084d66 100644 --- a/tests/unit_tests/openvpn/test_pkt.c +++ b/tests/unit_tests/openvpn/test_pkt.c @@ -33,6 +33,7 @@ #include #include #include +#include "test_common.h" #include "crypto.h" #include "options.h" @@ -628,6 +629,7 @@ int main(void) { + openvpn_unit_test_setup(); const struct CMUnitTest tests[] = { cmocka_unit_test(test_tls_decrypt_lite_none), cmocka_unit_test(test_tls_decrypt_lite_auth), diff --git a/tests/unit_tests/openvpn/test_provider.c b/tests/unit_tests/openvpn/test_provider.c index 335fca2..94deab6 100644 --- a/tests/unit_tests/openvpn/test_provider.c +++ b/tests/unit_tests/openvpn/test_provider.c @@ -40,6 +40,8 @@ #include #include +#include "test_common.h" + struct management *management; /* global */ static int mgmt_callback_called; @@ -119,6 +121,7 @@ static void init_test() { + openvpn_unit_test_setup(); prov[0] = OSSL_PROVIDER_load(NULL, "default"); OSSL_PROVIDER_add_builtin(NULL, prov_name, xkey_provider_init); prov[1] = OSSL_PROVIDER_load(NULL, prov_name); diff --git a/tests/unit_tests/openvpn/test_ssl.c b/tests/unit_tests/openvpn/test_ssl.c index d0c3df7..18b9ec8 100644 --- a/tests/unit_tests/openvpn/test_ssl.c +++ b/tests/unit_tests/openvpn/test_ssl.c @@ -43,6 +43,7 @@ #include "mss.h" #include "ssl_verify_backend.h" #include "win32.h" +#include "test_common.h" /* Mock function to be allowed to include win32.c which is required for * getting the temp directory */ @@ -122,6 +123,8 @@ int main(void) { + openvpn_unit_test_setup(); + const struct CMUnitTest tests[] = { cmocka_unit_test(crypto_pem_encode_certificate) }; diff --git a/tests/unit_tests/openvpn/test_tls_crypt.c b/tests/unit_tests/openvpn/test_tls_crypt.c index 465543a..a01fbe5 100644 --- a/tests/unit_tests/openvpn/test_tls_crypt.c +++ b/tests/unit_tests/openvpn/test_tls_crypt.c @@ -34,6 +34,7 @@ #include #include +#include "test_common.h" #include "tls_crypt.c" /* Define this function here as dummy since including the ssl_*.c files @@ -673,6 +674,7 @@ int main(void) { + openvpn_unit_test_setup(); const struct CMUnitTest tests[] = { cmocka_unit_test_setup_teardown(tls_crypt_loopback, test_tls_crypt_setup,