Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] futex_waitv01: Add test verifies EINVAL for invalid nr_futexes
@ 2022-04-08  9:17 Zhao Gongyi via ltp
  2022-04-08 12:46 ` Andrea Cervesato via ltp
  2022-04-12 11:53 ` Richard Palethorpe
  0 siblings, 2 replies; 3+ messages in thread
From: Zhao Gongyi via ltp @ 2022-04-08  9:17 UTC (permalink / raw)
  To: ltp

Add test verifies EINVAL for invalid nr_futexes according to
https://www.kernel.org/doc/html/latest/userspace-api/futex2.html.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
v1->v2: Check also lower bound that suggested by Andrea Cervesato

 testcases/kernel/syscalls/futex/futex_waitv01.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/testcases/kernel/syscalls/futex/futex_waitv01.c b/testcases/kernel/syscalls/futex/futex_waitv01.c
index 601fee8df..721852750 100644
--- a/testcases/kernel/syscalls/futex/futex_waitv01.c
+++ b/testcases/kernel/syscalls/futex/futex_waitv01.c
@@ -98,6 +98,19 @@ static void test_invalid_clockid(void)
 		     "futex_waitv invalid clockid");
 }

+static void test_invalid_nr_futex(void)
+{
+	struct timespec to;
+	init_waitv();
+	init_timeout(&to);
+
+	/* Valid nr_futexes is [1, 128] */
+	TST_EXP_FAIL(futex_waitv(waitv, 129, 0, &to, CLOCK_REALTIME), EINVAL,
+		     "futex_waitv invalid nr_futexes");
+	TST_EXP_FAIL(futex_waitv(waitv, 0, 0, &to, CLOCK_REALTIME), EINVAL,
+		     "futex_waitv invalid nr_futexes");
+}
+
 static void run(void)
 {
 	test_invalid_flags();
@@ -105,6 +118,7 @@ static void run(void)
 	test_null_address();
 	test_null_waiters();
 	test_invalid_clockid();
+	test_invalid_nr_futex();
 }

 static struct tst_test test = {
--
2.17.1


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

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

* Re: [LTP] [PATCH v2] futex_waitv01: Add test verifies EINVAL for invalid nr_futexes
  2022-04-08  9:17 [LTP] [PATCH v2] futex_waitv01: Add test verifies EINVAL for invalid nr_futexes Zhao Gongyi via ltp
@ 2022-04-08 12:46 ` Andrea Cervesato via ltp
  2022-04-12 11:53 ` Richard Palethorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Andrea Cervesato via ltp @ 2022-04-08 12:46 UTC (permalink / raw)
  To: Zhao Gongyi, ltp


[-- Attachment #1.1: Type: text/plain, Size: 1546 bytes --]

Hi!

It looks good, +1

Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.de>


On 4/8/22 11:17, Zhao Gongyi via ltp wrote:
> Add test verifies EINVAL for invalid nr_futexes according to
> https://www.kernel.org/doc/html/latest/userspace-api/futex2.html.
>
> Signed-off-by: Zhao Gongyi<zhaogongyi@huawei.com>
> ---
> v1->v2: Check also lower bound that suggested by Andrea Cervesato
>
>   testcases/kernel/syscalls/futex/futex_waitv01.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
>
> diff --git a/testcases/kernel/syscalls/futex/futex_waitv01.c b/testcases/kernel/syscalls/futex/futex_waitv01.c
> index 601fee8df..721852750 100644
> --- a/testcases/kernel/syscalls/futex/futex_waitv01.c
> +++ b/testcases/kernel/syscalls/futex/futex_waitv01.c
> @@ -98,6 +98,19 @@ static void test_invalid_clockid(void)
>   		     "futex_waitv invalid clockid");
>   }
>
> +static void test_invalid_nr_futex(void)
> +{
> +	struct timespec to;
> +	init_waitv();
> +	init_timeout(&to);
> +
> +	/* Valid nr_futexes is [1, 128] */
> +	TST_EXP_FAIL(futex_waitv(waitv, 129, 0, &to, CLOCK_REALTIME), EINVAL,
> +		     "futex_waitv invalid nr_futexes");
> +	TST_EXP_FAIL(futex_waitv(waitv, 0, 0, &to, CLOCK_REALTIME), EINVAL,
> +		     "futex_waitv invalid nr_futexes");
> +}
> +
>   static void run(void)
>   {
>   	test_invalid_flags();
> @@ -105,6 +118,7 @@ static void run(void)
>   	test_null_address();
>   	test_null_waiters();
>   	test_invalid_clockid();
> +	test_invalid_nr_futex();
>   }
>
>   static struct tst_test test = {
> --
> 2.17.1
>
>

[-- Attachment #1.2: Type: text/html, Size: 2252 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


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

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

* Re: [LTP] [PATCH v2] futex_waitv01: Add test verifies EINVAL for invalid nr_futexes
  2022-04-08  9:17 [LTP] [PATCH v2] futex_waitv01: Add test verifies EINVAL for invalid nr_futexes Zhao Gongyi via ltp
  2022-04-08 12:46 ` Andrea Cervesato via ltp
@ 2022-04-12 11:53 ` Richard Palethorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Palethorpe @ 2022-04-12 11:53 UTC (permalink / raw)
  To: Zhao Gongyi; +Cc: ltp

Hello Zhao,

Zhao Gongyi via ltp <ltp@lists.linux.it> writes:

> Add test verifies EINVAL for invalid nr_futexes according to
> https://www.kernel.org/doc/html/latest/userspace-api/futex2.html.
>
> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> ---
> v1->v2: Check also lower bound that suggested by Andrea Cervesato
>
>  testcases/kernel/syscalls/futex/futex_waitv01.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/testcases/kernel/syscalls/futex/futex_waitv01.c b/testcases/kernel/syscalls/futex/futex_waitv01.c
> index 601fee8df..721852750 100644
> --- a/testcases/kernel/syscalls/futex/futex_waitv01.c
> +++ b/testcases/kernel/syscalls/futex/futex_waitv01.c
> @@ -98,6 +98,19 @@ static void test_invalid_clockid(void)
>  		     "futex_waitv invalid clockid");
>  }
>
> +static void test_invalid_nr_futex(void)
> +{
> +	struct timespec to;

Space required here (run `make check-<test_name>`).

Pushed with correction, thanks!

-- 
Thank you,
Richard.

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

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

end of thread, other threads:[~2022-04-12 11:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-08  9:17 [LTP] [PATCH v2] futex_waitv01: Add test verifies EINVAL for invalid nr_futexes Zhao Gongyi via ltp
2022-04-08 12:46 ` Andrea Cervesato via ltp
2022-04-12 11:53 ` Richard Palethorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox