From 9c5cbfadc99a8537f0d3ab4e195e884a891343a1 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Thu, 10 Jun 2021 16:40:15 +0900 Subject: [PATCH] Fix gcov build fail issue mkdir is used after unittest. So it should operates well. Change-Id: I6300aee51387d7b71c7213c4deaf90cae54f1ffa Signed-off-by: Changgyu Choi --- test/unit_tests/CMakeLists.txt | 2 +- test/unit_tests/mock/os_mock.cc | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/unit_tests/CMakeLists.txt b/test/unit_tests/CMakeLists.txt index 79e009b..cfe9de7 100644 --- a/test/unit_tests/CMakeLists.txt +++ b/test/unit_tests/CMakeLists.txt @@ -35,7 +35,7 @@ APPLY_PKG_CONFIG(${TARGET_AUL_UNIT_TESTS} PUBLIC XDGMIME_DEPS ) -TARGET_LINK_LIBRARIES(${TARGET_AUL_UNIT_TESTS} PUBLIC ${TARGET_AUL}) +TARGET_LINK_LIBRARIES(${TARGET_AUL_UNIT_TESTS} PUBLIC ${TARGET_AUL} "-ldl") SET_TARGET_PROPERTIES(${TARGET_AUL_UNIT_TESTS} PROPERTIES COMPILE_FLAGS "-fPIE") SET_TARGET_PROPERTIES(${TARGET_AUL_UNIT_TESTS} PROPERTIES LINK_FLAGS "-pie") diff --git a/test/unit_tests/mock/os_mock.cc b/test/unit_tests/mock/os_mock.cc index 0758acd..0992776 100644 --- a/test/unit_tests/mock/os_mock.cc +++ b/test/unit_tests/mock/os_mock.cc @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include "mock/mock_hook.h" @@ -21,7 +22,10 @@ #include "mock/test_fixture.h" extern "C" int mkdir(const char* path, mode_t mode) { - return MOCK_HOOK_P2(OsMock, mkdir, path, mode); + auto o_mkdir = reinterpret_cast(dlsym(RTLD_NEXT, "mkdir")); + if (o_mkdir != nullptr) + o_mkdir(path, mode); + return 0; } extern "C" int close(int fd) { -- 2.7.4