All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v3 0/6] Rewrite mountns testing suite
@ 2022-03-01  9:15 Andrea Cervesato
  2022-03-01  9:15 ` [LTP] [PATCH v3 1/6] Rewrite mountns01 test using new LTP API Andrea Cervesato
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Andrea Cervesato @ 2022-03-01  9:15 UTC (permalink / raw)
  To: ltp

mountns testing suite has been rewritten using new LTP API and libclone
has been removed from dependences.

Andrea Cervesato (6):
  Rewrite mountns01 test using new LTP API
  Rewrite mountns02 test using new LTP API
  Rewrite mountns03 test using new LTP API
  Rewrite mountns04 test using new LTP API
  Removed obsolete mountns_helper.h
  Removed libclone usage from mountns testing suite

 testcases/kernel/containers/mountns/Makefile  |  21 +-
 testcases/kernel/containers/mountns/mountns.h |  50 +++++
 .../kernel/containers/mountns/mountns01.c     | 185 +++++++---------
 .../kernel/containers/mountns/mountns02.c     | 186 +++++++---------
 .../kernel/containers/mountns/mountns03.c     | 206 +++++++-----------
 .../kernel/containers/mountns/mountns04.c     | 109 ++++-----
 .../containers/mountns/mountns_helper.h       |  61 ------
 7 files changed, 334 insertions(+), 484 deletions(-)
 create mode 100644 testcases/kernel/containers/mountns/mountns.h
 delete mode 100644 testcases/kernel/containers/mountns/mountns_helper.h

-- 
2.35.1


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

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

* [LTP] [PATCH v3 1/6] Rewrite mountns01 test using new LTP API
  2022-03-01  9:15 [LTP] [PATCH v3 0/6] Rewrite mountns testing suite Andrea Cervesato
@ 2022-03-01  9:15 ` Andrea Cervesato
  2022-03-01 14:35   ` Cyril Hrubis
  2022-03-01  9:15 ` [LTP] [PATCH v3 2/6] Rewrite mountns02 " Andrea Cervesato
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Andrea Cervesato @ 2022-03-01  9:15 UTC (permalink / raw)
  To: ltp

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
---
 testcases/kernel/containers/mountns/mountns.h |  50 +++++
 .../kernel/containers/mountns/mountns01.c     | 185 +++++++-----------
 2 files changed, 125 insertions(+), 110 deletions(-)
 create mode 100644 testcases/kernel/containers/mountns/mountns.h

diff --git a/testcases/kernel/containers/mountns/mountns.h b/testcases/kernel/containers/mountns/mountns.h
new file mode 100644
index 000000000..ad8befa71
--- /dev/null
+++ b/testcases/kernel/containers/mountns/mountns.h
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+#ifndef COMMON_H
+#define COMMON_H
+
+#include "tst_test.h"
+#include "lapi/namespaces_constants.h"
+
+#define DIRA "A"
+#define DIRB "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))
+		SAFE_UMOUNT(DIRA);
+
+	if (tst_is_mounted(DIRB))
+		SAFE_UMOUNT(DIRB);
+}
+
+static void create_folders(void)
+{
+	SAFE_MKDIR(DIRA, 0777);
+	SAFE_MKDIR(DIRB, 0777);
+	SAFE_TOUCH(DIRA "/A", 0, NULL);
+	SAFE_TOUCH(DIRB "/B", 0, NULL);
+}
+
+#endif
diff --git a/testcases/kernel/containers/mountns/mountns01.c b/testcases/kernel/containers/mountns/mountns01.c
index 0bd0c592c..f2d67d17a 100644
--- a/testcases/kernel/containers/mountns/mountns01.c
+++ b/testcases/kernel/containers/mountns/mountns01.c
@@ -1,149 +1,114 @@
-/* Copyright (c) 2014 Red Hat, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of version 2 the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- ***********************************************************************
- * File: mountns01.c
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * [Description]
  *
  * Tests a shared mount: shared mount can be replicated to as many
  * mountpoints and all the replicas continue to be exactly same.
- * Description:
- * 1. Creates directories "A", "B" and files "A/A", "B/B"
- * 2. Unshares mount namespace and makes it private (so mounts/umounts
- *    have no effect on a real system)
- * 3. Bind mounts directory "A" to "A"
- * 4. Makes directory "A" shared
- * 5. Clones a new child process with CLONE_NEWNS flag
- * 6. There are two test cases (where X is parent namespace and Y child
- *    namespace):
- *    1)
- *	X: bind mounts "B" to "A"
- *	Y: must see "A/B"
- *	X: umounts "A"
- *    2)
- *	Y: bind mounts "B" to "A"
- *	X: must see "A/B"
- *	Y: umounts "A"
- ***********************************************************************/
-
-#define _GNU_SOURCE
+ *
+ * [Algorithm]
+ *
+ * . Creates directories "A", "B" and files "A/A", "B/B"
+ * . Unshares mount namespace and makes it private (so mounts/umounts have no
+ *   effect on a real system)
+ * . Bind mounts directory "A" to "A"
+ * . Makes directory "A" shared
+ * . Clones a new child process with CLONE_NEWNS flag
+ * . There are two test cases (where X is parent namespace and Y child namespace):
+ * .. First test case
+ * ... X: bind mounts "B" to "A"
+ * ... Y: must see "A/B"
+ * ... X: umounts "A"
+ * .. Second test case
+ * ... Y: bind mounts "B" to "A"
+ * ... X: must see "A/B"
+ * ... Y: umounts "A"
+ */
+
 #include <sys/wait.h>
 #include <sys/mount.h>
-#include <stdio.h>
-#include <errno.h>
-#include "mountns_helper.h"
-#include "test.h"
-#include "safe_macros.h"
-
-char *TCID	= "mountns01";
-int TST_TOTAL	= 2;
+#include "mountns.h"
+#include "tst_test.h"
 
-#if defined(MS_SHARED) && defined(MS_PRIVATE) && defined(MS_REC)
-
-int child_func(void *arg LTP_ATTRIBUTE_UNUSED)
+static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
 {
-	int ret = 0;
+	TST_CHECKPOINT_WAIT(0);
 
-	TST_SAFE_CHECKPOINT_WAIT(NULL, 0);
+	if (access(DIRA "/B", F_OK) == 0)
+		tst_res(TPASS, "shared mount in parent passed");
+	else
+		tst_res(TFAIL, "shared mount in parent failed");
 
-	if (access(DIRA"/B", F_OK) == -1)
-		ret = 2;
+	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
-	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(NULL, 0);
+	/* bind mounts DIRB to DIRA making contents of DIRB visible in DIRA */
+	SAFE_MOUNT(DIRB, DIRA, "none", MS_BIND, NULL);
 
-	/* bind mounts DIRB to DIRA making contents of DIRB visible
-	 * in DIRA */
-	if (mount(DIRB, DIRA, "none", MS_BIND, NULL) == -1) {
-		perror("mount");
-		return 1;
-	}
+	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
-	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(NULL, 0);
+	SAFE_UMOUNT(DIRA);
 
-	umount(DIRA);
-	return ret;
+	return 0;
 }
 
-static void test(void)
+static void run(void)
 {
-	int status;
+	int ret;
 
 	/* unshares the mount ns */
-	if (unshare(CLONE_NEWNS) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "unshare failed");
+	SAFE_UNSHARE(CLONE_NEWNS);
+
 	/* makes sure parent mounts/umounts have no effect on a real system */
-	SAFE_MOUNT(cleanup, "none", "/", "none", MS_REC|MS_PRIVATE, NULL);
+	SAFE_MOUNT("none", "/", "none", MS_REC | MS_PRIVATE, NULL);
 
 	/* bind mounts DIRA to itself */
-	SAFE_MOUNT(cleanup, DIRA, DIRA, "none", MS_BIND, NULL);
+	SAFE_MOUNT(DIRA, DIRA, "none", MS_BIND, NULL);
 
 	/* makes mount DIRA shared */
-	SAFE_MOUNT(cleanup, "none", DIRA, "none", MS_SHARED, NULL);
+	SAFE_MOUNT("none", DIRA, "none", MS_SHARED, NULL);
 
-	if (do_clone_tests(CLONE_NEWNS, child_func, NULL, NULL, NULL) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "clone failed");
+	ret = ltp_clone_quick(CLONE_NEWNS | SIGCHLD, child_func, NULL);
+	if (ret < 0)
+		tst_brk(TBROK, "clone failed");
 
-	/* bind mounts DIRB to DIRA making contents of DIRB visible
-	 * in DIRA */
-	SAFE_MOUNT(cleanup, DIRB, DIRA, "none", MS_BIND, NULL);
+	/* bind mounts DIRB to DIRA making contents of DIRB visible in DIRA */
+	SAFE_MOUNT(DIRB, DIRA, "none", MS_BIND, NULL);
 
-	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(cleanup, 0);
+	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
-	SAFE_UMOUNT(cleanup, DIRA);
+	SAFE_UMOUNT(DIRA);
 
-	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(cleanup, 0);
+	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
-	if (access(DIRA"/B", F_OK) == 0)
-		tst_resm(TPASS, "shared mount in child passed");
+	if (access(DIRA "/B", F_OK) == 0)
+		tst_res(TPASS, "shared mount in child passed");
 	else
-		tst_resm(TFAIL, "shared mount in child failed");
-
-	TST_SAFE_CHECKPOINT_WAKE(cleanup, 0);
+		tst_res(TFAIL, "shared mount in child failed");
 
+	TST_CHECKPOINT_WAKE(0);
 
-	SAFE_WAIT(cleanup, &status);
-	if (WIFEXITED(status)) {
-		if ((WEXITSTATUS(status) == 0))
-			tst_resm(TPASS, "shared mount in parent passed");
-		else
-			tst_resm(TFAIL, "shared mount in parent failed");
-	}
-	if (WIFSIGNALED(status)) {
-		tst_resm(TBROK, "child was killed with signal %s",
-			 tst_strsig(WTERMSIG(status)));
-		return;
-	}
-
-	SAFE_UMOUNT(cleanup, DIRA);
+	SAFE_UMOUNT(DIRA);
 }
 
-int main(int argc, char *argv[])
+static void setup(void)
 {
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++)
-		test();
-
-	cleanup();
-	tst_exit();
+	check_newns();
+	create_folders();
 }
 
-#else
-int main(void)
+static void cleanup(void)
 {
-	tst_brkm(TCONF, NULL, "needed mountflags are not defined");
+	umount_folders();
 }
-#endif
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = run,
+	.needs_root = 1,
+	.needs_checkpoints = 1,
+};
-- 
2.35.1


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

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

* [LTP] [PATCH v3 2/6] Rewrite mountns02 test using new LTP API
  2022-03-01  9:15 [LTP] [PATCH v3 0/6] Rewrite mountns testing suite Andrea Cervesato
  2022-03-01  9:15 ` [LTP] [PATCH v3 1/6] Rewrite mountns01 test using new LTP API Andrea Cervesato
@ 2022-03-01  9:15 ` Andrea Cervesato
  2022-03-01  9:15 ` [LTP] [PATCH v3 3/6] Rewrite mountns03 " Andrea Cervesato
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Andrea Cervesato @ 2022-03-01  9:15 UTC (permalink / raw)
  To: ltp

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
---
 .../kernel/containers/mountns/mountns02.c     | 186 +++++++-----------
 1 file changed, 76 insertions(+), 110 deletions(-)

diff --git a/testcases/kernel/containers/mountns/mountns02.c b/testcases/kernel/containers/mountns/mountns02.c
index 0e0e03e4d..c51999e35 100644
--- a/testcases/kernel/containers/mountns/mountns02.c
+++ b/testcases/kernel/containers/mountns/mountns02.c
@@ -1,149 +1,115 @@
-/* Copyright (c) 2014 Red Hat, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of version 2 the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- ***********************************************************************
- * File: mountns02.c
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * [Description]
  *
  * Tests a private mount: private mount does not forward or receive
  * propagation.
- * Description:
- * 1. Creates directories "A", "B" and files "A/A", "B/B"
- * 2. Unshares mount namespace and makes it private (so mounts/umounts
- *    have no effect on a real system)
- * 3. Bind mounts directory "A" to "A"
- * 4. Makes directory "A" private
- * 5. Clones a new child process with CLONE_NEWNS flag
- * 6. There are two test cases (where X is parent namespace and Y child
- *    namespace):
- *    1)
- *	X: bind mounts "B" to "A"
- *	Y: must see "A/A" and must not see "A/B"
- *	X: umounts "A"
- *    2)
- *	Y: bind mounts "B" to "A"
- *	X: must see "A/A" and must not see "A/B"
- *	Y: umounts A
- ***********************************************************************/
-
-#define _GNU_SOURCE
+ *
+ * [Algorithm]
+ *
+ * . Creates directories "A", "B" and files "A/A", "B/B"
+ * . Unshares mount namespace and makes it private (so mounts/umounts have no
+ *   effect on a real system)
+ * . Bind mounts directory "A" to "A"
+ * . Makes directory "A" private
+ * . Clones a new child process with CLONE_NEWNS flag
+ * . There are two test cases (where X is parent namespace and Y child
+ *   namespace):
+ * .. First test case
+ * ... X: bind mounts "B" to "A"
+ * ... Y: must see "A/A" and must not see "A/B"
+ * ... X: umounts "A"
+ * .. Second test case
+ * ... Y: bind mounts "B" to "A"
+ * ... X: must see "A/A" and must not see "A/B"
+ * ... Y: umounts A
+ */
+
 #include <sys/wait.h>
 #include <sys/mount.h>
-#include <stdio.h>
-#include <errno.h>
-#include "mountns_helper.h"
-#include "test.h"
-#include "safe_macros.h"
-
-char *TCID	= "mountns02";
-int TST_TOTAL	= 2;
+#include "mountns.h"
+#include "tst_test.h"
 
-#if defined(MS_SHARED) && defined(MS_PRIVATE) && defined(MS_REC)
-
-int child_func(void *arg LTP_ATTRIBUTE_UNUSED)
+static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
 {
-	int ret = 0;
+	TST_CHECKPOINT_WAIT(0);
 
-	TST_SAFE_CHECKPOINT_WAIT(NULL, 0);
+	if ((access(DIRA "/A", F_OK) != 0) || (access(DIRA "/B", F_OK) == 0))
+		tst_res(TFAIL, "private mount in parent failed");
+	else
+		tst_res(TPASS, "private mount in parent passed");
 
-	if ((access(DIRA"/A", F_OK) != 0) || (access(DIRA"/B", F_OK) == 0))
-		ret = 2;
+	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
-	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(NULL, 0);
+	/* bind mounts DIRB to DIRA making contents of DIRB visible in DIRA */
+	SAFE_MOUNT(DIRB, DIRA, "none", MS_BIND, NULL);
 
-	/* bind mounts DIRB to DIRA making contents of DIRB visible
-	 * in DIRA */
-	if (mount(DIRB, DIRA, "none", MS_BIND, NULL) == -1) {
-		perror("mount");
-		return 1;
-	}
+	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
-	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(NULL, 0);
+	SAFE_UMOUNT(DIRA);
 
-	umount(DIRA);
-	return ret;
+	return 0;
 }
 
-static void test(void)
+static void run(void)
 {
-	int status;
+	int ret;
 
 	/* unshares the mount ns */
-	if (unshare(CLONE_NEWNS) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "unshare failed");
+	SAFE_UNSHARE(CLONE_NEWNS);
+
 	/* makes sure parent mounts/umounts have no effect on a real system */
-	SAFE_MOUNT(cleanup, "none", "/", "none", MS_REC|MS_PRIVATE, NULL);
+	SAFE_MOUNT("none", "/", "none", MS_REC | MS_PRIVATE, NULL);
 
 	/* bind mounts DIRA to itself */
-	SAFE_MOUNT(cleanup, DIRA, DIRA, "none", MS_BIND, NULL);
+	SAFE_MOUNT(DIRA, DIRA, "none", MS_BIND, NULL);
 
 	/* makes mount DIRA private */
-	SAFE_MOUNT(cleanup, "none", DIRA, "none", MS_PRIVATE, NULL);
+	SAFE_MOUNT("none", DIRA, "none", MS_PRIVATE, NULL);
 
-	if (do_clone_tests(CLONE_NEWNS, child_func, NULL, NULL, NULL) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "clone failed");
+	ret = ltp_clone_quick(CLONE_NEWNS | SIGCHLD, child_func, NULL);
+	if (ret < 0)
+		tst_brk(TBROK, "clone failed");
 
-	/* bind mounts DIRB to DIRA making contents of DIRB visible
-	 * in DIRA */
-	SAFE_MOUNT(cleanup, DIRB, DIRA, "none", MS_BIND, NULL);
+	/* bind mounts DIRB to DIRA making contents of DIRB visible in DIRA */
+	SAFE_MOUNT(DIRB, DIRA, "none", MS_BIND, NULL);
 
-	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(cleanup, 0);
+	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
-	SAFE_UMOUNT(cleanup, DIRA);
+	SAFE_UMOUNT(DIRA);
 
-	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(cleanup, 0);
+	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
-	if ((access(DIRA"/A", F_OK) != 0) || (access(DIRA"/B", F_OK) == 0))
-		tst_resm(TFAIL, "private mount in child failed");
+	if ((access(DIRA "/A", F_OK) != 0) || (access(DIRA "/B", F_OK) == 0))
+		tst_res(TFAIL, "private mount in child failed");
 	else
-		tst_resm(TPASS, "private mount in child passed");
-
-	TST_SAFE_CHECKPOINT_WAKE(cleanup, 0);
+		tst_res(TPASS, "private mount in child passed");
 
+	TST_CHECKPOINT_WAKE(0);
 
-	SAFE_WAIT(cleanup, &status);
-	if (WIFEXITED(status)) {
-		if ((WEXITSTATUS(status) == 0))
-			tst_resm(TPASS, "private mount in parent passed");
-		else
-			tst_resm(TFAIL, "private mount in parent failed");
-	}
-	if (WIFSIGNALED(status)) {
-		tst_resm(TBROK, "child was killed with signal %s",
-			 tst_strsig(WTERMSIG(status)));
-		return;
-	}
-
-	SAFE_UMOUNT(cleanup, DIRA);
+	SAFE_UMOUNT(DIRA);
 }
 
-int main(int argc, char *argv[])
+static void setup(void)
 {
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++)
-		test();
-
-	cleanup();
-	tst_exit();
+	check_newns();
+	create_folders();
 }
 
-#else
-int main(void)
+static void cleanup(void)
 {
-	tst_brkm(TCONF, NULL, "needed mountflags are not defined");
+	umount_folders();
 }
-#endif
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = run,
+	.needs_root = 1,
+	.needs_checkpoints = 1,
+};
-- 
2.35.1


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

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

* [LTP] [PATCH v3 3/6] Rewrite mountns03 test using new LTP API
  2022-03-01  9:15 [LTP] [PATCH v3 0/6] Rewrite mountns testing suite Andrea Cervesato
  2022-03-01  9:15 ` [LTP] [PATCH v3 1/6] Rewrite mountns01 test using new LTP API Andrea Cervesato
  2022-03-01  9:15 ` [LTP] [PATCH v3 2/6] Rewrite mountns02 " Andrea Cervesato
@ 2022-03-01  9:15 ` Andrea Cervesato
  2022-03-01  9:15 ` [LTP] [PATCH v3 4/6] Rewrite mountns04 " Andrea Cervesato
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Andrea Cervesato @ 2022-03-01  9:15 UTC (permalink / raw)
  To: ltp

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
---
 .../kernel/containers/mountns/mountns03.c     | 206 +++++++-----------
 1 file changed, 84 insertions(+), 122 deletions(-)

diff --git a/testcases/kernel/containers/mountns/mountns03.c b/testcases/kernel/containers/mountns/mountns03.c
index 196a36149..b8537d1a0 100644
--- a/testcases/kernel/containers/mountns/mountns03.c
+++ b/testcases/kernel/containers/mountns/mountns03.c
@@ -1,166 +1,128 @@
-/* Copyright (c) 2014 Red Hat, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of version 2 the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- ***********************************************************************
- * File: mountns03.c
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * [Description]
  *
  * Tests a slave mount: slave mount is like a shared mount except that
  * mount and umount events only propagate towards it.
  *
- * Description:
- * 1. Creates directories "A", "B" and files "A/A", "B/B"
- * 2. Unshares mount namespace and makes it private (so mounts/umounts
- *    have no effect on a real system)
- * 3. Bind mounts directory "A" to itself
- * 4. Makes directory "A" shared
- * 5. Clones a new child process with CLONE_NEWNS flag and makes "A"
- *    a slave mount
- * 6. There are two testcases (where X is parent namespace and Y child
- *    namespace):
- *    1)
- *	X: bind mounts "B" to "A"
- *	Y: must see the file "A/B"
- *	X: umounts "A"
- *    2)
- *	Y: bind mounts "B" to "A"
- *	X: must see only the "A/A" and must not see "A/B" (as slave
- *	   mount does not forward propagation)
- *	Y: umounts "A"
- ***********************************************************************/
-
-#define _GNU_SOURCE
+ * [Algorithm]
+ *
+ * . Creates directories "A", "B" and files "A/A", "B/B"
+ * . Unshares mount namespace and makes it private (so mounts/umounts have no
+ *   effect on a real system)
+ * . Bind mounts directory "A" to itself
+ * . Makes directory "A" shared
+ * . Clones a new child process with CLONE_NEWNS flag and makes "A" a slave
+ *   mount
+ * . There are two testcases (where X is parent namespace and Y child
+ *   namespace):
+ * .. First test case
+ * ... X: bind mounts "B" to "A"
+ * ... Y: must see the file "A/B"
+ * ... X: umounts "A"
+ * .. Second test case
+ * ... Y: bind mounts "B" to "A"
+ * ... X: must see only the "A/A" and must not see "A/B" (as slave mount does
+ *     not forward propagation)
+ * ... Y: umounts "A"
+ */
+
 #include <sys/wait.h>
 #include <sys/mount.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#include "mountns_helper.h"
-#include "test.h"
-#include "safe_macros.h"
+#include "mountns.h"
+#include "tst_test.h"
 
-char *TCID	= "mountns03";
-int TST_TOTAL	= 2;
-
-#if defined(MS_SHARED) && defined(MS_PRIVATE) \
-    && defined(MS_REC) && defined(MS_SLAVE)
-
-int child_func(void *arg LTP_ATTRIBUTE_UNUSED)
+static int child_func(LTP_ATTRIBUTE_UNUSED void *arg)
 {
-	int ret = 0;
+	/*
+	 * makes mount DIRA a slave of DIRA (all slave mounts have
+	 * a master mount which is a shared mount)
+	 */
+	SAFE_MOUNT("none", DIRA, "none", MS_SLAVE, NULL);
 
-	/* makes mount DIRA a slave of DIRA (all slave mounts have
-	 * a master mount which is a shared mount) */
-	if (mount("none", DIRA, "none", MS_SLAVE, NULL) == -1) {
-		perror("mount");
-		return 1;
-	}
-
-	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(NULL, 0);
+	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
 	/* checks that shared mounts propagates to slave mount */
-	if (access(DIRA"/B", F_OK) == -1)
-		ret = 2;
+	if (access(DIRA "/B", F_OK) == 0)
+		tst_res(TPASS, "propagation to slave mount passed");
+	else
+		tst_res(TFAIL, "propagation to slave mount failed");
 
-	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(NULL, 0);
+	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
-	/* bind mounts DIRB to DIRA making contents of DIRB visible
-	 * in DIRA */
-	if (mount(DIRB, DIRA, "none", MS_BIND, NULL) == -1) {
-		perror("mount");
-		return 1;
-	}
+	/* bind mounts DIRB to DIRA making contents of DIRB visible in DIRA */
+	SAFE_MOUNT(DIRB, DIRA, "none", MS_BIND, NULL);
 
-	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(NULL, 0);
+	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
-	umount(DIRA);
-	return ret;
+	SAFE_UMOUNT(DIRA);
+
+	return 0;
 }
 
-static void test(void)
+static void run(void)
 {
-	int status;
+	int ret;
 
 	/* unshares the mount ns */
-	if (unshare(CLONE_NEWNS) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "unshare failed");
+	SAFE_UNSHARE(CLONE_NEWNS);
+
 	/* makes sure parent mounts/umounts have no effect on a real system */
-	SAFE_MOUNT(cleanup, "none", "/", "none", MS_REC|MS_PRIVATE, NULL);
+	SAFE_MOUNT("none", "/", "none", MS_REC | MS_PRIVATE, NULL);
 
 	/* bind mounts DIRA to itself */
-	SAFE_MOUNT(cleanup, DIRA, DIRA, "none", MS_BIND, NULL);
+	SAFE_MOUNT(DIRA, DIRA, "none", MS_BIND, NULL);
 
 	/* makes mount DIRA shared */
-	SAFE_MOUNT(cleanup, "none", DIRA, "none", MS_SHARED, NULL);
+	SAFE_MOUNT("none", DIRA, "none", MS_SHARED, NULL);
 
-	if (do_clone_tests(CLONE_NEWNS, child_func, NULL, NULL, NULL) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "clone failed");
+	ret = ltp_clone_quick(CLONE_NEWNS | SIGCHLD, child_func, NULL);
+	if (ret < 0)
+		tst_brk(TBROK, "clone failed");
 
 	/* waits for child to make a slave mount */
-	TST_SAFE_CHECKPOINT_WAIT(cleanup, 0);
+	TST_CHECKPOINT_WAIT(0);
 
-	/* bind mounts DIRB to DIRA making contents of DIRB visible
-	 * in DIRA */
-	SAFE_MOUNT(cleanup, DIRB, DIRA, "none", MS_BIND, NULL);
+	/* bind mounts DIRB to DIRA making contents of DIRB visible in DIRA */
+	SAFE_MOUNT(DIRB, DIRA, "none", MS_BIND, NULL);
 
-	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(cleanup, 0);
+	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
-	SAFE_UMOUNT(cleanup, DIRA);
+	SAFE_UMOUNT(DIRA);
 
-	TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(cleanup, 0);
+	TST_CHECKPOINT_WAKE_AND_WAIT(0);
 
 	/* checks that slave mount doesn't propagate to shared mount */
-	if ((access(DIRA"/A", F_OK) == 0) && (access(DIRA"/B", F_OK) == -1))
-		tst_resm(TPASS, "propagation from slave mount passed");
+	if ((access(DIRA "/A", F_OK) == 0) && (access(DIRA "/B", F_OK) == -1))
+		tst_res(TPASS, "propagation from slave mount passed");
 	else
-		tst_resm(TFAIL, "propagation form slave mount failed");
-
-	TST_SAFE_CHECKPOINT_WAKE(cleanup, 0);
+		tst_res(TFAIL, "propagation form slave mount failed");
 
+	TST_CHECKPOINT_WAKE(0);
 
-	SAFE_WAIT(cleanup, &status);
-	if (WIFEXITED(status)) {
-		if (WEXITSTATUS(status) == 0)
-			tst_resm(TPASS, "propagation to slave mount passed");
-		else
-			tst_resm(TFAIL, "propagation to slave mount failed");
-	}
-	if (WIFSIGNALED(status)) {
-		tst_resm(TBROK, "child was killed with signal %s",
-			 tst_strsig(WTERMSIG(status)));
-		return;
-	}
-
-	SAFE_UMOUNT(cleanup, DIRA);
+	SAFE_UMOUNT(DIRA);
 }
 
-int main(int argc, char *argv[])
+static void setup(void)
 {
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++)
-		test();
-
-	cleanup();
-	tst_exit();
+	check_newns();
+	create_folders();
 }
 
-#else
-int main(void)
+static void cleanup(void)
 {
-	tst_brkm(TCONF, NULL, "needed mountflags are not defined");
+	umount_folders();
 }
-#endif
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = run,
+	.needs_root = 1,
+	.needs_checkpoints = 1,
+};
-- 
2.35.1


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

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

* [LTP] [PATCH v3 4/6] Rewrite mountns04 test using new LTP API
  2022-03-01  9:15 [LTP] [PATCH v3 0/6] Rewrite mountns testing suite Andrea Cervesato
                   ` (2 preceding siblings ...)
  2022-03-01  9:15 ` [LTP] [PATCH v3 3/6] Rewrite mountns03 " Andrea Cervesato
@ 2022-03-01  9:15 ` Andrea Cervesato
  2022-03-01  9:15 ` [LTP] [PATCH v3 5/6] Removed obsolete mountns_helper.h Andrea Cervesato
  2022-03-01  9:15 ` [LTP] [PATCH v3 6/6] Removed libclone usage from mountns testing suite Andrea Cervesato
  5 siblings, 0 replies; 9+ messages in thread
From: Andrea Cervesato @ 2022-03-01  9:15 UTC (permalink / raw)
  To: ltp

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
---
 .../kernel/containers/mountns/mountns04.c     | 109 ++++++++----------
 1 file changed, 46 insertions(+), 63 deletions(-)

diff --git a/testcases/kernel/containers/mountns/mountns04.c b/testcases/kernel/containers/mountns/mountns04.c
index 1f022a683..044c90aa7 100644
--- a/testcases/kernel/containers/mountns/mountns04.c
+++ b/testcases/kernel/containers/mountns/mountns04.c
@@ -1,89 +1,72 @@
-/* Copyright (c) 2014 Red Hat, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of version 2 the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- ***********************************************************************
- * File: mountns04.c
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * [Description]
  *
  * Tests an unbindable mount: unbindable mount is an unbindable
  * private mount.
- * Description:
- * 1. Creates directories "A", "B" and files "A/A", "B/B"
- * 2. Unshares mount namespace and makes it private (so mounts/umounts
- *    have no effect on a real system)
- * 3. Bind mounts directory "A" to "A"
- * 4. Makes directory directory "A" unbindable
- * 5. Tries to bind mount unbindable "A" to "B":
- *    - if it fails, test passes
- *    - if it passes, test fails
- ***********************************************************************/
+ *
+ * [Algorithm]
+ *
+ * . Creates directories "A", "B" and files "A/A", "B/B"
+ * . Unshares mount namespace and makes it private (so mounts/umounts have no
+ *   effect on a real system)
+ * . Bind mounts directory "A" to "A"
+ * . Makes directory "A" unbindable
+ * . Tries to bind mount unbindable "A" to "B":
+ * .. if it fails, test passes
+ * .. if it passes, test fails
+ */
 
-#define _GNU_SOURCE
 #include <sys/wait.h>
 #include <sys/mount.h>
-#include <stdio.h>
-#include <errno.h>
-#include "mountns_helper.h"
-#include "test.h"
-#include "safe_macros.h"
-
-char *TCID	= "mountns04";
-int TST_TOTAL	= 1;
-
-#if defined(MS_SHARED) && defined(MS_PRIVATE) \
-    && defined(MS_REC) && defined(MS_UNBINDABLE)
+#include "mountns.h"
+#include "tst_test.h"
 
-static void test(void)
+static void run(void)
 {
 	/* unshares the mount ns */
-	if (unshare(CLONE_NEWNS) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "unshare failed");
+	SAFE_UNSHARE(CLONE_NEWNS);
+
 	/* makes sure mounts/umounts have no effect on a real system */
-	SAFE_MOUNT(cleanup, "none", "/", "none", MS_REC|MS_PRIVATE, NULL);
+	SAFE_MOUNT("none", "/", "none", MS_REC | MS_PRIVATE, NULL);
 
 	/* bind mounts DIRA to itself */
-	SAFE_MOUNT(cleanup, DIRA, DIRA, "none", MS_BIND, NULL);
+	SAFE_MOUNT(DIRA, DIRA, "none", MS_BIND, NULL);
+
 	/* makes mount DIRA unbindable */
-	SAFE_MOUNT(cleanup, "none", DIRA, "none", MS_UNBINDABLE, NULL);
+	SAFE_MOUNT("none", DIRA, "none", MS_UNBINDABLE, NULL);
 
 	/* tries to bind mount unbindable DIRA to DIRB which should fail */
 	if (mount(DIRA, DIRB, "none", MS_BIND, NULL) == -1) {
-		tst_resm(TPASS, "unbindable mount passed");
+		tst_res(TPASS, "unbindable mount passed");
 	} else {
-		SAFE_UMOUNT(cleanup, DIRB);
-		tst_resm(TFAIL, "unbindable mount faled");
+		SAFE_UMOUNT(DIRB);
+		tst_res(TFAIL, "unbindable mount faled");
 	}
 
-	SAFE_UMOUNT(cleanup, DIRA);
+	SAFE_UMOUNT(DIRA);
 }
 
-int main(int argc, char *argv[])
+static void setup(void)
 {
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++)
-		test();
-
-	cleanup();
-	tst_exit();
+	check_newns();
+	create_folders();
 }
 
-#else
-int main(void)
+static void cleanup(void)
 {
-	tst_brkm(TCONF, NULL, "needed mountflags are not defined");
+	umount_folders();
 }
-#endif
+
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = run,
+	.needs_root = 1,
+	.needs_checkpoints = 1,
+};
-- 
2.35.1


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

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

* [LTP] [PATCH v3 5/6] Removed obsolete mountns_helper.h
  2022-03-01  9:15 [LTP] [PATCH v3 0/6] Rewrite mountns testing suite Andrea Cervesato
                   ` (3 preceding siblings ...)
  2022-03-01  9:15 ` [LTP] [PATCH v3 4/6] Rewrite mountns04 " Andrea Cervesato
@ 2022-03-01  9:15 ` Andrea Cervesato
  2022-03-01  9:15 ` [LTP] [PATCH v3 6/6] Removed libclone usage from mountns testing suite Andrea Cervesato
  5 siblings, 0 replies; 9+ messages in thread
From: Andrea Cervesato @ 2022-03-01  9:15 UTC (permalink / raw)
  To: ltp

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
---
 .../containers/mountns/mountns_helper.h       | 61 -------------------
 1 file changed, 61 deletions(-)
 delete mode 100644 testcases/kernel/containers/mountns/mountns_helper.h

diff --git a/testcases/kernel/containers/mountns/mountns_helper.h b/testcases/kernel/containers/mountns/mountns_helper.h
deleted file mode 100644
index 4b4538eb8..000000000
--- a/testcases/kernel/containers/mountns/mountns_helper.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Copyright (c) 2014 Red Hat, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of version 2 the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "libclone.h"
-#include "test.h"
-#include "safe_macros.h"
-
-#define DIRA "A"
-#define DIRB "B"
-
-static int dummy_child(void *v)
-{
-	(void) v;
-	return 0;
-}
-
-static int check_newns(void)
-{
-	int pid, status;
-
-	if (tst_kvercmp(2, 4, 19) < 0)
-		tst_brkm(TCONF, NULL, "CLONE_NEWNS not supported");
-
-	pid = do_clone_unshare_test(T_CLONE, CLONE_NEWNS, dummy_child, NULL);
-	if (pid == -1)
-		tst_brkm(TCONF | TERRNO, NULL, "CLONE_NEWNS not supported");
-	SAFE_WAIT(NULL, &status);
-
-	return 0;
-}
-
-static void cleanup(void)
-{
-	umount(DIRA);
-	umount(DIRB);
-	tst_rmdir();
-}
-
-static void setup(void)
-{
-	tst_require_root();
-	check_newns();
-	tst_tmpdir();
-	TST_CHECKPOINT_INIT(tst_rmdir);
-	SAFE_MKDIR(cleanup, DIRA, 0777);
-	SAFE_MKDIR(cleanup, DIRB, 0777);
-	SAFE_TOUCH(cleanup, DIRA"/A", 0, NULL);
-	SAFE_TOUCH(cleanup, DIRB"/B", 0, NULL);
-}
-- 
2.35.1


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

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

* [LTP] [PATCH v3 6/6] Removed libclone usage from mountns testing suite
  2022-03-01  9:15 [LTP] [PATCH v3 0/6] Rewrite mountns testing suite Andrea Cervesato
                   ` (4 preceding siblings ...)
  2022-03-01  9:15 ` [LTP] [PATCH v3 5/6] Removed obsolete mountns_helper.h Andrea Cervesato
@ 2022-03-01  9:15 ` Andrea Cervesato
  5 siblings, 0 replies; 9+ messages in thread
From: Andrea Cervesato @ 2022-03-01  9:15 UTC (permalink / raw)
  To: ltp

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
---
 testcases/kernel/containers/mountns/Makefile | 21 +++-----------------
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/testcases/kernel/containers/mountns/Makefile b/testcases/kernel/containers/mountns/Makefile
index bd42bf41b..16284f4d5 100644
--- a/testcases/kernel/containers/mountns/Makefile
+++ b/testcases/kernel/containers/mountns/Makefile
@@ -1,23 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (c) 2014 Red Hat, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of version 2 the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-##############################################################################
+# Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
 
-top_srcdir              ?= ../../../..
+top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-include $(abs_srcdir)/../Makefile.inc
-
-LDLIBS                  := -lclone $(LDLIBS)
-
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
-- 
2.35.1


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

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

* Re: [LTP] [PATCH v3 1/6] Rewrite mountns01 test using new LTP API
  2022-03-01  9:15 ` [LTP] [PATCH v3 1/6] Rewrite mountns01 test using new LTP API Andrea Cervesato
@ 2022-03-01 14:35   ` Cyril Hrubis
  2022-03-01 15:18     ` Cyril Hrubis
  0 siblings, 1 reply; 9+ messages in thread
From: Cyril Hrubis @ 2022-03-01 14:35 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi!
Pushed with minor changes, thanks.

- changed the numbered list to simple list in the documentation
  as the three levels of different numbering looked a bit confusing

- changed the license to GPL-2.0 as the original was 2.0 only as well

- removed a few obvious comments, as long as the comment describes
  exactly what the next line does there is no value of keeping it

diff --git a/testcases/kernel/containers/mountns/mountns01.c b/testcases/kernel/containers/mountns/mountns01.c
index f2d67d17a..452fe1d10 100644
--- a/testcases/kernel/containers/mountns/mountns01.c
+++ b/testcases/kernel/containers/mountns/mountns01.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 Red Hat, Inc.
  * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
@@ -12,21 +12,21 @@
  *
  * [Algorithm]
  *
- * . Creates directories "A", "B" and files "A/A", "B/B"
- * . Unshares mount namespace and makes it private (so mounts/umounts have no
+ * - Creates directories "A", "B" and files "A/A", "B/B"
+ * - Unshares mount namespace and makes it private (so mounts/umounts have no
  *   effect on a real system)
- * . Bind mounts directory "A" to "A"
- * . Makes directory "A" shared
- * . Clones a new child process with CLONE_NEWNS flag
- * . There are two test cases (where X is parent namespace and Y child namespace):
- * .. First test case
- * ... X: bind mounts "B" to "A"
- * ... Y: must see "A/B"
- * ... X: umounts "A"
- * .. Second test case
- * ... Y: bind mounts "B" to "A"
- * ... X: must see "A/B"
- * ... Y: umounts "A"
+ * - Bind mounts directory "A" to "A"
+ * - Makes directory "A" shared
+ * - Clones a new child process with CLONE_NEWNS flag
+ * - There are two test cases (where X is parent namespace and Y child namespace):
+ *  1. First test case
+ *   .. X: bind mounts "B" to "A"
+ *   .. Y: must see "A/B"
+ *   .. X: umounts "A"
+ *  2. Second test case
+ *   .. Y: bind mounts "B" to "A"
+ *   .. X: must see "A/B"
+ *   .. Y: umounts "A"
  */
 
 #include <sys/wait.h>
@@ -59,23 +59,18 @@ static void run(void)
 {
 	int ret;
 
-	/* unshares the mount ns */
 	SAFE_UNSHARE(CLONE_NEWNS);
 
 	/* makes sure parent mounts/umounts have no effect on a real system */
 	SAFE_MOUNT("none", "/", "none", MS_REC | MS_PRIVATE, NULL);
 
-	/* bind mounts DIRA to itself */
 	SAFE_MOUNT(DIRA, DIRA, "none", MS_BIND, NULL);
-
-	/* makes mount DIRA shared */
 	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");
 
-	/* bind mounts DIRB to DIRA making contents of DIRB visible in DIRA */
 	SAFE_MOUNT(DIRB, DIRA, "none", MS_BIND, NULL);
 
 	TST_CHECKPOINT_WAKE_AND_WAIT(0);

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v3 1/6] Rewrite mountns01 test using new LTP API
  2022-03-01 14:35   ` Cyril Hrubis
@ 2022-03-01 15:18     ` Cyril Hrubis
  0 siblings, 0 replies; 9+ messages in thread
From: Cyril Hrubis @ 2022-03-01 15:18 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi!
And pushed the rest with a similar changes, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

end of thread, other threads:[~2022-03-01 15:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01  9:15 [LTP] [PATCH v3 0/6] Rewrite mountns testing suite Andrea Cervesato
2022-03-01  9:15 ` [LTP] [PATCH v3 1/6] Rewrite mountns01 test using new LTP API Andrea Cervesato
2022-03-01 14:35   ` Cyril Hrubis
2022-03-01 15:18     ` Cyril Hrubis
2022-03-01  9:15 ` [LTP] [PATCH v3 2/6] Rewrite mountns02 " Andrea Cervesato
2022-03-01  9:15 ` [LTP] [PATCH v3 3/6] Rewrite mountns03 " Andrea Cervesato
2022-03-01  9:15 ` [LTP] [PATCH v3 4/6] Rewrite mountns04 " Andrea Cervesato
2022-03-01  9:15 ` [LTP] [PATCH v3 5/6] Removed obsolete mountns_helper.h Andrea Cervesato
2022-03-01  9:15 ` [LTP] [PATCH v3 6/6] Removed libclone usage from mountns testing suite Andrea Cervesato

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.