From patchwork Sat Jun 15 13:02:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 756 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id yHimE5h5BV07GQAAIUCqbw for ; Sat, 15 Jun 2019 19:04:56 -0400 Received: from proxy18.mail.iad3b.rsapps.net ([172.31.255.6]) by director8.mail.ord1d.rsapps.net with LMTP id 2MSdEJh5BV2ICAAAfY0hYg ; Sat, 15 Jun 2019 19:04:56 -0400 Received: from smtp11.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy18.mail.iad3b.rsapps.net with LMTP id 2FYDCph5BV1tRgAA3NpJmQ ; Sat, 15 Jun 2019 19:04:56 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp11.gate.iad3b.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: fd488f0c-8fc1-11e9-941a-52540070b5bb-1-1 Received: from [216.105.38.7] ([216.105.38.7:33872] helo=lists.sourceforge.net) by smtp11.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 51/E5-01483-799750D5; Sat, 15 Jun 2019 19:04:55 -0400 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.90_1) (envelope-from ) id 1hcHhi-0003Lz-HO; Sat, 15 Jun 2019 23:03:22 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hcHhh-0003Ls-1f for openvpn-devel@lists.sourceforge.net; Sat, 15 Jun 2019 23:03:21 +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:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Ms3O3JHR6gPMxBmvHpbnDFp9ayFwxvYdm6LNYJhPsbg=; b=VDTWY84Gk7G5dl/pXxm8SlHLqn 3DmKe3ewigkNy42CQTqrRazURE0439YGMG4hrj96v++Pji5Wg6bNN4wIZVheldm77UQvuRrhbs8GN Oepo84Z9hJZS9HOWnCxPVIUWnbQu2BmPwWfNGY9ERAoWRDgAPfA7g+Bwr4ZqC7DGIOP4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=Ms3O3JHR6gPMxBmvHpbnDFp9ayFwxvYdm6LNYJhPsbg=; b=L DupS9Qrzv2fdKkyg0apwx025jno0VOS4yBnQ6jbpFhhw8Q4iyIfZP4Sedq1akQRrvqH2UQ26T3pB7 yYKRnRaZetqTjHQVQNCb8Q5uqy9skwFvZmkLFp5N0mQBD2B0aBZTajXTT0/GzfbyQW8Zb00PY1zNa 7dGRXm6rFsVE29jo=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1hcHha-00Fwq3-89 for openvpn-devel@lists.sourceforge.net; Sat, 15 Jun 2019 23:03:18 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Sun, 16 Jun 2019 01:02:12 +0200 Message-Id: <20190615230213.14888-1-a@unstable.cc> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: makefile.am] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [5.148.176.60 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1hcHha-00Fwq3-89 Subject: [Openvpn-devel] [PATCH 1/2] t_net.sh: make bash dep explicit and run only if SITNL is compiled 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: , Cc: Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Antonio Quartulli The t_net script currently has #!/bin/sh but it implicitly assume to be using bash. This is fine on most distros, but some do not have sh pointing to bash by default, thus breaking the script. Explicitly use bash to avoid failures. On the other hand, run this unit-test only if SITNL was enabled at compile time. This test was designed with SITNL in mind and it is not yet ready for other backends. Running only when SITNL is enabled implies running on Linux only therefore we are guaranteed that bash will always work. While at it, also add a comment as of why the t_client.rc file is sourced. Signed-off-by: Antonio Quartulli Acked-by: Gert Doering --- configure.ac | 3 +++ tests/Makefile.am | 7 ++++--- tests/t_net.sh | 3 ++- tests/unit_tests/openvpn/Makefile.am | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 2d78098e..8c95e310 100644 --- a/configure.ac +++ b/configure.ac @@ -1226,11 +1226,14 @@ else enable_plugin_down_root="no" fi +AM_CONDITIONAL([HAVE_SITNL], [false]) + if test "${enable_iproute2}" = "yes"; then test -z "${IPROUTE}" && AC_MSG_ERROR([ip utility is required but missing]) AC_DEFINE([ENABLE_IPROUTE], [1], [enable iproute2 support]) else if test "${have_sitnl}" = "yes"; then AC_DEFINE([ENABLE_SITNL], [1], [enable sitnl support]) + AM_CONDITIONAL([HAVE_SITNL], [true]) else if test "${WIN32}" != "yes" -a "${have_sitnl}" != "yes"; then test -z "${ROUTE}" && AC_MSG_ERROR([route utility is required but missing]) test -z "${IFCONFIG}" && AC_MSG_ERROR([ifconfig utility is required but missing]) diff --git a/tests/Makefile.am b/tests/Makefile.am index 67acf7e3..801192ed 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,9 +14,10 @@ MAINTAINERCLEANFILES = \ SUBDIRS = unit_tests -test_scripts = t_net.sh -test_scripts += t_client.sh -test_scripts += t_lpback.sh t_cltsrv.sh +test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh +if HAVE_SITNL +test_scripts += t_net.sh +endif TESTS_ENVIRONMENT = top_srcdir="$(top_srcdir)" TESTS = $(test_scripts) diff --git a/tests/t_net.sh b/tests/t_net.sh index 0be5bb42..1940ec92 100755 --- a/tests/t_net.sh +++ b/tests/t_net.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash IFACE="dummy0" UNIT_TEST="./unit_tests/openvpn/networking_testdriver" @@ -74,6 +74,7 @@ run_test() ## execution starts here +# t_client.rc required only for RUN_SUDO definition if [ -r "${top_builddir}"/t_client.rc ]; then . "${top_builddir}"/t_client.rc elif [ -r "${srcdir}"/t_client.rc ]; then diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvpn/Makefile.am index c6da91a8..e61c57c4 100644 --- a/tests/unit_tests/openvpn/Makefile.am +++ b/tests/unit_tests/openvpn/Makefile.am @@ -14,7 +14,7 @@ endif TESTS = $(test_binaries) check_PROGRAMS = $(test_binaries) -if TARGET_LINUX +if HAVE_SITNL check_PROGRAMS += networking_testdriver endif From patchwork Sat Jun 15 13:02:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 755 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.27.255.52]) by backend30.mail.ord1d.rsapps.net with LMTP id iO0/J315BV10eAAAIUCqbw for ; Sat, 15 Jun 2019 19:04:29 -0400 Received: from proxy3.mail.iad3a.rsapps.net ([172.27.255.52]) by director11.mail.ord1d.rsapps.net with LMTP id +OgsJH15BV3HGAAAvGGmqA ; Sat, 15 Jun 2019 19:04:29 -0400 Received: from smtp40.gate.iad3a ([172.27.255.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy3.mail.iad3a.rsapps.net with LMTP id kGiKHX15BV3XVQAAYaqY3Q ; Sat, 15 Jun 2019 19:04:29 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp40.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: ed605b6a-8fc1-11e9-8a2f-5254003a14f9-1-1 Received: from [216.105.38.7] ([216.105.38.7:33832] helo=lists.sourceforge.net) by smtp40.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 4D/D5-10206-D79750D5; Sat, 15 Jun 2019 19:04:29 -0400 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1hcHhg-0003Ez-DG; Sat, 15 Jun 2019 23:03:20 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hcHhf-0003Es-IZ for openvpn-devel@lists.sourceforge.net; Sat, 15 Jun 2019 23:03:19 +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:Cc:To:From:Sender:Reply-To: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=2k2PKSgdNG8vt+J0L+dA1ISSvH7SNKvsirDqd3WshMo=; b=CJwb2uRazz5xMa9Xm0JfIfoL9C vYTnFfZ6f6q4NLjGDKgbOk0dEKyikzpljJTO6/zCLMM00QXuPtbu/r79zoGwRfP4GCd5P3kHSoCGj RDW38SvBAHZh0GPEM3LFlI50hKy7rZS6SR2PTIWRBDzvLVosc+VTR7a9sNHTvXu+6BTE=; 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:Cc:To:From:Sender:Reply-To: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=2k2PKSgdNG8vt+J0L+dA1ISSvH7SNKvsirDqd3WshMo=; b=jeNDZJQcvSleSi6FOeDgWOglaM 6pjAqaTzc7QMkdSv3SQGM02AKncjd7batYqqE2guK42kh6MykpGL5XtBF4go6w4C58AtNAPMOZm7D /wlWiwFodFy/ktscSBacFMFtc13eP65sjyEdv8O6+s9Hw+buRJkwA29YRYM+WpHPqqyo=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1hcHhb-00FXuw-PX for openvpn-devel@lists.sourceforge.net; Sat, 15 Jun 2019 23:03:19 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Sun, 16 Jun 2019 01:02:13 +0200 Message-Id: <20190615230213.14888-2-a@unstable.cc> In-Reply-To: <20190615230213.14888-1-a@unstable.cc> References: <20190615230213.14888-1-a@unstable.cc> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [5.148.176.60 listed in list.dnswl.org] 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: openvpn.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1hcHhb-00FXuw-PX Subject: [Openvpn-devel] [PATCH 2/2] t_net.sh: properly perform sudo check and print test steps 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: , Cc: Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Antonio Quartulli The current script is performing a tes ton the "kill" command, but this is not useful to the t_net.sh script as it never really executes it. Rather test that "sudo " really works. has to be added to the sudoers file if this test has to be performend unattanded. The path is: ./unit_tests/openvpn/networking_testdriver On to pof that, print a simple OK for every test that is succesful. Signed-off-by: Antonio Quartulli Acked-by: Gert Doering --- tests/t_net.sh | 12 +++++------- tests/unit_tests/openvpn/test_networking.c | 6 ++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/t_net.sh b/tests/t_net.sh index 1940ec92..70e8517d 100755 --- a/tests/t_net.sh +++ b/tests/t_net.sh @@ -125,14 +125,12 @@ else echo " must be set correctly in 't_client.rc'. SKIP." >&2 exit 77 else - # We have to use sudo. Make sure that we (hopefully) do not have - # to ask the users password during the test. This is done to - # prevent timing issues, e.g. when the waits for openvpn to start - if $RUN_SUDO $KILL_EXEC -0 $$ + # check that we can run the unit-test binary with sudo + if $RUN_SUDO $UNIT_TEST test then - echo "$0: $RUN_SUDO $KILL_EXEC -0 succeeded, good." + echo "$0: $RUN_SUDO $UNIT_TEST succeeded, good." else - echo "$0: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2 + echo "$0: $RUN_SUDO $UNIT_TEST failed, cannot go on. SKIP." >&2 exit 77 fi fi @@ -172,7 +170,7 @@ for i in $(seq 0 $MAX_TEST); do exit 1 fi done - + echo "Test $i: OK" done # remove interface for good diff --git a/tests/unit_tests/openvpn/test_networking.c b/tests/unit_tests/openvpn/test_networking.c index 66035011..6c50da92 100644 --- a/tests/unit_tests/openvpn/test_networking.c +++ b/tests/unit_tests/openvpn/test_networking.c @@ -185,6 +185,12 @@ main(int argc, char *argv[]) return -1; } + /* the t_net script can use this command to perform a dry-run test */ + if (strcmp(argv[1], "test") == 0) + { + return 0; + } + if (argc > 3) { iface = argv[2];