From 3633bc9054a955753ee438d6a9147b505f9f9f69 Mon Sep 17 00:00:00 2001 From: Jan Michalski Date: Thu, 7 Mar 2024 15:08:23 -0500 Subject: [PATCH] test: don't configure the log function for PMEMOBJ... ... nor PMEMCORE. Signed-off-by: Jan Michalski --- src/test/Makefile.inc | 15 ++-------- src/test/core_log/Makefile.inc | 3 +- src/test/core_log_default_function/Makefile | 4 +-- .../core_log_internal/core_log_internal.c | 3 -- src/test/core_log_no_func/core_log_no_func.c | 3 -- src/test/core_log_threshold_mt/Makefile | 2 +- src/test/unittest/Makefile | 3 +- src/test/unittest/unittest.h | 25 +---------------- src/test/unittest/ut_log.c | 28 ------------------- 9 files changed, 8 insertions(+), 78 deletions(-) delete mode 100644 src/test/unittest/ut_log.c diff --git a/src/test/Makefile.inc b/src/test/Makefile.inc index f9f635758e4..0da5eee2186 100644 --- a/src/test/Makefile.inc +++ b/src/test/Makefile.inc @@ -385,13 +385,11 @@ endif ifeq ($(LIBPMEMCORE), y) LIBPMEM=y -USE_LOG_PMEMCORE=y OBJS += $(LIBS_DIR)/debug/libpmemcore.a INCS += -I$(TOP)/src/core endif ifeq ($(LIBPMEMCORE), internal-nondebug) -USE_LOG_PMEMCORE=y OBJS +=\ $(TOP)/src/nondebug/core/alloc.o\ $(TOP)/src/nondebug/core/fs_posix.o\ @@ -410,7 +408,6 @@ INCS += -I$(TOP)/src/core endif ifeq ($(LIBPMEMCORE), internal-debug) -USE_LOG_PMEMCORE=y OBJS +=\ $(TOP)/src/debug/core/alloc.o\ $(TOP)/src/debug/core/fs_posix.o\ @@ -531,19 +528,13 @@ CFLAGS += -DFAULT_INJECTION=1 CXXFLAGS += -DFAULT_INJECTION=1 endif -ifeq ($(USE_LOG_PMEMCORE),y) -CFLAGS += -DUSE_LOG_PMEMCORE -endif - ifeq ($(USE_LOG_PMEMOBJ),y) CFLAGS += -DUSE_LOG_PMEMOBJ endif -# USE_LOG_PMEMCORE != y means the binary is built without directly linking with -# core units which are required by libut.a (ut_log.c to be exact). -# In case the binary is built with directly linking with core units it is -# assumed the following are among them already. -ifneq ($(USE_LOG_PMEMCORE),y) +# LIBPMEMCORE == '' means the binary is built without directly linking with +# core units which are required whenever test makes use of core utils. +ifeq ($(LIBPMEMCORE),) OBJS += $(TOP)/src/debug/core/out.o OBJS += $(TOP)/src/debug/core/last_error_msg.o OBJS += $(TOP)/src/debug/core/log.o diff --git a/src/test/core_log/Makefile.inc b/src/test/core_log/Makefile.inc index 7eb23ab70c0..1e2ecb614bb 100644 --- a/src/test/core_log/Makefile.inc +++ b/src/test/core_log/Makefile.inc @@ -4,8 +4,7 @@ BUILD_STATIC_DEBUG=n BUILD_STATIC_NONDEBUG=n -# 'internal' is required for proper mock integration -# 'debug' provides 'out_log()' required for 'ut_log_function()' +# required for proper mock integration LIBPMEMCORE=internal-debug include ../Makefile.inc diff --git a/src/test/core_log_default_function/Makefile b/src/test/core_log_default_function/Makefile index f81b3907a37..6857d30cb99 100644 --- a/src/test/core_log_default_function/Makefile +++ b/src/test/core_log_default_function/Makefile @@ -7,9 +7,7 @@ OBJS = core_log_default_function.o BUILD_STATIC_DEBUG=n BUILD_STATIC_NONDEBUG=n -# 'internal' is required for proper mock integration -# 'debug' is required for debug version of core/log.o that provides -# implementation of 'out_log()' that is used by 'ut_log_function()' +# required for proper mock integration LIBPMEMCORE=internal-debug include ../Makefile.inc diff --git a/src/test/core_log_internal/core_log_internal.c b/src/test/core_log_internal/core_log_internal.c index 637cce50518..948a4aea915 100644 --- a/src/test/core_log_internal/core_log_internal.c +++ b/src/test/core_log_internal/core_log_internal.c @@ -245,9 +245,6 @@ static struct test_case test_cases[] = { #undef abort extern void abort(void) __THROW __attribute__((__noreturn__)); -#undef LOG_SET_PMEMCORE_FUNC -#define LOG_SET_PMEMCORE_FUNC - int main(int argc, char *argv[]) { diff --git a/src/test/core_log_no_func/core_log_no_func.c b/src/test/core_log_no_func/core_log_no_func.c index 4b64500f845..d3672c3ca70 100644 --- a/src/test/core_log_no_func/core_log_no_func.c +++ b/src/test/core_log_no_func/core_log_no_func.c @@ -55,9 +55,6 @@ static struct test_case test_cases[] = { #define NTESTS ARRAY_SIZE(test_cases) -#undef LOG_SET_PMEMCORE_FUNC -#define LOG_SET_PMEMCORE_FUNC - int main(int argc, char *argv[]) { diff --git a/src/test/core_log_threshold_mt/Makefile b/src/test/core_log_threshold_mt/Makefile index 2c7ad36734d..545331e97fc 100644 --- a/src/test/core_log_threshold_mt/Makefile +++ b/src/test/core_log_threshold_mt/Makefile @@ -7,6 +7,6 @@ OBJS = core_log_threshold_mt.o BUILD_STATIC_DEBUG=n BUILD_STATIC_NONDEBUG=n -LIBPMEMCORE=nondebug +LIBPMEMCORE=y include ../Makefile.inc diff --git a/src/test/unittest/Makefile b/src/test/unittest/Makefile index 59e580e3ac4..6244049d16b 100644 --- a/src/test/unittest/Makefile +++ b/src/test/unittest/Makefile @@ -16,8 +16,7 @@ vpath %.h $(TOP)/src/core TARGET_UT = libut.a OBJS_UT = ut.o ut_alloc.o ut_file.o ut_pthread.o ut_signal.o ut_backtrace.o\ - os_posix.o os_thread_posix.o util.o alloc.o rand.o ut_fh.o ut_mt.o\ - ut_log.o + os_posix.o os_thread_posix.o util.o alloc.o rand.o ut_fh.o ut_mt.o CFLAGS = -I$(TOP)/src/include CFLAGS += -I$(TOP)/src/common diff --git a/src/test/unittest/unittest.h b/src/test/unittest/unittest.h index c13422871ee..dfcf9d195b9 100644 --- a/src/test/unittest/unittest.h +++ b/src/test/unittest/unittest.h @@ -121,32 +121,9 @@ void ut_err(const char *file, int line, const char *func, const char *fmt, ...) __attribute__((format(printf, 4, 5))); -void -ut_log_function(enum core_log_level level, const char *file_name, - const int line_no, const char *function_name, - const char *message); - -#ifdef USE_LOG_PMEMCORE -#define LOG_SET_PMEMCORE_FUNC core_log_set_function(ut_log_function) -#else -#define LOG_SET_PMEMCORE_FUNC -#endif - -#ifdef USE_LOG_PMEMOBJ -#define LOG_SET_PMEMOBJ_FUNC \ - pmemobj_log_set_function((pmemobj_log_function *)ut_log_function) -#else -#define LOG_SET_PMEMOBJ_FUNC -#endif - /* indicate the start of the test */ #define START(argc, argv, ...)\ - do {\ - ut_start(__FILE__, __LINE__, __func__, argc, argv,\ - __VA_ARGS__);\ - LOG_SET_PMEMCORE_FUNC; \ - LOG_SET_PMEMOBJ_FUNC; \ - } while (0) + ut_start(__FILE__, __LINE__, __func__, argc, argv, __VA_ARGS__) /* normal exit from test */ #define DONE(...)\ diff --git a/src/test/unittest/ut_log.c b/src/test/unittest/ut_log.c deleted file mode 100644 index 8c03185fbbe..00000000000 --- a/src/test/unittest/ut_log.c +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -/* Copyright 2024, Intel Corporation */ - -/* - * ut_log.c -- unit test log function - * - */ - -#include "unittest.h" -#include "out.h" - -static const int core_log_level_to_out_level[] = { - [CORE_LOG_LEVEL_HARK] = 1, - [CORE_LOG_LEVEL_FATAL] = 1, - [CORE_LOG_LEVEL_ERROR] = 1, - [CORE_LOG_LEVEL_WARNING] = 2, - [CORE_LOG_LEVEL_NOTICE] = 3, - [CORE_LOG_LEVEL_INFO] = 4, - [CORE_LOG_LEVEL_DEBUG] = 4, -}; - -void -ut_log_function(enum core_log_level level, const char *file_name, - const int line_no, const char *function_name, const char *message) -{ - out_log(file_name, line_no, function_name, - core_log_level_to_out_level[(int)level], "%s", message); -}