krb5 commit: Add cmocka support

Greg Hudson ghudson at mit.edu
Wed Aug 10 12:33:50 EDT 2016


https://github.com/krb5/krb5/commit/0db097ba8b605ea7a6e0364ad786da6528868179
commit 0db097ba8b605ea7a6e0364ad786da6528868179
Author: Sarah Day <sarahday at mit.edu>
Date:   Mon Jul 25 13:20:08 2016 -0400

    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(+), 0 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a07af79..88ad5e0 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 d8c524f..8f0e3eb 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 9180fd4..d792abc 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- at 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 ba0d1fc..cec2218 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 58f89d9..7ef0c62 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 <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h> ])
+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


More information about the cvs-krb5 mailing list