From 0db097ba8b605ea7a6e0364ad786da6528868179 Mon Sep 17 00:00:00 2001 From: Sarah Day Date: Mon, 25 Jul 2016 13:20:08 -0400 Subject: [PATCH] Add cmocka support --- .travis.yml | 9 +++++++++ src/Makefile.in | 3 +++ src/config/post.in | 7 +++++++ src/config/pre.in | 1 + src/configure.in | 17 +++++++++++++++++ 5 files changed, 37 insertions(+) diff --git a/.travis.yml b/.travis.yml index a07af79d15..88ad5e0027 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,5 +11,14 @@ compiler: before_install: - sudo apt-get update -qq - sudo apt-get install -y bison dejagnu gettext keyutils ldap-utils libldap2-dev libkeyutils-dev libssl-dev python-cjson python-paste python-pyrad slapd tcl-dev tcsh + - mkdir -p cmocka/build + - cd cmocka + - wget https://cmocka.org/files/1.0/cmocka-1.0.1.tar.xz + - tar -xvf cmocka-1.0.1.tar.xz + - cd build + - cmake ../cmocka-1.0.1 -DCMAKE_INSTALL_PREFIX=/usr + - make + - sudo make install + - cd ../.. script: cd src && autoreconf && ./configure --with-ldap && make && make check diff --git a/src/Makefile.in b/src/Makefile.in index d8c524fd6d..8f0e3eb277 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -498,6 +498,9 @@ check-unix: check-pytests-no: check-postrecurse @echo 'Skipped python test scripts: python 2.5 or later required' >> \ + +check-cmocka-no: check-postrecurse + @echo 'Skipped cmocka tests due to missing library or header file' >> \ $(SKIPTESTS) # Create a test realm and spawn a shell in an environment pointing to it. diff --git a/src/config/post.in b/src/config/post.in index 9180fd40cc..d792abc487 100644 --- a/src/config/post.in +++ b/src/config/post.in @@ -145,6 +145,13 @@ check-pytests-yes: check-pytests check-pytests-no: check-pytests: +# cmocka tests +check-unix: check-cmocka-@HAVE_CMOCKA@ + +check-cmocka-yes: check-cmocka +check-cmocka-no: +check-cmocka: + clean: clean-$(WHAT) clean-unix:: diff --git a/src/config/pre.in b/src/config/pre.in index ba0d1fc2bc..cec221897e 100644 --- a/src/config/pre.in +++ b/src/config/pre.in @@ -384,6 +384,7 @@ VERTO_LIBS = @VERTO_LIBS@ DL_LIB = @DL_LIB@ +CMOCKA_LIBS = @CMOCKA_LIBS@ LDAP_LIBS = @LDAP_LIBS@ KRB5_LIB = -lkrb5 diff --git a/src/configure.in b/src/configure.in index 58f89d9b15..7ef0c62e30 100644 --- a/src/configure.in +++ b/src/configure.in @@ -1097,6 +1097,23 @@ if test x"$PYTHON" != x; then fi AC_SUBST(HAVE_PYTHON) +# For cmocka tests. +CMOCKA_LIBS= +HAVE_CMOCKA=no +HAVE_CMOCKA_H=no +HAVE_CMOCKA_LIB=no +AC_CHECK_HEADER(cmocka.h, [HAVE_CMOCKA_H=yes], :, [ +#include +#include +#include ]) +AC_CHECK_LIB(cmocka, _cmocka_run_group_tests, [HAVE_CMOCKA_LIB=yes]) +if test "$HAVE_CMOCKA_LIB" = yes && test "$HAVE_CMOCKA_H" = yes; then + HAVE_CMOCKA=yes + CMOCKA_LIBS='-lcmocka' +fi +AC_SUBST(HAVE_CMOCKA) +AC_SUBST(CMOCKA_LIBS) + # for plugins/kdb/db2 # AIX is unusual in that it wants all symbols resolved at link time -- 2.47.2