From: Krzysztof Opasiak Date: Mon, 7 Aug 2017 18:33:30 +0000 (+0200) Subject: tests: Fix TEST_ENTRY_POINT() macro X-Git-Tag: submit/tizen/20170816.231957~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=296ca10ee44f41396faca523d176aa86ba1ba7ea;p=platform%2Fcore%2Fsystem%2Ffaultd.git tests: Fix TEST_ENTRY_POINT() macro Fix couple of issues: - remove ptr variable from release builds - Fix module name used in macro - Add other macros to help calling this function from test code Change-Id: If7b35ed4920e1f25121288146df84f8f2946ffb2 Signed-off-by: Krzysztof Opasiak --- diff --git a/Makefile.am b/Makefile.am index 02c8b90..a361003 100644 --- a/Makefile.am +++ b/Makefile.am @@ -131,7 +131,9 @@ test_LDFLAGS = -ldl test_LDADD = $(CMOCKA_LIBS) $(LIBSYSTEMD_LIBS) $(AUDIT_LIBS) \ $(LIBEJDB_LIBS) $(JSON_C_LIBS) -test_CFLAGS = -I${top_srcdir}/src/util +test_CFLAGS = -I${top_srcdir}/src/util \ + -D"FAULTD_MODNAME_T=$(call name_fix,$(modname))" \ + -DTEST_BUILD test_SOURCES = \ tests/unit/faultd_object_tests.c \ diff --git a/src/core/module.h b/src/core/module.h index f44df9e..7206098 100644 --- a/src/core/module.h +++ b/src/core/module.h @@ -26,9 +26,14 @@ #include "faultd-config.h" #include "list.h" -#ifdef ENABLE_TESTS +#ifdef TEST_BUILD + +#define TEST_ENTRY_POINT_NAME(MODULE, FUNC) \ + CONCAT(test_, CONCAT(MODULE, _ ## FUNC)) + #define TEST_ENTRY_POINT(func) \ typeof(func) (*CONCAT(FAULTD_MODNAME_T, _ ## func)) = func + #else #define TEST_ENTRY_POINT(func) #endif diff --git a/tests/unit/fdtf.h b/tests/unit/fdtf.h index 7665c23..29368ea 100644 --- a/tests/unit/fdtf.h +++ b/tests/unit/fdtf.h @@ -10,6 +10,12 @@ #include "common.h" #include "module.h" +#define CALL_TEST_ENTRY_POINT(MOD, FUNC) \ + TEST_ENTRY_POINT_NAME(MOD, FUNC) + +#define DECLARE_TEST_ENTRY_POINT(MOD, FUNC, RET, ...) \ + extern RET (*TEST_ENTRY_POINT_NAME(MOD, FUNC))(__VA_ARGS__) + struct fdtf_test_group { char *name; CMFixtureFunction setup;