[PATCH 1/2] selftests: futex: Make futex_waitv's invalid clockid test more robust

From: André Almeida
Date: Thu Oct 28 2021 - 15:29:59 EST


If we use NULL for *waiters, we may be triggering a different error
path. Use a valid value for this arguments to make sure that the invalid
clockid is the one triggering the EINVAL return.

Signed-off-by: André Almeida <andrealmeid@xxxxxxxxxxxxx>
---
tools/testing/selftests/futex/functional/futex_waitv.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/futex/functional/futex_waitv.c b/tools/testing/selftests/futex/functional/futex_waitv.c
index a94337f677e1..336b04dacd0e 100644
--- a/tools/testing/selftests/futex/functional/futex_waitv.c
+++ b/tools/testing/selftests/futex/functional/futex_waitv.c
@@ -217,12 +217,17 @@ int main(int argc, char *argv[])
}

/* Testing an invalid clockid */
+ waitv[0].uaddr = (uintptr_t)&futexes[0];
+ waitv[0].flags = FUTEX_PRIVATE_FLAG | FUTEX_32;
+ waitv[0].val = 0;
+ waitv[0].__reserved = 0;
+
if (clock_gettime(CLOCK_MONOTONIC, &to))
error("gettime64 failed\n", errno);

to.tv_sec++;

- res = futex_waitv(NULL, NR_FUTEXES, 0, &to, CLOCK_TAI);
+ res = futex_waitv(waitv, 1, 0, &to, CLOCK_TAI);
if (res == EINVAL) {
ksft_test_result_fail("futex_waitv private returned: %d %s\n",
res ? errno : res,
--
2.33.1