From e598dbfe781a2e349e8b99af2cbae23294c7590e Mon Sep 17 00:00:00 2001 From: dhy308 Date: Wed, 4 Jan 2023 11:53:44 +0800 Subject: [PATCH] fix review problems Signed-off-by: dhy308 --- libc-test/src/functionalext/fortify/fcntl_ext.c | 9 +++++---- libc-test/src/functionalext/fortify/poll.c | 5 +++-- libc-test/src/functionalext/fortify/string_ext.c | 3 ++- .../functionalext/supplement/passwd/getspnam_r.c | 13 ++++--------- .../src/functionalext/thread/pthread_mutex_ext.c | 2 +- .../functionalext/thread/pthread_rwlock_rdlock.c | 2 +- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/libc-test/src/functionalext/fortify/fcntl_ext.c b/libc-test/src/functionalext/fortify/fcntl_ext.c index 3a7320aa..38090e30 100644 --- a/libc-test/src/functionalext/fortify/fcntl_ext.c +++ b/libc-test/src/functionalext/fortify/fcntl_ext.c @@ -18,6 +18,7 @@ #include #include #include "fortify_test.h" +#include "functionalext.h" #include "test.h" #define FILE_MODE_ALL (0777) @@ -120,7 +121,7 @@ static void open_0030(void) static void open_0040(void) { int fd = open("/proc/version", O_RDWR); - TEST(fd != -1); + EXPECT_NE(open_0040, fd, -1); close(fd); return; @@ -216,7 +217,7 @@ static void openat_0030(void) static void openat_0040(void) { int fd = openat(AT_FDCWD, "/proc/version", O_RDWR); - TEST(fd != -1); + EXPECT_NE(openat_0040, fd, -1); close(fd); return; @@ -313,7 +314,7 @@ static void open64_0030(void) static void open64_0040(void) { int fd = open64("/proc/version", O_RDWR); - TEST(fd != -1); + EXPECT_NE(open64_0040, fd, -1); close(fd); return; @@ -409,7 +410,7 @@ static void openat64_0030(void) static void openat64_0040(void) { int fd = openat64(AT_FDCWD, "/proc/version", O_RDWR); - TEST(fd != -1); + EXPECT_NE(openat64_0040, fd, -1); close(fd); return; diff --git a/libc-test/src/functionalext/fortify/poll.c b/libc-test/src/functionalext/fortify/poll.c index 730846c1..d3a0b615 100644 --- a/libc-test/src/functionalext/fortify/poll.c +++ b/libc-test/src/functionalext/fortify/poll.c @@ -19,6 +19,7 @@ #include #include #include "fortify_test.h" +#include "functionalext.h" #include "test.h" #define PPOLL_TIMESPEC_NSEC (100) @@ -82,7 +83,7 @@ static void poll_0030(void) { nfds_t fd_count = atoi("1"); struct pollfd buf[2] = {{0, POLLIN, 0}, {1, POLLIN, 0}}; - TEST(poll(buf, fd_count, 1) == 1); + EXPECT_EQ(poll_0030, poll(buf, fd_count, 1), 1); return; } @@ -151,7 +152,7 @@ static void ppoll_0030(void) nfds_t fd_count = atoi("1"); struct pollfd buf[2] = {{0, POLLIN, 0}, {1, POLLIN, 0}}; struct timespec ts = { .tv_nsec = PPOLL_TIMESPEC_NSEC }; - TEST(ppoll(buf, fd_count, &ts, NULL) == 1); + EXPECT_EQ(ppoll_0030, ppoll(buf, fd_count, &ts, NULL), 1); return; } diff --git a/libc-test/src/functionalext/fortify/string_ext.c b/libc-test/src/functionalext/fortify/string_ext.c index cfade06f..d0108374 100644 --- a/libc-test/src/functionalext/fortify/string_ext.c +++ b/libc-test/src/functionalext/fortify/string_ext.c @@ -20,6 +20,7 @@ #include #include #include "fortify_test.h" +#include "functionalext.h" #include "test.h" #include "../../../../porting/linux/user/include/fortify/fortify.h" @@ -909,7 +910,7 @@ static void test_strlen_0020() exit(0); default: waitpid(pid, &status, WUNTRACED); - TEST(WIFEXITED(status) == 0); + EXPECT_EQ(test_strlen_0020, WIFEXITED(status), 0); kill(pid, SIGCONT); break; } diff --git a/libc-test/src/functionalext/supplement/passwd/getspnam_r.c b/libc-test/src/functionalext/supplement/passwd/getspnam_r.c index d8d77ade..38d3b0cc 100644 --- a/libc-test/src/functionalext/supplement/passwd/getspnam_r.c +++ b/libc-test/src/functionalext/supplement/passwd/getspnam_r.c @@ -16,6 +16,7 @@ #include #include #include +#include "functionalext.h" #include "test.h" /** @@ -34,15 +35,9 @@ void getspnam_r_0100(void) const char *spwd_name = "root"; int result = getspnam_r(spwd_name, &spwd_storage, buf, sizeof(buf), &spwd); - if (result != 0) { - t_error("%s getgrnam_r failed\n", __func__); - } - if (!spwd) { - t_error("%s failed, spwd is NULL\n", __func__); - } - if (strcmp(spwd_name, spwd->sp_namp)) { - t_error("%s spwd->sp_namp is %s\n", __func__, spwd->sp_namp); - } + EXPECT_EQ(getspnam_r_0100, result, 0); + EXPECT_PTRNE(getspnam_r_0100, spwd, NULL); + EXPECT_EQ(getspnam_r_0100, strcmp(spwd_name, spwd->sp_namp), 0); } int main(int argc, char *argv[]) diff --git a/libc-test/src/functionalext/thread/pthread_mutex_ext.c b/libc-test/src/functionalext/thread/pthread_mutex_ext.c index 44ce2ad7..9cf05314 100644 --- a/libc-test/src/functionalext/thread/pthread_mutex_ext.c +++ b/libc-test/src/functionalext/thread/pthread_mutex_ext.c @@ -310,7 +310,7 @@ static void pthread_mutex_timedlock_monotonic_np_0030(void) { pthread_mutex_t *mtx = (pthread_mutex_t *)NULL; struct timespec ts = {0}; - TEST(pthread_mutex_timedlock_monotonic_np(mtx, &ts) == EINVAL); + EXPECT_EQ(pthread_mutex_timedlock_monotonic_np(mtx, &ts), EINVAL); } /********************************************* Test case dividing line ***********************************************/ diff --git a/libc-test/src/functionalext/thread/pthread_rwlock_rdlock.c b/libc-test/src/functionalext/thread/pthread_rwlock_rdlock.c index 01823c6b..45a900e7 100644 --- a/libc-test/src/functionalext/thread/pthread_rwlock_rdlock.c +++ b/libc-test/src/functionalext/thread/pthread_rwlock_rdlock.c @@ -277,7 +277,7 @@ static void pthread_rwlock_timedrdlock_monotonic_np_0020(void) static void pthread_rwlock_timedrdlock_monotonic_np_0030(void) { struct timespec ts = {0}; - TEST(pthread_rwlock_timedrdlock_monotonic_np((pthread_rwlock_t *)NULL, &ts) == EINVAL); + EXPECT_EQ(pthread_rwlock_timedrdlock_monotonic_np((pthread_rwlock_t *)NULL, &ts), EINVAL); } int main(void) -- GitLab