test: Fix mock function to call the real one 35/301835/1 accepted/tizen_unified_riscv accepted/tizen/unified/20231128.175118 accepted/tizen/unified/riscv/20231211.234104
authorYoungjae Cho <y0.cho@samsung.com>
Fri, 24 Nov 2023 07:11:37 +0000 (16:11 +0900)
committeryoungjae cho <y0.cho@samsung.com>
Fri, 24 Nov 2023 08:31:55 +0000 (08:31 +0000)
commitf3a95d38c32297b5ffb20927485288b26e8f40d8
tree10fdf469bb9f26f73c5945b77889872b3f3d2191
parentad6be149d2c7449cb4660db172c83a042d4089c6
test: Fix mock function to call the real one

Technically, to call the real symbol open() associated with the
linker flag --wrap=open, it should be invoked via __real_open().
It is matter in some build environment. Without it, the mock function
__wrap_open() calls open(), which is call for __wrap_open() itself
recursively.

ASAN build blames it:

[ RUN      ] test_sys_get_str_p1
[  ERROR   ] --- No entries for symbol __wrap_open.
/home/abuild/rpmbuild/BUILD/libsyscommon-5.0.0/tests/test-mock.c:16:
     error: Could not get value to mock function __wrap_open
/home/abuild/rpmbuild/BUILD/libsyscommon-5.0.0/tests/test-mock.c:35:
     note: Previously returned mock value was declared here

In this case, the __wrap_open() is recursively called. Within the
recursive call, there is no more reserved value to get as it has
already been consumed up by the previous __wrap_open(), which is test
failure. Fixed open() to __real_open() in order not to recursively
call the __wrap_open() but to call the real open().

Change-Id: Ib53f13ed68f335929569ad8755e86a711a08e274
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
tests/CMakeLists.txt
tests/test-mock.c