[LTP] [PATCH v5 3/3] Add futex_waitv testing suite
Cyril Hrubis
chrubis@suse.cz
Thu Feb 10 15:18:02 CET 2022
Hi!
I've fixed a few things in this patch and pushed the whole patchset,
thanks.
Full diff:
diff --git a/testcases/kernel/syscalls/futex/futex_waitv02.c b/testcases/kernel/syscalls/futex/futex_waitv02.c
index 2897f6c78..0a0e2b620 100644
--- a/testcases/kernel/syscalls/futex/futex_waitv02.c
+++ b/testcases/kernel/syscalls/futex/futex_waitv02.c
@@ -37,10 +37,10 @@ static void setup(void)
if (tst_parse_int(str_numfutex, &numfutex, 1, FUTEX_WAITV_MAX))
tst_brk(TBROK, "Invalid number of futexes '%s'", str_numfutex);
- futexes = SAFE_MALLOC(sizeof(uint32_t) * numfutex);
+ futexes = tst_alloc(sizeof(uint32_t) * numfutex);
memset(futexes, FUTEX_INITIALIZER, sizeof(uint32_t) * numfutex);
- waitv = SAFE_MALLOC(sizeof(struct futex_waitv) * numfutex);
+ waitv = tst_alloc(sizeof(struct futex_waitv) * numfutex);
memset(waitv, 0, sizeof(struct futex_waitv) * numfutex);
for (i = 0; i < numfutex; i++) {
@@ -60,8 +60,8 @@ static void *threaded(void *arg)
TEST(futex_wake(tv.fntype, (void *)(uintptr_t)waitv[numfutex - 1].uaddr,
1, FUTEX_PRIVATE_FLAG));
if (TST_RET < 0) {
- tst_brk(TBROK, "futex_wake private returned: %ld %s", TST_RET,
- tst_strerrno(TST_ERR));
+ tst_brk(TBROK | TTERRNO,
+ "futex_wake private returned: %ld", TST_RET);
}
return NULL;
@@ -70,7 +70,7 @@ static void *threaded(void *arg)
static void run(void)
{
struct timespec to;
- int ret, tid;
+ int tid;
pthread_t t;
tid = tst_syscall(__NR_gettid);
@@ -81,13 +81,13 @@ static void run(void)
SAFE_CLOCK_GETTIME(CLOCK_MONOTONIC, &to);
to.tv_sec++;
- ret = futex_waitv(waitv, numfutex, 0, &to, CLOCK_MONOTONIC);
- if (ret < 0)
- tst_brk(TBROK, "futex_waitv returned: %d %s", ret,
- tst_strerrno(-ret));
- else if (ret != numfutex - 1)
- tst_res(TFAIL, "futex_waitv returned: %d, expecting %d", ret,
- numfutex - 1);
+ TEST(futex_waitv(waitv, numfutex, 0, &to, CLOCK_MONOTONIC));
+ if (TST_RET < 0) {
+ tst_brk(TBROK | TTERRNO, "futex_waitv returned: %ld", TST_RET);
+ } else if (TST_RET != numfutex - 1) {
+ tst_res(TFAIL, "futex_waitv returned: %ld, expecting %d",
+ TST_RET, numfutex - 1);
+ }
SAFE_PTHREAD_JOIN(t, NULL);
tst_res(TPASS, "futex_waitv returned correctly");
diff --git a/testcases/kernel/syscalls/futex/futex_waitv03.c b/testcases/kernel/syscalls/futex/futex_waitv03.c
index 773cc5af3..d8e39c76a 100644
--- a/testcases/kernel/syscalls/futex/futex_waitv03.c
+++ b/testcases/kernel/syscalls/futex/futex_waitv03.c
@@ -39,7 +39,7 @@ static void setup(void)
if (tst_parse_int(str_numfutex, &numfutex, 1, FUTEX_WAITV_MAX))
tst_brk(TBROK, "Invalid number of futexes '%s'", str_numfutex);
- waitv = SAFE_MALLOC(sizeof(struct futex_waitv) * numfutex);
+ waitv = tst_alloc(sizeof(struct futex_waitv) * numfutex);
memset(waitv, 0, sizeof(struct futex_waitv) * numfutex);
for (i = 0; i < numfutex; i++) {
@@ -72,8 +72,8 @@ static void *threaded(void *arg)
TEST(futex_wake(tv.fntype, (void *)(uintptr_t)waitv[numfutex - 1].uaddr,
1, 0));
if (TST_RET < 0) {
- tst_brk(TBROK, "futex_wake private returned: %ld %s", TST_RET,
- tst_strerrno(TST_ERR));
+ tst_brk(TBROK | TTERRNO,
+ "futex_wake private returned: %ld", TST_RET);
}
return NULL;
@@ -94,12 +94,12 @@ static void run(void)
to.tv_sec++;
TEST(futex_waitv(waitv, numfutex, 0, &to, CLOCK_MONOTONIC));
- if (TST_RET < 0)
- tst_brk(TBROK, "futex_waitv returned: %ld %s", TST_RET,
- tst_strerrno(TST_ERR));
- else if (TST_RET != numfutex - 1)
+ if (TST_RET < 0) {
+ tst_brk(TBROK | TTERRNO, "futex_waitv returned: %ld", TST_RET);
+ } else if (TST_RET != numfutex - 1) {
tst_res(TFAIL, "futex_waitv returned: %ld, expecting %d",
TST_RET, numfutex - 1);
+ }
SAFE_PTHREAD_JOIN(t, NULL);
tst_res(TPASS, "futex_waitv returned correctly");
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list