]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Only build and run cmocka unit tests if its submodule is initialized
authorDavid Sommerseth <dazo@privateinternetaccess.com>
Tue, 31 May 2016 10:28:46 +0000 (12:28 +0200)
committerDavid Sommerseth <dazo@privateinternetaccess.com>
Tue, 31 May 2016 14:40:29 +0000 (16:40 +0200)
Commit 40cb4cfc5d01110 added infrastructure to write unit tests using
cmocka.  This was implemented using a git submodule to fetch an
up-to-date cmocka test framework.

The issue which appeared was that 'make check' stopped working if
the cmocka submodule was not initialized and updated.  As we do not
want this to be a hard depenency, this patch makes running these
unit tests conditional.  If cmocka has not been initialized, skip
them or if it has been initialized all unit tests will be run.

 [v2 - Also check if cmake is available, as cmocka depends on that
       to be built ]

Signed-off-by: David Sommerseth <dazo@privateinternetaccess.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1464703645-26640-1-git-send-email-openvpn@sf.lists.topphemmelig.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11758

configure.ac
tests/unit_tests/Makefile.am
vendor/Makefile.am

index 5e69f91c91e6f4f690a61c841927d10223f2d330..d73302345e2893ac8c87976da92320153238de9b 100644 (file)
@@ -1211,6 +1211,22 @@ TEST_CFLAGS="-I\$(top_srcdir)/include -I\$(abs_top_builddir)/vendor/dist/include
 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 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
index e076db82c767fe417da6be2e3429d9f5ec846dfc..8868c1cb4f670d82f39a16f0ea2772b612993913 100644 (file)
@@ -1,3 +1,5 @@
 AUTOMAKE_OPTIONS = foreign
 
+if CMOCKA_INITIALIZED
 SUBDIRS = example_test plugins
+endif
index f68240e9062670e63255eaac5c460382226fb89a..84656a11511f8f4a9795bfbdde4e08d762c0d9d2 100644 (file)
@@ -15,7 +15,9 @@ distdir:
 
 libcmocka: distdir
        mkdir -p $(cmockabuild)
+if CMOCKA_INITIALIZED
        (cd $(cmockabuild) && cmake -DCMAKE_INSTALL_PREFIX=$(cmockainstall) $(cmockasrc) && make && make install)
+endif
 
 check: libcmocka