All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v3] futex_waitv01: Add test verifies EAGIN/ETIMEDOUT
@ 2022-06-08  3:19 Zhao Gongyi via ltp
  2022-06-09 13:45 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Zhao Gongyi via ltp @ 2022-06-08  3:19 UTC (permalink / raw)
  To: ltp

Add test verifies EAGIN/ETIMEDOUT for futex_waitv according to
https://www.kernel.org/doc/html/latest/userspace-api/futex2.html.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
v2->v3:
	1. Replace CLOCK_REALTIME with CLOCK_MONOTONIC
	2. Change from 1s to 10ms for the timeout
 .../kernel/syscalls/futex/futex_waitv01.c     | 35 +++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/futex/futex_waitv01.c b/testcases/kernel/syscalls/futex/futex_waitv01.c
index f2c19b748..17b96738c 100644
--- a/testcases/kernel/syscalls/futex/futex_waitv01.c
+++ b/testcases/kernel/syscalls/futex/futex_waitv01.c
@@ -107,12 +107,41 @@ static void test_invalid_nr_futexes(void)
 	init_timeout(&to);

 	/* Valid nr_futexes is [1, 128] */
-	TST_EXP_FAIL(futex_waitv(waitv, 129, 0, &to, CLOCK_REALTIME), EINVAL,
+	TST_EXP_FAIL(futex_waitv(waitv, 129, 0, &to, CLOCK_MONOTONIC), EINVAL,
 		     "futex_waitv invalid nr_futexes");
-	TST_EXP_FAIL(futex_waitv(waitv, 0, 0, &to, CLOCK_REALTIME), EINVAL,
+	TST_EXP_FAIL(futex_waitv(waitv, 0, 0, &to, CLOCK_MONOTONIC), EINVAL,
 		     "futex_waitv invalid nr_futexes");
 }

+static void test_mismatch_between_uaddr_and_val(void)
+{
+	struct timespec to;
+
+	waitv->uaddr = (uintptr_t)futex;
+	waitv->flags = FUTEX_32 | FUTEX_PRIVATE_FLAG;
+	waitv->val = 1;
+
+	init_timeout(&to);
+
+	TST_EXP_FAIL(futex_waitv(waitv, 1, 0, &to, CLOCK_MONOTONIC), EAGAIN,
+		     "futex_waitv mismatch between value of uaddr and val");
+}
+
+static void test_timeout(void)
+{
+	struct timespec to;
+
+	waitv->uaddr = (uintptr_t)futex;
+	waitv->flags = FUTEX_32 | FUTEX_PRIVATE_FLAG;
+	waitv->val = 0;
+
+	SAFE_CLOCK_GETTIME(CLOCK_REALTIME, &to);
+	to = tst_timespec_add_us(to, 10000);
+
+	TST_EXP_FAIL(futex_waitv(waitv, 1, 0, &to, CLOCK_REALTIME), ETIMEDOUT,
+		     "futex_waitv timeout");
+}
+
 static void cleanup(void)
 {
 	free(futex);
@@ -126,6 +155,8 @@ static void run(void)
 	test_null_waiters();
 	test_invalid_clockid();
 	test_invalid_nr_futexes();
+	test_mismatch_between_uaddr_and_val();
+	test_timeout();
 }

 static struct tst_test test = {
--
2.17.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [LTP] [PATCH v3] futex_waitv01: Add test verifies EAGIN/ETIMEDOUT
  2022-06-08  3:19 [LTP] [PATCH v3] futex_waitv01: Add test verifies EAGIN/ETIMEDOUT Zhao Gongyi via ltp
@ 2022-06-09 13:45 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2022-06-09 13:45 UTC (permalink / raw)
  To: Zhao Gongyi; +Cc: ltp

Hi!
Applied, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-09 13:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08  3:19 [LTP] [PATCH v3] futex_waitv01: Add test verifies EAGIN/ETIMEDOUT Zhao Gongyi via ltp
2022-06-09 13:45 ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.