Fix gcov build error 30/259630/1
authorHyunho <hhstark.kang@samsung.com>
Thu, 10 Jun 2021 09:01:07 +0000 (18:01 +0900)
committerHyunho <hhstark.kang@samsung.com>
Thu, 10 Jun 2021 09:01:07 +0000 (18:01 +0900)
Change-Id: Ifef513c3ebba53d4f51cfbaab19bded632a0e33d
Signed-off-by: Hyunho <hhstark.kang@samsung.com>
unittest/CMakeLists.txt
unittest/src/test_widget_service.cc

index 11a5709..6c30ccb 100644 (file)
@@ -37,6 +37,7 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${widget_service_unittests_LDFLAGS}
     ${pkgs_LIBRARIES}
     gmock
     widget_service
+    "-ldl"
 )
 
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
index aec4a7c..95d0dd0 100644 (file)
@@ -18,6 +18,7 @@
 #include <gmock/gmock.h>
 #include <stdio.h>
 #include <sqlite3.h>
+#include <dlfcn.h>
 
 #include "include/widget_service.h"
 #include "include/widget_errno.h"
@@ -59,17 +60,29 @@ int __fake_cynara_finish(cynara* cyn) {
 }
 
 int __fake_open(const char* path, int flag) {
+  auto o_open = reinterpret_cast<decltype(open)*>(dlsym(RTLD_NEXT, "open"));
+  if (o_open != nullptr)
+    o_open(path, flag);
   return 0;
 }
 
 ssize_t __fake_read(int fd, void* buf, size_t size) {
+  auto o_read = reinterpret_cast<decltype(read)*>(dlsym(RTLD_NEXT, "read"));
+  if (o_read != nullptr)
+    o_read(fd, buf, size);
   return 0;
 }
 
 int __fake_chown(const char *pathname, uid_t owner, gid_t group) {
+  auto o_chown = reinterpret_cast<decltype(chown)*>(dlsym(RTLD_NEXT, "chown"));
+  if (o_chown != nullptr)
+    o_chown(pathname, owner, group);
   return 0;
 }
 int __fake_chmod(const char *pathname, mode_t mode) {
+  auto o_chmod = reinterpret_cast<decltype(chmod)*>(dlsym(RTLD_NEXT, "chmod"));
+  if (o_chmod != nullptr)
+    o_chmod(pathname, mode);
   return 0;
 }