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 <k.opasiak@samsung.com>
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 \
#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
#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;