Add the option to enable testing code 05/134105/2
authorŁukasz Stelmach <l.stelmach@samsung.com>
Wed, 14 Jun 2017 14:30:20 +0000 (16:30 +0200)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Wed, 14 Jun 2017 14:42:48 +0000 (16:42 +0200)
Add the option in configure.ac and the macro to define entry points
for testing code.

Change-Id: Icbdc657283b925935861e951123a3b4d4ee55662
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
configure.ac
src/core/module.h

index 2778466885fb5ec35f0fc06af9021522aa12396a..318051fb3f54c2ad5d0d518a9b56dea3acf7ff5e 100644 (file)
@@ -35,6 +35,14 @@ AC_ARG_ENABLE([test_programs],
 
 AM_CONDITIONAL(BUILD_TEST_PROGRAMS, [test "x$enable_test_programs" = xyes])
 
+AC_ARG_ENABLE([tests],
+             AS_HELP_STRING([--enable-tests], [enable tests]),
+             [enable_test_programs=$enableval], [enable_tests=no])
+if test "x$enable_tests" = "xyes"; then
+        AC_DEFINE(ENABLE_TESTS, 1, [Define if testing code is to be enabled])
+fi
+AM_CONDITIONAL(ENABLE_TESTS, [test "x$enable_tests" = xyes])
+
 PKG_CHECK_MODULES(LIBSYSTEMD,
         [libsystemd >= 231],
         have_libsystemd=yes,
index 9f0f78c04f92907d9e6bd36a0b66bdc7808045c0..931a4e59f712cd307ea6a2de4b18d183689efe61 100644 (file)
 #include <time.h>
 #include <systemd/sd-event.h>
 
-#include "list.h"
 #include "common.h"
+#include "config.h"
+#include "list.h"
+
+#ifdef ENABLE_TESTS
+#define TEST_ENTRY_POINT(func) \
+       typeof(func) CONCAT(FAULTD_MODNAME_T, _ ## func) = func
+#else
+#define TEST_ENTRY_POINT(func)
+#endif
 
 #define FAULTD_MODNAME STR(FAULTD_MODNAME_T)