[LTP] [PATCH v4] Rewrite userns06.c using new LTP API

Cyril Hrubis chrubis@suse.cz
Tue Apr 26 15:57:57 CEST 2022


Hi!
Pushed with minor changes, thanks.

- removed some useless comments
- fixed the type for resource files
- changed the TBROK to TCONF in the helper when libcap is missing

diff --git a/testcases/kernel/containers/userns/userns06.c b/testcases/kernel/containers/userns/userns06.c
index 100ad8274..002c72907 100644
--- a/testcases/kernel/containers/userns/userns06.c
+++ b/testcases/kernel/containers/userns/userns06.c
@@ -29,9 +29,6 @@
 #define CHILD2UID 200
 #define CHILD2GID 200
 
-/*
- * child_fn1() - Inside a new user namespace
- */
 static int child_fn1(void)
 {
 	char *const args[] = { TEST_APP, "privileged", NULL };
@@ -39,9 +36,6 @@ static int child_fn1(void)
 
 	TST_CHECKPOINT_WAIT(0);
 
-	/* execv will replace the main function and it will end this child
-	 * accordingly.
-	 */
 	ret = execv(args[0], args);
 	if (ret == -1)
 		tst_brk(TBROK | TERRNO, "execv: unexpected error");
@@ -49,9 +43,6 @@ static int child_fn1(void)
 	return 0;
 }
 
-/*
- * child_fn2() - Inside a new user namespace
- */
 static int child_fn2(void)
 {
 	int uid, gid, ret;
@@ -69,9 +60,6 @@ static int child_fn2(void)
 
 	tst_res(TPASS, "expected uid and gid");
 
-	/* execv will replace the main function and it will end this child
-	 * accordingly.
-	 */
 	ret = execv(args[0], args);
 	if (ret == -1)
 		tst_brk(TBROK | TERRNO, "execv: unexpected error");
@@ -133,7 +121,7 @@ static struct tst_test test = {
 	.test_all = run,
 	.needs_root = 1,
 	.needs_checkpoints = 1,
-	.resource_files = (char *const []) {
+	.resource_files = (const char *[]) {
 		TEST_APP,
 		NULL,
 	},
diff --git a/testcases/kernel/containers/userns/userns06_capcheck.c b/testcases/kernel/containers/userns/userns06_capcheck.c
index 589e8bb94..bae4e4e33 100644
--- a/testcases/kernel/containers/userns/userns06_capcheck.c
+++ b/testcases/kernel/containers/userns/userns06_capcheck.c
@@ -60,6 +60,6 @@ int main(void)
 {
 	tst_reinit();
 
-	tst_brk(TBROK, "System is missing libcap");
+	tst_brk(TCONF, "System is missing libcap");
 }

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list