[LTP] [PATCH v2] Remove ltp_quick_clone from mountns testing suite
Andrea Cervesato
andrea.cervesato@suse.de
Tue Mar 7 13:50:10 CET 2023
From: Andrea Cervesato <andrea.cervesato@suse.com>
ltp_quick_clone has been replaced by SAFE_CLONE in the mountns testing
suite that now is independed from libclone and legacy API.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Check for CONFIG_USER_NS
testcases/kernel/containers/mountns/mountns.h | 18 -----------------
.../kernel/containers/mountns/mountns01.c | 20 +++++++++++--------
.../kernel/containers/mountns/mountns02.c | 20 +++++++++++--------
.../kernel/containers/mountns/mountns03.c | 20 +++++++++++--------
.../kernel/containers/mountns/mountns04.c | 6 +++++-
5 files changed, 41 insertions(+), 43 deletions(-)
diff --git a/testcases/kernel/containers/mountns/mountns.h b/testcases/kernel/containers/mountns/mountns.h
index 615f1a058..9bb854659 100644
--- a/testcases/kernel/containers/mountns/mountns.h
+++ b/testcases/kernel/containers/mountns/mountns.h
@@ -8,28 +8,10 @@
#define COMMON_H
#include "tst_test.h"
-#include "lapi/sched.h"
#define DIRA "LTP_DIR_A"
#define DIRB "LTP_DIR_B"
-static int dummy_child(void *v)
-{
- (void)v;
- return 0;
-}
-
-static void check_newns(void)
-{
- int pid, status;
-
- pid = ltp_clone_quick(CLONE_NEWNS | SIGCHLD, dummy_child, NULL);
- if (pid < 0)
- tst_brk(TCONF, "CLONE_NEWNS not supported");
-
- SAFE_WAIT(&status);
-}
-
static void umount_folders(void)
{
if (tst_is_mounted(DIRA))
diff --git a/testcases/kernel/containers/mountns/mountns01.c b/testcases/kernel/containers/mountns/mountns01.c
index e8f176920..41c2956ea 100644
--- a/testcases/kernel/containers/mountns/mountns01.c
+++ b/testcases/kernel/containers/mountns/mountns01.c
@@ -33,8 +33,9 @@
#include <sys/mount.h>
#include "mountns.h"
#include "tst_test.h"
+#include "lapi/sched.h"
-static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
+static void child_func(void)
{
TST_CHECKPOINT_WAIT(0);
@@ -51,13 +52,11 @@ static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
TST_CHECKPOINT_WAKE_AND_WAIT(0);
SAFE_UMOUNT(DIRA);
-
- return 0;
}
static void run(void)
{
- int ret;
+ const struct tst_clone_args args = { CLONE_NEWNS, SIGCHLD };
SAFE_UNSHARE(CLONE_NEWNS);
@@ -67,9 +66,10 @@ static void run(void)
SAFE_MOUNT(DIRA, DIRA, "none", MS_BIND, NULL);
SAFE_MOUNT("none", DIRA, "none", MS_SHARED, NULL);
- ret = ltp_clone_quick(CLONE_NEWNS | SIGCHLD, child_func, NULL);
- if (ret < 0)
- tst_brk(TBROK, "clone failed");
+ if (!SAFE_CLONE(&args)) {
+ child_func();
+ return;
+ }
SAFE_MOUNT(DIRB, DIRA, "none", MS_BIND, NULL);
@@ -93,7 +93,6 @@ static void run(void)
static void setup(void)
{
- check_newns();
create_folders();
}
@@ -107,5 +106,10 @@ static struct tst_test test = {
.cleanup = cleanup,
.test_all = run,
.needs_root = 1,
+ .forks_child = 1,
.needs_checkpoints = 1,
+ .needs_kconfigs = (const char *[]) {
+ "CONFIG_USER_NS",
+ NULL,
+ },
};
diff --git a/testcases/kernel/containers/mountns/mountns02.c b/testcases/kernel/containers/mountns/mountns02.c
index 4b85fa79b..7ca01a438 100644
--- a/testcases/kernel/containers/mountns/mountns02.c
+++ b/testcases/kernel/containers/mountns/mountns02.c
@@ -34,8 +34,9 @@
#include <sys/mount.h>
#include "mountns.h"
#include "tst_test.h"
+#include "lapi/sched.h"
-static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
+static void child_func(void)
{
TST_CHECKPOINT_WAIT(0);
@@ -51,13 +52,11 @@ static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
TST_CHECKPOINT_WAKE_AND_WAIT(0);
SAFE_UMOUNT(DIRA);
-
- return 0;
}
static void run(void)
{
- int ret;
+ const struct tst_clone_args args = { CLONE_NEWNS, SIGCHLD };
SAFE_UNSHARE(CLONE_NEWNS);
@@ -68,9 +67,10 @@ static void run(void)
SAFE_MOUNT("none", DIRA, "none", MS_PRIVATE, NULL);
- ret = ltp_clone_quick(CLONE_NEWNS | SIGCHLD, child_func, NULL);
- if (ret < 0)
- tst_brk(TBROK, "clone failed");
+ if (!SAFE_CLONE(&args)) {
+ child_func();
+ return;
+ }
SAFE_MOUNT(DIRB, DIRA, "none", MS_BIND, NULL);
@@ -94,7 +94,6 @@ static void run(void)
static void setup(void)
{
- check_newns();
create_folders();
}
@@ -108,5 +107,10 @@ static struct tst_test test = {
.cleanup = cleanup,
.test_all = run,
.needs_root = 1,
+ .forks_child = 1,
.needs_checkpoints = 1,
+ .needs_kconfigs = (const char *[]) {
+ "CONFIG_USER_NS",
+ NULL,
+ },
};
diff --git a/testcases/kernel/containers/mountns/mountns03.c b/testcases/kernel/containers/mountns/mountns03.c
index 1d26a25d8..3b4936b06 100644
--- a/testcases/kernel/containers/mountns/mountns03.c
+++ b/testcases/kernel/containers/mountns/mountns03.c
@@ -36,8 +36,9 @@
#include <sys/mount.h>
#include "mountns.h"
#include "tst_test.h"
+#include "lapi/sched.h"
-static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
+static void child_func(void)
{
/*
* makes mount DIRA a slave of DIRA (all slave mounts have
@@ -59,13 +60,11 @@ static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
TST_CHECKPOINT_WAKE_AND_WAIT(0);
SAFE_UMOUNT(DIRA);
-
- return 0;
}
static void run(void)
{
- int ret;
+ const struct tst_clone_args args = { CLONE_NEWNS, SIGCHLD };
SAFE_UNSHARE(CLONE_NEWNS);
@@ -76,9 +75,10 @@ static void run(void)
SAFE_MOUNT("none", DIRA, "none", MS_SHARED, NULL);
- ret = ltp_clone_quick(CLONE_NEWNS | SIGCHLD, child_func, NULL);
- if (ret < 0)
- tst_brk(TBROK, "clone failed");
+ if (!SAFE_CLONE(&args)) {
+ child_func();
+ return;
+ }
TST_CHECKPOINT_WAIT(0);
@@ -104,7 +104,6 @@ static void run(void)
static void setup(void)
{
- check_newns();
create_folders();
}
@@ -118,5 +117,10 @@ static struct tst_test test = {
.cleanup = cleanup,
.test_all = run,
.needs_root = 1,
+ .forks_child = 1,
.needs_checkpoints = 1,
+ .needs_kconfigs = (const char *[]) {
+ "CONFIG_USER_NS",
+ NULL,
+ },
};
diff --git a/testcases/kernel/containers/mountns/mountns04.c b/testcases/kernel/containers/mountns/mountns04.c
index fc392f1a7..7b4dcb16d 100644
--- a/testcases/kernel/containers/mountns/mountns04.c
+++ b/testcases/kernel/containers/mountns/mountns04.c
@@ -22,6 +22,7 @@
#include <sys/mount.h>
#include "mountns.h"
#include "tst_test.h"
+#include "lapi/sched.h"
static void run(void)
{
@@ -46,7 +47,6 @@ static void run(void)
static void setup(void)
{
- check_newns();
create_folders();
}
@@ -61,4 +61,8 @@ static struct tst_test test = {
.test_all = run,
.needs_root = 1,
.needs_tmpdir = 1,
+ .needs_kconfigs = (const char *[]) {
+ "CONFIG_USER_NS",
+ NULL,
+ },
};
--
2.35.3
More information about the ltp
mailing list