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

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.