summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2023-10-10 10:31:10 +0900
committerSukhyungKang <shine.kang@samsung.com>2023-11-13 09:37:43 +0900
commit784bebc90e0b354cc31128db22e5599634616599 (patch)
treed551a476584e2a1368370d1e7463d48e44f2aa9b
parentf12b01e83cfbc0842e8faea88a7243e5e91aac06 (diff)
downloadnotification-784bebc90e0b354cc31128db22e5599634616599.tar.gz
notification-784bebc90e0b354cc31128db22e5599634616599.tar.bz2
notification-784bebc90e0b354cc31128db22e5599634616599.zip
Fix build break issue
This patch removes access hook code about EXPECT_CALL(). While calling the exit handlers, the gcov calls the access() function. In that time, the TestFixture instance was destroyed. It causes the crash issue. +------------------------------------------------------------------------------+ | #0 0xb7fd4a51 in __kernel_vsyscall () | #1 0xb746a246 in __libc_signal_restore_set (set=0xbfffed00) at ../sysdeps/unix/sysv/linux/internal-signals.h:84 | #2 __GI_raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:48 | #3 0xb74513ce in __GI_abort () at abort.c:79 | #4 0xb76a4c1c in ?? () from /lib/libstdc++.so.6 | #5 0xb76b3336 in ?? () from /lib/libstdc++.so.6 | #6 0xb76b339f in std::terminate() () from /lib/libstdc++.so.6 | #7 0xb76b3682 in __cxa_throw () from /lib/libstdc++.so.6 | #8 0x08383cab in TestFixture::GetMock<GlibMock> () at /usr/lib/gcc/i586-tizen-linux-gnu/9.2.0/include/c++/ext/new_allocator.h:89 | #9 0x08674944 in access (arg1=0x8a14f90 "/home", arg2=0) at /usr/src/debug/notification-0.7.4-1.i386/tests/mock/glib_mock.cc:40 | #10 0x087313c1 in gcov_do_dump () | #11 0x08731b73 in __gcov_exit () | #12 0xb7fe6cc2 in _dl_fini () at dl-fini.c:138 | #13 0xb746cfff in __run_exit_handlers (status=status@entry=0, listp=0xb760439c <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, | run_dtors=run_dtors@entry=true) at exit.c:108 | #14 0xb746d1d5 in __GI_exit (status=0) at exit.c:139 | #15 0xb7452f5d in __libc_start_main (main=0x8136330 <main(int, char**)>, argc=1, argv=0xbffff4a4, init=0x8731cb0 <__libc_csu_init>, | fini=0x8731d20 <__libc_csu_fini>, rtld_fini=0xb7fe6ad0 <_dl_fini>, stack_end=0xbffff49c) at ../csu/libc-start.c:342 | #16 0x08149d01 in _start () at ../sysdeps/i386/start.S:126 +------------------------------------------------------------------------------+ Change-Id: Ic722adb053122e312e42cc2868777c1afb13b495 Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--tests/mock/glib_mock.cc12
-rw-r--r--tests/noti_unittest/CMakeLists.txt1
-rw-r--r--tests/noti_unittest/src/test_notification_db.cc3
-rw-r--r--tests/noti_unittest/src/test_notification_noti.cc3
4 files changed, 12 insertions, 7 deletions
diff --git a/tests/mock/glib_mock.cc b/tests/mock/glib_mock.cc
index 2e99040..d46610e 100644
--- a/tests/mock/glib_mock.cc
+++ b/tests/mock/glib_mock.cc
@@ -16,6 +16,8 @@
#include "glib_mock.hh"
+#include <dlfcn.h>
+
#include "mock_hook.hh"
#include "test_fixture.hh"
@@ -37,7 +39,15 @@ extern "C" gboolean g_file_make_directory(GFile* arg1, GCancellable* arg2,
}
extern "C" int access(const char* arg1, int arg2) {
- return MOCK_HOOK_P2(GlibMock, access, arg1, arg2);
+ if (strstr(arg1, ".notification.db") ||
+ strstr(arg1, "notification.ini"))
+ return 0;
+
+ int (*access_func)(const char*, int) =
+ reinterpret_cast<int (*)(const char*, int)>(dlsym(RTLD_NEXT, "access"));
+ if (access_func) return access_func(arg1, arg2);
+
+ return 0;
}
extern "C" ssize_t read(int fd, void *buf, size_t count) {
diff --git a/tests/noti_unittest/CMakeLists.txt b/tests/noti_unittest/CMakeLists.txt
index 81a955c..0e16d00 100644
--- a/tests/noti_unittest/CMakeLists.txt
+++ b/tests/noti_unittest/CMakeLists.txt
@@ -57,6 +57,7 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${notification-unittests_LDFLAGS}
gmock
notification
notification-ex
+ "-ldl"
)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
diff --git a/tests/noti_unittest/src/test_notification_db.cc b/tests/noti_unittest/src/test_notification_db.cc
index c1bd7c2..53f5159 100644
--- a/tests/noti_unittest/src/test_notification_db.cc
+++ b/tests/noti_unittest/src/test_notification_db.cc
@@ -90,9 +90,6 @@ TEST_F(NotificationDBTest, notification_db_test) {
.WillOnce(Invoke(__fake_sqlite3_column_text))
.WillOnce(Invoke(__fake_sqlite3_column_text_bundle));
- EXPECT_CALL(GetMock<GlibMock>(), access(_, _))
- .WillOnce(Return(0));
-
int ret;
sqlite3* db = nullptr;
diff --git a/tests/noti_unittest/src/test_notification_noti.cc b/tests/noti_unittest/src/test_notification_noti.cc
index d9ca168..c74ce35 100644
--- a/tests/noti_unittest/src/test_notification_noti.cc
+++ b/tests/noti_unittest/src/test_notification_noti.cc
@@ -85,9 +85,6 @@ TEST_F(NotificationNotiTest, notification_noti_test) {
EXPECT_CALL(GetMock<AulMock>(), aul_app_get_appid_bypid(_, _, _))
.WillRepeatedly(Invoke(__fake_aul_app_get_appid_bypid));
- EXPECT_CALL(GetMock<GlibMock>(), access(_, _))
- .WillRepeatedly(Return(0));
-
EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
.WillRepeatedly(Invoke(__fake_sqlite3_open_v2));