Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH] unshare01: add EINVAL check
@ 2025-03-12  9:28 lufei
  2025-03-13  9:35 ` Petr Vorel
  0 siblings, 1 reply; 2+ messages in thread
From: lufei @ 2025-03-12  9:28 UTC (permalink / raw)
  To: ltp; +Cc: lufei

---
 testcases/kernel/syscalls/unshare/unshare01.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/syscalls/unshare/unshare01.c b/testcases/kernel/syscalls/unshare/unshare01.c
index 6e6315b11..ce1ed2e14 100644
--- a/testcases/kernel/syscalls/unshare/unshare01.c
+++ b/testcases/kernel/syscalls/unshare/unshare01.c
@@ -28,21 +28,30 @@
 #include "config.h"
 
 #ifdef HAVE_UNSHARE
+#define INV_FLAG 0x0123
+
 
 static struct test_case_t {
 	int mode;
 	const char *desc;
+	const int eno;
 } tc[] = {
-	{CLONE_FILES,	"CLONE_FILES"},
-	{CLONE_FS,	"CLONE_FS"},
-	{CLONE_NEWNS,	"CLONE_NEWNS"},
+	{CLONE_FILES,	"CLONE_FILES",	0},
+	{CLONE_FS,	"CLONE_FS",	0},
+	{CLONE_NEWNS,	"CLONE_NEWNS",	0},
+	{INV_FLAG,	"INV_FLAG",	EINVAL},
 };
 
 static void run(unsigned int i)
 {
 	pid_t pid = SAFE_FORK();
-	if (pid == 0)
-		TST_EXP_PASS(unshare(tc[i].mode), "unshare(%s)", tc[i].desc);
+
+	if (pid == 0) {
+		if (tc[i].eno)
+			TST_EXP_FAIL(unshare(tc[i].mode), tc[i].eno, "unshare(%s)", tc[i].desc);
+		else
+			TST_EXP_PASS(unshare(tc[i].mode), "unshare(%s)", tc[i].desc);
+	}
 }
 
 static struct tst_test test = {
-- 
2.39.3


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

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

end of thread, other threads:[~2025-03-13  9:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-12  9:28 [LTP] [PATCH] unshare01: add EINVAL check lufei
2025-03-13  9:35 ` Petr Vorel

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