All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] kcmp03: Add check for KCMP_SYSVSEM before running test
@ 2025-02-14 15:31 Dorinda Bassey
  2025-02-17 10:12 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Dorinda Bassey @ 2025-02-14 15:31 UTC (permalink / raw)
  To: ltp; +Cc: sbertram, javierm

This commit introduces a new function
`is_kcmp_supported()` to check if the kernel supports the
`KCMP_SYSVSEM` operation. In the `verify_kcmp()` function,
we add logic to detect when the kernel does not support
`KCMP_SYSVSEM` and skip the test for that case with a TCONF
result. This ensures that the test does not fail when the
Kconfig that supports `KCMP_SYSVSEM` is unavailable.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
---
 testcases/kernel/syscalls/kcmp/kcmp03.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/testcases/kernel/syscalls/kcmp/kcmp03.c b/testcases/kernel/syscalls/kcmp/kcmp03.c
index 37d5118d5..255171d98 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp03.c
+++ b/testcases/kernel/syscalls/kcmp/kcmp03.c
@@ -52,6 +52,12 @@ static void cleanup(void)
 	free(stack);
 }
 
+static int is_kcmp_supported(void)
+{
+	int result = syscall(__NR_kcmp, getpid(), getpid(), KCMP_SYSVSEM, 0, 0);
+	return result == 0 || errno != EOPNOTSUPP;
+}
+
 static int do_child(void *arg)
 {
 	pid2 = getpid();
@@ -64,6 +70,13 @@ static void verify_kcmp(unsigned int n)
 	int res;
 	struct tcase *tc = &tcases[n];
 
+    // Handle the case for KCMP_SYSVSEM specifically
+    if (tc->kcmp_type == KCMP_SYSVSEM) {
+        if (!is_kcmp_supported()) {
+            tst_brk(TCONF, "Kernel does not support KCMP_SYSVSEM, skipping test.");
+	    }
+	}
+
 	pid1 = getpid();
 	tst_res(TINFO, "Testing %s", tc->desc);
 
-- 
2.48.1


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

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

* Re: [LTP] [PATCH] kcmp03: Add check for KCMP_SYSVSEM before running test
  2025-02-14 15:31 [LTP] [PATCH] kcmp03: Add check for KCMP_SYSVSEM before running test Dorinda Bassey
@ 2025-02-17 10:12 ` Cyril Hrubis
  2025-02-17 12:52   ` Dorinda Bassey
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2025-02-17 10:12 UTC (permalink / raw)
  To: Dorinda Bassey; +Cc: sbertram, javierm, ltp

Hi!
> This commit introduces a new function
> `is_kcmp_supported()` to check if the kernel supports the
> `KCMP_SYSVSEM` operation. In the `verify_kcmp()` function,
> we add logic to detect when the kernel does not support
> `KCMP_SYSVSEM` and skip the test for that case with a TCONF
> result. This ensures that the test does not fail when the
> Kconfig that supports `KCMP_SYSVSEM` is unavailable.

First of all the coding style is inconsistent, have you run 'make check'
in the test directory and fixed all the problems?

> Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
> ---
>  testcases/kernel/syscalls/kcmp/kcmp03.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/testcases/kernel/syscalls/kcmp/kcmp03.c b/testcases/kernel/syscalls/kcmp/kcmp03.c
> index 37d5118d5..255171d98 100644
> --- a/testcases/kernel/syscalls/kcmp/kcmp03.c
> +++ b/testcases/kernel/syscalls/kcmp/kcmp03.c
> @@ -52,6 +52,12 @@ static void cleanup(void)
>  	free(stack);
>  }
>  
> +static int is_kcmp_supported(void)
> +{
> +	int result = syscall(__NR_kcmp, getpid(), getpid(), KCMP_SYSVSEM, 0, 0);

Why syscall() instead of kcmp() that is used in the rest of the test?

> +	return result == 0 || errno != EOPNOTSUPP;
> +}
> +
>  static int do_child(void *arg)
>  {
>  	pid2 = getpid();
> @@ -64,6 +70,13 @@ static void verify_kcmp(unsigned int n)
>  	int res;
>  	struct tcase *tc = &tcases[n];
>  
> +    // Handle the case for KCMP_SYSVSEM specifically
> +    if (tc->kcmp_type == KCMP_SYSVSEM) {
> +        if (!is_kcmp_supported()) {

This function should be called once from the test setup and the results
should be cached.

> +            tst_brk(TCONF, "Kernel does not support KCMP_SYSVSEM, skipping test.");

This should be just tst_res(TCONF, "..."); followed by return 0;

We do not want to abort subseqent test iterations (e.g. -i 2 on command
line) just because one operation is not supported.

> +	    }
> +	}


>  	pid1 = getpid();
>  	tst_res(TINFO, "Testing %s", tc->desc);
>  
> -- 
> 2.48.1
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH] kcmp03: Add check for KCMP_SYSVSEM before running test
  2025-02-17 10:12 ` Cyril Hrubis
@ 2025-02-17 12:52   ` Dorinda Bassey
  0 siblings, 0 replies; 3+ messages in thread
From: Dorinda Bassey @ 2025-02-17 12:52 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: sbertram, javierm, ltp

Hi Cyril,

Thank you for the feedback, I just sent a v2 of the patch.

BR,
Dorinda Bassey.

On Mon, Feb 17, 2025 at 11:12 AM Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> > This commit introduces a new function
> > `is_kcmp_supported()` to check if the kernel supports the
> > `KCMP_SYSVSEM` operation. In the `verify_kcmp()` function,
> > we add logic to detect when the kernel does not support
> > `KCMP_SYSVSEM` and skip the test for that case with a TCONF
> > result. This ensures that the test does not fail when the
> > Kconfig that supports `KCMP_SYSVSEM` is unavailable.
>
> First of all the coding style is inconsistent, have you run 'make check'
> in the test directory and fixed all the problems?
>
> > Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
> > ---
> >  testcases/kernel/syscalls/kcmp/kcmp03.c | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> >
> > diff --git a/testcases/kernel/syscalls/kcmp/kcmp03.c
> b/testcases/kernel/syscalls/kcmp/kcmp03.c
> > index 37d5118d5..255171d98 100644
> > --- a/testcases/kernel/syscalls/kcmp/kcmp03.c
> > +++ b/testcases/kernel/syscalls/kcmp/kcmp03.c
> > @@ -52,6 +52,12 @@ static void cleanup(void)
> >       free(stack);
> >  }
> >
> > +static int is_kcmp_supported(void)
> > +{
> > +     int result = syscall(__NR_kcmp, getpid(), getpid(), KCMP_SYSVSEM,
> 0, 0);
>
> Why syscall() instead of kcmp() that is used in the rest of the test?
>
> > +     return result == 0 || errno != EOPNOTSUPP;
> > +}
> > +
> >  static int do_child(void *arg)
> >  {
> >       pid2 = getpid();
> > @@ -64,6 +70,13 @@ static void verify_kcmp(unsigned int n)
> >       int res;
> >       struct tcase *tc = &tcases[n];
> >
> > +    // Handle the case for KCMP_SYSVSEM specifically
> > +    if (tc->kcmp_type == KCMP_SYSVSEM) {
> > +        if (!is_kcmp_supported()) {
>
> This function should be called once from the test setup and the results
> should be cached.
>
> > +            tst_brk(TCONF, "Kernel does not support KCMP_SYSVSEM,
> skipping test.");
>
> This should be just tst_res(TCONF, "..."); followed by return 0;
>
> We do not want to abort subseqent test iterations (e.g. -i 2 on command
> line) just because one operation is not supported.
>
> > +         }
> > +     }
>
>
> >       pid1 = getpid();
> >       tst_res(TINFO, "Testing %s", tc->desc);
> >
> > --
> > 2.48.1
> >
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
>

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

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

end of thread, other threads:[~2025-02-17 12:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-14 15:31 [LTP] [PATCH] kcmp03: Add check for KCMP_SYSVSEM before running test Dorinda Bassey
2025-02-17 10:12 ` Cyril Hrubis
2025-02-17 12:52   ` Dorinda Bassey

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.