[LTP] [PATCH] kcmp03: Add check for KCMP_SYSVSEM before running test
Dorinda Bassey
dbassey@redhat.com
Mon Feb 17 13:52:33 CET 2025
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
>
>
More information about the ltp
mailing list