From patchwork Sun Jun 23 08:32:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 763 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id eL9yNwDGD121ZwAAIUCqbw for ; Sun, 23 Jun 2019 14:33:36 -0400 Received: from proxy20.mail.iad3b.rsapps.net ([172.31.255.6]) by director9.mail.ord1d.rsapps.net with LMTP id 0JiPNADGD12CNgAAalYnBA ; Sun, 23 Jun 2019 14:33:36 -0400 Received: from smtp37.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy20.mail.iad3b.rsapps.net with LMTP id uAioLQDGD12PBAAAcDxLoQ ; Sun, 23 Jun 2019 14:33:36 -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: smtp37.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=greenie.muc.de X-Suspicious-Flag: YES X-Classification-ID: 694d9dc2-95e5-11e9-abe0-5254002ca64a-1-1 Received: from [216.105.38.7] ([216.105.38.7:37118] helo=lists.sourceforge.net) by smtp37.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 06/53-21464-006CF0D5; Sun, 23 Jun 2019 14:33:36 -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 1hf7Hp-0006fP-65; Sun, 23 Jun 2019 18:32:21 +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 1hf7Ho-0006fE-65 for openvpn-devel@lists.sourceforge.net; Sun, 23 Jun 2019 18:32:20 +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=daG9AGGZqfQXIkD/+GCfx1+7+xfsfdJQ619IGTtqAiY=; b=gpKkBIPHwIzHQUGq2aiLJrBLMt oSFyxJCJqfgzI6fe3kzSvelGM/os0ND449TUSMEPFE2ASYOICoypSlTQdCG0kYGiFJf4LR6Q3Dm4K QEC1vjFr0bhhPyNV/GR0Z9z4n6r9D8dpjdDb4iB27obqrwtPC/5G9hLA+8rmulBuzrQg=; 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=daG9AGGZqfQXIkD/+GCfx1+7+xfsfdJQ619IGTtqAiY=; b=QCxqp+xw4JhsSTIXpMWgyAJol9 MsmOmPpIebWqEv5jy+9enaDBo0TpX6E9QZvY17EbwTCOfgE+DmqLVFauf/wUTspVpR+5jjg+Lixgr mewHLYh+nJLe91UJ0tech+HF7NAnYPlzD3NHtX4nu25iILTwRIt1RQUC5T1GEft8UcMg=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1hf7Hm-00AlQ4-UD for openvpn-devel@lists.sourceforge.net; Sun, 23 Jun 2019 18:32:23 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.14.9/8.14.9) with ESMTP id x5NIWBlh006050 for ; Sun, 23 Jun 2019 20:32:11 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.14.9/8.14.9/Submit) id x5NIWBg3006049 for openvpn-devel@lists.sourceforge.net; Sun, 23 Jun 2019 20:32:11 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Sun, 23 Jun 2019 20:32:10 +0200 Message-Id: <20190623183210.6005-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190623180157.29390-1-gert@greenie.muc.de> References: <20190623180157.29390-1-gert@greenie.muc.de> 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: muc.de] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1hf7Hm-00AlQ4-UD Subject: [Openvpn-devel] [PATCH v3] Remove cmocka submodule, rely on system-wide installation instead. 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 We used to ship git submodule instructions to build a local copy of cmocka in vendor/cmocka/ and use that (if cmake is installed) to build unit tests. With the network test driver this turns out to be a LD_LIBRARY_PATH vs. SUDO complication which is really outweighing the benefit of a local build today - so, use the system-wide installation if available (querying pgk-config). Do not build unit-tests otherwise. v2: (inspired by patch from David Sommerseth) introduce "configure --disable-unit-test" switch simplify configure.ac logic use CMOCKA_LIBS and CMOCKA_INCLUDE (set by PKG_CHECK) v3: repair conflict with commit 7473f326366fbceb CMOCKA_INCLUDE is not correct, must be CMOCKA_CFLAGS (see config.status) Signed-off-by: Gert Doering Acked-By: David Sommerseth --- .gitmodules | 4 ---- INSTALL | 14 +++++++++++++ Makefile.am | 2 +- configure.ac | 40 +++++++++++++++++------------------- tests/unit_tests/Makefile.am | 2 +- vendor/Makefile.am | 22 -------------------- vendor/README.md | 8 -------- vendor/cmocka | 1 - 8 files changed, 35 insertions(+), 58 deletions(-) delete mode 100644 .gitmodules delete mode 100644 vendor/Makefile.am delete mode 100644 vendor/README.md delete mode 160000 vendor/cmocka diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c1ff36e1..00000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "vendor/cmocka"] - path = vendor/cmocka - url = https://git.cryptomilk.org/projects/cmocka.git - branch = master diff --git a/INSTALL b/INSTALL index 0ba3bba6..50123e05 100644 --- a/INSTALL +++ b/INSTALL @@ -156,6 +156,20 @@ Test SSL/TLS negotiations (runs for 2 minutes): For more thorough client-server tests you can configure your own, private test environment. See tests/t_client.rc-sample for details. +To do the C unit tests, you need to have the "cmocka" test framework +installed on your system. More recent distributions already ship this +as part of their packages/ports. If your system does not have it, +you can install cmocka with these commands: + + $ git clone https://git.cryptomilk.org/projects/cmocka.git + $ cd cmocka + $ mkdir build + $ cd build + $ cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Debug .. + $ make + $ sudo make install + + ************************************************************************* OPTIONS for ./configure: diff --git a/Makefile.am b/Makefile.am index a4dbb34b..439120e4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,7 +53,7 @@ BUILT_SOURCES = \ config-version.h endif -SUBDIRS = build distro include src sample doc vendor tests +SUBDIRS = build distro include src sample doc tests dist_doc_DATA = \ README \ diff --git a/configure.ac b/configure.ac index 5745a129..2cc396e5 100644 --- a/configure.ac +++ b/configure.ac @@ -1361,33 +1361,32 @@ AC_SUBST([sampledir]) AC_SUBST([systemdunitdir]) AC_SUBST([tmpfilesdir]) +AC_ARG_ENABLE( + [unit-tests], + [AS_HELP_STRING([--disable-unit-tests], + [Disables building and running the unit tests suite])], + [], + [enable_unit_tests="yes"] +) + +# Check if cmocka is available - needed for unit testing +PKG_CHECK_MODULES( + [CMOCKA], [cmocka], + [have_cmocka="yes"], + [AC_MSG_WARN([cmocka.pc not found on the system. Unit tests disabled])] +) +AM_CONDITIONAL([ENABLE_UNITTESTS], [test "${enable_unit_tests}" = "yes" -a "${have_cmocka}" = "yes" ]) +AC_SUBST([ENABLE_UNITTESTS]) + TEST_LDFLAGS="${OPTIONAL_CRYPTO_LIBS} ${OPTIONAL_PKCS11_HELPER_LIBS}" -TEST_LDFLAGS="${TEST_LDFLAGS} ${OPTIONAL_LZO_LIBS}" -TEST_LDFLAGS="${TEST_LDFLAGS} -lcmocka -L\$(top_builddir)/vendor/dist/lib" -TEST_LDFLAGS="${TEST_LDFLAGS} -Wl,-rpath,\$(top_builddir)/vendor/dist/lib" +TEST_LDFLAGS="${TEST_LDFLAGS} ${OPTIONAL_LZO_LIBS} ${CMOCKA_LIBS}" TEST_CFLAGS="${OPTIONAL_CRYPTO_CFLAGS} ${OPTIONAL_PKCS11_HELPER_CFLAGS}" TEST_CFLAGS="${TEST_CFLAGS} ${OPTIONAL_LZO_CFLAGS}" -TEST_CFLAGS="${TEST_CFLAGS} -I\$(top_srcdir)/include -I\$(top_builddir)/vendor/dist/include" +TEST_CFLAGS="${TEST_CFLAGS} -I\$(top_srcdir)/include ${CMOCKA_CFLAGS}" AC_SUBST([TEST_LDFLAGS]) AC_SUBST([TEST_CFLAGS]) -# Check if cmake is available and cmocka git submodule is initialized, -# needed for unit testing -AC_CHECK_PROGS([CMAKE], [cmake]) -if test -n "${CMAKE}"; then - if test -f "${srcdir}/vendor/cmocka/CMakeLists.txt"; then - AM_CONDITIONAL([CMOCKA_INITIALIZED], [true]) - else - AM_CONDITIONAL([CMOCKA_INITIALIZED], [false]) - AC_MSG_RESULT([!! WARNING !! The cmoka git submodule has not been initialized or updated. Unit testing cannot be performed.]) - fi -else - AC_MSG_RESULT([!! WARNING !! CMake is NOT available. Unit testing cannot be performed.]) - AM_CONDITIONAL([CMOCKA_INITIALIZED], [false]) -fi - - AC_CONFIG_FILES([ version.sh Makefile @@ -1415,7 +1414,6 @@ AC_CONFIG_FILES([ tests/unit_tests/openvpn/Makefile tests/unit_tests/plugins/Makefile tests/unit_tests/plugins/auth-pam/Makefile - vendor/Makefile sample/Makefile ]) AC_CONFIG_FILES([tests/t_client.sh], [chmod +x tests/t_client.sh]) diff --git a/tests/unit_tests/Makefile.am b/tests/unit_tests/Makefile.am index 31d37b89..33fefaac 100644 --- a/tests/unit_tests/Makefile.am +++ b/tests/unit_tests/Makefile.am @@ -1,5 +1,5 @@ AUTOMAKE_OPTIONS = foreign -if CMOCKA_INITIALIZED +if ENABLE_UNITTESTS SUBDIRS = example_test openvpn plugins endif diff --git a/vendor/Makefile.am b/vendor/Makefile.am deleted file mode 100644 index 46072c3c..00000000 --- a/vendor/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -cmockasrc = $(srcdir)/cmocka -# Not just '$(builddir)/cmocka', because cmocka requires an out-of-source build -cmockabuild = $(builddir)/cmocka_build -cmockadist = $(builddir)/dist - -MAINTAINERCLEANFILES = \ - $(srcdir)/Makefile.in \ - "$(cmockabuild)" \ - "$(cmockadist)" - -libcmocka: -if CMOCKA_INITIALIZED - mkdir -p $(cmockabuild) $(cmockadist) - ## Compensate for the cd in the paths - (cd $(cmockabuild) && cmake -DCMAKE_INSTALL_PREFIX=../$(cmockadist) ../$(cmockasrc) && make && make install) -endif - -check: libcmocka - -clean: - rm -rf $(cmockabuild) - rm -rf $(cmockainstall) diff --git a/vendor/README.md b/vendor/README.md deleted file mode 100644 index cede99b6..00000000 --- a/vendor/README.md +++ /dev/null @@ -1,8 +0,0 @@ -Vendor -======== - -Vendor source libraries are included in this directory. Libraries are included -when there is no good way to ensure that the package is available on all -systems. - -`Makefile.am` compiles these libraries and installs them into ./dist. diff --git a/vendor/cmocka b/vendor/cmocka deleted file mode 160000 index b2732b52..00000000 --- a/vendor/cmocka +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b2732b52202ae48f866a024c633466efdbb8e85a