test: cmocka-fd-handler: Add cmocka fd handler during build 72/320472/2
authorUnsung Lee <unsung.lee@samsung.com>
Sat, 9 Nov 2024 06:12:06 +0000 (15:12 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Mon, 25 Nov 2024 02:31:45 +0000 (11:31 +0900)
Add cmocka test for the fd handler. The test code was previously excluded from the build
due to not reflecting the latest resourced code.
It allows the cmocka for fd handler tests to be executed at build time.

Change-Id: If147c63deff89213106dade8540ff8d0c2f04b8f
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
tests/CMakeLists.txt
tests/cmocka-fd-handler.c

index 5417e3c6fb267c3e7bf24cdb5de7e9e4baed3166..3fba61190ad6de69640dbe04c333b3a82080ca09 100644 (file)
@@ -77,6 +77,7 @@ endfunction()
 #ADD_TESTS(test-common "${UNIT_TESTS_CFLAGS}" "-O0" test-common.c)
 #ADD_TESTS(test-safe-kill "${UNIT_TESTS_CFLAGS}" "-Wl,--wrap=kill,--wrap=fopen,--wrap=fopen64 -O0" test-safe-kill.c)
 ADD_TESTS(cmocka-memory-cgroup "${UNIT_TESTS_CFLAGS}" "-Wl,--wrap=fread_int,--wrap=fread_uint,--wrap=fread_ulonglong -O0" cmocka-memory-cgroup.c)
+ADD_TESTS(cmocka-fd-handler "${UNIT_TESTS_CFLAGS}" "-Wl,--wrap=malloc,--wrap=free -O0" cmocka-fd-handler.c)
 
 function(ADD_SKIP_TEST name wraps sources)
        ADD_EXECUTABLE(${name} ${sources})
index ef978e574314ff3062f18bd4c88ecd9aee83df1c..fb9fd2d7346f9b57108f189315d70ae55bfbc03b 100644 (file)
@@ -132,9 +132,9 @@ static void test_add_fd_read_handler(void **state)
        assert(fd_handler_ctx != NULL);
        assert(fd_handler_ctx->fd >= 0);
 
-       assert_int_equal(add_fd_read_handler(-1, NULL, NULL, NULL, &(fd_handler_ctx->handler)), -EINVAL);
-       assert_int_equal(add_fd_read_handler(231, NULL, NULL, NULL, &(fd_handler_ctx->handler)), -EINVAL);
-       assert_int_equal(add_fd_read_handler(fd_handler_ctx->fd[0], test_fd_read_handler_cb,
+       assert_int_equal(add_fd_read_handler(NULL, -1, NULL, NULL, NULL, &(fd_handler_ctx->handler)), -EINVAL);
+       assert_int_equal(add_fd_read_handler(NULL, 231, NULL, NULL, NULL, &(fd_handler_ctx->handler)), -EINVAL);
+       assert_int_equal(add_fd_read_handler(NULL, fd_handler_ctx->fd[0], test_fd_read_handler_cb,
                                fd_handler_ctx, test_fd_read_handler_release_cb, &(fd_handler_ctx->handler)), 0);
 }