diff options
-rw-r--r-- | .gitmodules | 4 | ||||
-rw-r--r-- | INSTALL | 14 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 40 | ||||
-rw-r--r-- | tests/unit_tests/Makefile.am | 2 | ||||
-rw-r--r-- | vendor/Makefile.am | 22 | ||||
-rw-r--r-- | vendor/README.md | 8 | ||||
m--------- | vendor/cmocka | 0 |
8 files changed, 35 insertions, 57 deletions
diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c1ff36e..0000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "vendor/cmocka"] - path = vendor/cmocka - url = https://git.cryptomilk.org/projects/cmocka.git - branch = master @@ -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 a4dbb34..439120e 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 5745a12..2cc396e 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 31d37b8..33fefaa 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 46072c3..0000000 --- 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 cede99b..0000000 --- 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 -Subproject b2732b52202ae48f866a024c633466efdbb8e85 |