[PATCH] clone11: skip CLONE_NEWCGROUP on kernels < 4.6

Andrea Cervesato <[email protected]>
Newsgroups gmane.linux.ltp
Message-ID <[email protected]>
From: Andrea Cervesato <andrea.cervesato-IBi9RG/[email protected]>

CLONE_NEWCGROUP was added in kernel v4.6. On older kernels such as
v4.4, the flag is unknown and clone() returns EINVAL instead of the
expected EPERM, causing a spurious test failure.

Add a per-test-case minimum kernel version check so that the
CLONE_NEWCGROUP case reports TCONF on kernels older than 4.6.

Signed-off-by: Andrea Cervesato <andrea.cervesato-IBi9RG/[email protected]>
---
 testcases/kernel/syscalls/clone/clone11.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/clone/clone11.c b/testcases/kernel/syscalls/clone/clone11.c
index 028da778158de6867a71ac3974f9c2263481d3a3..607e42585fad41784be9104be01f504218559342 100644
--- a/testcases/kernel/syscalls/clone/clone11.c
+++ b/testcases/kernel/syscalls/clone/clone11.c
@@ -21,9 +21,10 @@ static int *child_pid;
 static struct tcase {
 	uint64_t flags;
 	const char *sflags;
+	int min_kver[3];
 } tcases[] = {
 	{ DESC(CLONE_NEWPID) },
-	{ DESC(CLONE_NEWCGROUP) },
+	{ DESC(CLONE_NEWCGROUP), .min_kver = {4, 6, 0} },
 	{ DESC(CLONE_NEWIPC) },
 	{ DESC(CLONE_NEWNET) },
 	{ DESC(CLONE_NEWNS) },
@@ -40,6 +41,13 @@ static void run(unsigned int n)
 {
 	struct tcase *tc = &tcases[n];
 
+	if (tc->min_kver[0] &&
+	    tst_kvercmp(tc->min_kver[0], tc->min_kver[1], tc->min_kver[2]) < 0) {
+		tst_res(TCONF, "clone(%s) needs kernel %d.%d+",
+			tc->sflags, tc->min_kver[0], tc->min_kver[1]);
+		return;
+	}
+
 	TST_EXP_FAIL(ltp_clone(tc->flags, child_fn, NULL, CHILD_STACK_SIZE, child_stack),
 		EPERM, "clone(%s) should fail with EPERM",
 		tc->sflags);

---
base-commit: a375e8deed471723f5a0114c56eb48fe6f6f45d3
change-id: 20260611-fix_clone11_min_kver-394cf499c2c7

Best regards,
-- 
Andrea Cervesato <andrea.cervesato-IBi9RG/[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.