Skip to content

Commit

Permalink
Remove cmocka submodule, rely on system-wide installation instead.
Browse files Browse the repository at this point in the history
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 7473f32
  CMOCKA_INCLUDE is not correct, must be CMOCKA_CFLAGS (see config.status)

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20190623183210.6005-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18570.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
  • Loading branch information
cron2 committed Jun 24, 2019
1 parent b3cfc43 commit 222e691
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 58 deletions.
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

14 changes: 14 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
40 changes: 19 additions & 21 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AUTOMAKE_OPTIONS = foreign

if CMOCKA_INITIALIZED
if ENABLE_UNITTESTS
SUBDIRS = example_test openvpn plugins
endif
22 changes: 0 additions & 22 deletions vendor/Makefile.am

This file was deleted.

8 changes: 0 additions & 8 deletions vendor/README.md

This file was deleted.

1 change: 0 additions & 1 deletion vendor/cmocka
Submodule cmocka deleted from b2732b

0 comments on commit 222e691

Please sign in to comment.