diff options
author | Niels de Vos <ndevos@redhat.com> | 2015-02-18 14:47:01 +0100 |
---|---|---|
committer | Kaleb KEITHLEY <kkeithle@redhat.com> | 2015-03-05 13:51:37 -0800 |
commit | bc2e58a436002e1627a225663bc7b11dddc1172f (patch) | |
tree | f586bcf41d82dcbb6979741ca299ff1291f9a8f7 /configure.ac | |
parent | 0bef7717d3100734c6c5a4ba85de7a39e76774db (diff) |
testing: Switch to cmocka the successor of cmockery2
This uses https://cmocka.org/ as the unit testing framework.
With this change, unit testing is made optional as well. We assume there
is no cmocka available while building. cmocka will be enabled by default
later on. For now, to build with cmocka run:
$ ./configure --enable-cmocka
This change is based on the work of Andreas (replacing cmockery2 with
cmocka) and Kaleb (make cmockery2 an optional build dependency).
The only modifications I made, are additional #defines in unittest.h for
making sure the unit tests function as expected.
Change-Id: Iea4cbcdaf09996b49ffcf3680c76731459cb197e
BUG: 1067059
Merged-change: http://review.gluster.org/9762/
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Change-Id: Ia2e955481c102d5dce17695a9205395a6030e985
Reviewed-on: http://review.gluster.org/9738
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/configure.ac b/configure.ac index 2d93ce847b6..2c3b0e31c1c 100644 --- a/configure.ac +++ b/configure.ac @@ -344,21 +344,6 @@ AC_CHECK_LIB([crypto], [MD5], , AC_MSG_ERROR([OpenSSL crypto library is required AC_CHECK_LIB([pthread], [pthread_mutex_init], , AC_MSG_ERROR([Posix threads library is required to build glusterfs])) - -PKG_CHECK_MODULES([UNITTEST], [cmockery2], [ - UNITTEST_CPPFLAGS=`${PKG_CONFIG} --print-errors --cflags-only-I "cmockery2"` - UNITTEST_CFLAGS=`${PKG_CONFIG} --print-errors --cflags-only-other "cmockery2"` - UNITTEST_LDFLAGS=`${PKG_CONFIG} --print-errors --libs-only-L "cmockery2"` - UNITTEST_LIBS=`${PKG_CONFIG} --print-errors --libs-only-l "cmockery2"` -],[ - AC_CHECK_LIB([cmockery], [mock_assert], [ - UNITTEST_LDFLAGS="-lcmockery -lgcov" - UNITTEST_CFLAGS="-Wall -Werror -DUNIT_TESTING=1" - ], [ - AC_MSG_ERROR([cmockery2 library is required to build glusterfs]) - ]) -]) - AC_CHECK_FUNC([dlopen], [has_dlopen=yes], AC_CHECK_LIB([dl], [dlopen], , AC_MSG_ERROR([Dynamic linking library required to build glusterfs]))) AC_CHECK_LIB([readline], [rl_do_undo], [RL_UNDO="yes"], [RL_UNDO="no"]) @@ -740,22 +725,6 @@ dnl check for Monotonic clock AC_CHECK_LIB([rt], [clock_gettime], , AC_MSG_WARN([System doesn't have monotonic clock using contrib])) -dnl Add cmockery2 for unit tests -case $host_os in - freebsd*) - dnl remove --coverage on FreeBSD due to a known llvm packaging bug - UNITTEST_CFLAGS="${UNITTEST_CPPFLAGS} ${UNITTEST_CFLAGS} -g -DDEBUG -O0" - UNITTEST_LDFLAGS="${UNITTEST_LIBS} ${UNITTEST_LDFLAGS}" - ;; - *) - UNITTEST_CFLAGS="${UNITTEST_CPPFLAGS} ${UNITTEST_CFLAGS} -g -DDEBUG -O0 --coverage" - UNITTEST_LDFLAGS="${UNITTEST_LIBS} ${UNITTEST_LDFLAGS}" - ;; -esac - -AC_SUBST(UNITTEST_CFLAGS) -AC_SUBST(UNITTEST_LDFLAGS) - dnl Check for argp AC_CHECK_HEADER([argp.h], AC_DEFINE(HAVE_ARGP, 1, [have argp])) @@ -1105,12 +1074,45 @@ PKG_CHECK_MODULES([URCU_CDS], [liburcu-cds >= 0.8], [], [AC_DEFINE(URCU_0_7, 1, [Define if liburcu 0.7 is found])], [AC_MSG_ERROR([liburcu >= 0.7 required])])]) +BUILD_UNITTEST="no" +AC_ARG_ENABLE([cmocka], + AC_HELP_STRING([--enable-cmocka], + [Enable cmocka build options.])) +if test "x$enable_cmocka" = "xyes"; then + BUILD_UNITTEST="yes" + PKG_CHECK_MODULES([UNITTEST], [cmocka], [],[ + AC_CHECK_LIB([cmocka], [mock_assert], [ + UNITTEST_LDFLAGS="-lcmocka -lgcov" + UNITTEST_CFLAGS="-Wall -Werror" + ], [ + AC_MSG_ERROR([cmocka library is required to build glusterfs]) + ]) + ]) +fi +AM_CONDITIONAL([UNITTEST], [test x$BUILD_UNITTEST = xyes]) + +dnl Define UNIT_TESTING only for building cmocka binaries. +UNITTEST_CFLAGS="${UNITTEST_CFLAGS} -DUNIT_TESTING=1" + +dnl Add cmocka for unit tests +case $host_os in + freebsd*) + dnl remove --coverage on FreeBSD due to a known llvm packaging bug + UNITTEST_CFLAGS="${UNITTEST_CPPFLAGS} ${UNITTEST_CFLAGS} -g -DDEBUG -O0" + UNITTEST_LDFLAGS="${UNITTEST_LIBS} ${UNITTEST_LDFLAGS}" + ;; + *) + UNITTEST_CFLAGS="${UNITTEST_CPPFLAGS} ${UNITTEST_CFLAGS} -g -DDEBUG -O0 --coverage" + UNITTEST_LDFLAGS="${UNITTEST_LIBS} ${UNITTEST_LDFLAGS}" + ;; +esac + +AC_SUBST(UNITTEST_CFLAGS) +AC_SUBST(UNITTEST_LDFLAGS) + AC_SUBST(CFLAGS) # end enable debug section -dnl Required if cmockery2 headers are not in standar paths -GF_CFLAGS="${GF_CFLAGS} ${UNITTEST_CPPFLAGS}" - AC_SUBST(GF_HOST_OS) AC_SUBST(GF_CFLAGS) AC_SUBST(GF_LDFLAGS) @@ -1189,4 +1191,5 @@ echo "Use syslog : $USE_SYSLOG" echo "XML output : $BUILD_XML_OUTPUT" echo "QEMU Block formats : $BUILD_QEMU_BLOCK" echo "Encryption xlator : $BUILD_CRYPT_XLATOR" +echo "Unit Tests : $BUILD_UNITTEST" echo |