All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [LTP] [PATCH] futex_waitv04: Add test for futex_waitv syscall
@ 2022-04-15  1:27 zhaogongyi via ltp
  2022-06-06 14:35 ` Cyril Hrubis
  0 siblings, 1 reply; 5+ messages in thread
From: zhaogongyi via ltp @ 2022-04-15  1:27 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril,

I also wondered whether to add these two testcases into futex_waitv01.c, there is a consideration that there are alse two other testcases need to be added according to linux manual:

1. A signal was sent to the sleeping task, returning -ERESTARTSYS.
2. Some futex at the list was woken, returning the index of some waked futex.

Best wishes!

Gongyi

> Hi!
> > diff --git a/testcases/kernel/syscalls/futex/futex_waitv04.c
> > b/testcases/kernel/syscalls/futex/futex_waitv04.c
> > new file mode 100644
> > index 000000000..783d481e9
> > --- /dev/null
> > +++ b/testcases/kernel/syscalls/futex/futex_waitv04.c
> > @@ -0,0 +1,83 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > +/*
> > + * Copyright (C) 2022 Zhao Gongyi <zhaogongyi@huawei.com>  */
> > +
> > +/*\
> > + * [Description]
> > + *
> > + * This test verifies EAGIN and ETIMEDOUT for futex_waitv syscall.
>                          ^
>                          EAGAIN
> 
> Is there a reason why can't we add these two testcases into
> futex_waitv01.c?
> 
> --
> Cyril Hrubis
> chrubis@suse.cz

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

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

* Re: [LTP] [PATCH] futex_waitv04: Add test for futex_waitv syscall
  2022-04-15  1:27 [LTP] [PATCH] futex_waitv04: Add test for futex_waitv syscall zhaogongyi via ltp
@ 2022-06-06 14:35 ` Cyril Hrubis
  0 siblings, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2022-06-06 14:35 UTC (permalink / raw)
  To: zhaogongyi; +Cc: ltp

Hi!
> I also wondered whether to add these two testcases into
> futex_waitv01.c, there is a consideration that there are alse two

Will you send a patch that adds these cases to the futext_waitv01.c
then?

> other testcases need to be added according to linux manual:
> 1. A signal was sent to the sleeping task, returning -ERESTARTSYS.
> 2. Some futex at the list was woken, returning the index of some waked futex.

Feel free to send more patches, adding more test coverage is always
welcomed.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH] futex_waitv04: Add test for futex_waitv syscall
@ 2022-06-07  2:58 zhaogongyi via ltp
  0 siblings, 0 replies; 5+ messages in thread
From: zhaogongyi via ltp @ 2022-06-07  2:58 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril,

I have resubmit the patch that move the test code to futex_waitv01.c as your suggestion, please see: https://patchwork.ozlabs.org/project/ltp/patch/20220607025435.184105-1-zhaogongyi@huawei.com/

Best wishes,
Gongyi

> 
> Hi!
> > I also wondered whether to add these two testcases into
> > futex_waitv01.c, there is a consideration that there are alse two
> 
> Will you send a patch that adds these cases to the futext_waitv01.c then?
> 
> > other testcases need to be added according to linux manual:
> > 1. A signal was sent to the sleeping task, returning -ERESTARTSYS.
> > 2. Some futex at the list was woken, returning the index of some waked
> futex.
> 
> Feel free to send more patches, adding more test coverage is always
> welcomed.
> 
> --
> Cyril Hrubis
> chrubis@suse.cz

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

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

* Re: [LTP] [PATCH] futex_waitv04: Add test for futex_waitv syscall
  2022-04-13 11:40 Zhao Gongyi via ltp
@ 2022-04-14 13:46 ` Cyril Hrubis
  0 siblings, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2022-04-14 13:46 UTC (permalink / raw)
  To: Zhao Gongyi; +Cc: ltp

Hi!
> diff --git a/testcases/kernel/syscalls/futex/futex_waitv04.c b/testcases/kernel/syscalls/futex/futex_waitv04.c
> new file mode 100644
> index 000000000..783d481e9
> --- /dev/null
> +++ b/testcases/kernel/syscalls/futex/futex_waitv04.c
> @@ -0,0 +1,83 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2022 Zhao Gongyi <zhaogongyi@huawei.com>
> + */
> +
> +/*\
> + * [Description]
> + *
> + * This test verifies EAGIN and ETIMEDOUT for futex_waitv syscall.
                         ^
                         EAGAIN

Is there a reason why can't we add these two testcases into
futex_waitv01.c?

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* [LTP] [PATCH] futex_waitv04: Add test for futex_waitv syscall
@ 2022-04-13 11:40 Zhao Gongyi via ltp
  2022-04-14 13:46 ` Cyril Hrubis
  0 siblings, 1 reply; 5+ messages in thread
From: Zhao Gongyi via ltp @ 2022-04-13 11:40 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>
---
 testcases/kernel/syscalls/futex/.gitignore    |  1 +
 .../kernel/syscalls/futex/futex_waitv04.c     | 83 +++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 testcases/kernel/syscalls/futex/futex_waitv04.c

diff --git a/testcases/kernel/syscalls/futex/.gitignore b/testcases/kernel/syscalls/futex/.gitignore
index 9d08ba7d3..13fd202f4 100644
--- a/testcases/kernel/syscalls/futex/.gitignore
+++ b/testcases/kernel/syscalls/futex/.gitignore
@@ -13,3 +13,4 @@
 /futex_waitv01
 /futex_waitv02
 /futex_waitv03
+/futex_waitv04
diff --git a/testcases/kernel/syscalls/futex/futex_waitv04.c b/testcases/kernel/syscalls/futex/futex_waitv04.c
new file mode 100644
index 000000000..783d481e9
--- /dev/null
+++ b/testcases/kernel/syscalls/futex/futex_waitv04.c
@@ -0,0 +1,83 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2022 Zhao Gongyi <zhaogongyi@huawei.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * This test verifies EAGIN and ETIMEDOUT for futex_waitv syscall.
+ */
+
+#include <time.h>
+#include "tst_test.h"
+#include "lapi/futex.h"
+#include "futex2test.h"
+#include "tst_safe_clocks.h"
+
+static uint32_t *futex;
+static struct futex_waitv *waitv;
+
+static void setup(void)
+{
+	futex = SAFE_MALLOC(sizeof(uint32_t));
+	*futex = FUTEX_INITIALIZER;
+}
+
+static void init_timeout(struct timespec *to)
+{
+	SAFE_CLOCK_GETTIME(CLOCK_MONOTONIC, to);
+	to->tv_sec++;
+}
+
+static void 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;
+
+	init_timeout(&to);
+
+	TST_EXP_FAIL(futex_waitv(waitv, 1, 0, &to, CLOCK_REALTIME), ETIMEDOUT,
+		     "futex_waitv timeout");
+}
+
+static void cleanup(void)
+{
+	if (futex != NULL)
+		free(futex);
+}
+
+static void run(void)
+{
+	mismatch_between_uaddr_and_val();
+	test_timeout();
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.min_kver = "5.16",
+	.bufs =
+		(struct tst_buffers[]){
+			{ &waitv, .size = sizeof(struct futex_waitv) },
+			{},
+		},
+};
--
2.17.1


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

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

end of thread, other threads:[~2022-06-07  2:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-15  1:27 [LTP] [PATCH] futex_waitv04: Add test for futex_waitv syscall zhaogongyi via ltp
2022-06-06 14:35 ` Cyril Hrubis
  -- strict thread matches above, loose matches on Subject: below --
2022-06-07  2:58 zhaogongyi via ltp
2022-04-13 11:40 Zhao Gongyi via ltp
2022-04-14 13:46 ` 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.