Skip to contentSkip to conversation

resource_files: inline resource file for readable doc

PATCH In review [email protected] 2 participants 4 messages Jul 22, 2022 – Jul 29, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 resource_files: inline resource file for readable doc

Currently from resource_files section of metadata doc, we usually get:

.resource_files TEST_APP

or

.resource_files resource_files

which do not help much.

This patch will inline reource file with its real name.

---
 testcases/kernel/containers/userns/userns06.c     |  2 +-
 testcases/kernel/syscalls/creat/creat07.c         | 10 ++++------
 testcases/kernel/syscalls/execve/execve02.c       | 10 ++++------
 testcases/kernel/syscalls/execve/execve04.c       | 10 ++++------
 testcases/kernel/syscalls/execve/execve05.c       | 10 ++++------
 testcases/kernel/syscalls/execveat/execveat01.c   | 10 ++++------
 testcases/kernel/syscalls/execveat/execveat02.c   | 10 ++++------
 testcases/kernel/syscalls/execveat/execveat03.c   | 10 ++++------
 testcases/kernel/syscalls/fanotify/fanotify03.c   | 10 ++++------
 testcases/kernel/syscalls/fanotify/fanotify10.c   | 10 ++++------
 testcases/kernel/syscalls/fanotify/fanotify12.c   | 10 ++++------
 testcases/kernel/syscalls/getrusage/getrusage03.c | 10 ++++------
 testcases/kernel/syscalls/pipe2/pipe2_02.c        | 10 ++++------
 testcases/kernel/syscalls/prctl/prctl06.c         | 10 ++++------
 14 files changed, 53 insertions(+), 79 deletions(-)
testcases/kernel/containers/userns/userns06.c +1 -1
index 002c72907..9e900d94b 100644
@@ -122,7 +122,7 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.needs_checkpoints = 1,
 	.resource_files = (const char *[]) {
-		TEST_APP,
+		"userns06_capcheck",
 		NULL,
 	},
 	.needs_kconfigs = (const char *[]) {
testcases/kernel/syscalls/creat/creat07.c +4 -6
index 1e9779476..327bd2ee3 100644
@@ -47,14 +47,12 @@ static void verify_creat(void)
 	SAFE_WAITPID(pid, NULL, 0);
 }
 
-static const char *const resource_files[] = {
-	TEST_APP,
-	NULL,
-};
-
 static struct tst_test test = {
 	.test_all = verify_creat,
 	.needs_checkpoints = 1,
 	.forks_child = 1,
-	.resource_files = resource_files,
+	.resource_files = (const char *[]) {
+		"creat07_child",
+		NULL,
+	},
 };
testcases/kernel/syscalls/execve/execve02.c +4 -6
index 0574f5c8b..4f43c8f0f 100644
@@ -74,16 +74,14 @@ static void setup(void)
 	nobody_uid = pwd->pw_uid;
 }
 
-static const char *const resource_files[] = {
-	TEST_APP,
-	NULL,
-};
-
 static struct tst_test test = {
 	.needs_root = 1,
 	.forks_child = 1,
 	.child_needs_reinit = 1,
 	.setup = setup,
-	.resource_files = resource_files,
+	.resource_files = (const char *[]) {
+		"execve_child",
+		NULL,
+	},
 	.test_all = verify_execve,
 };
testcases/kernel/syscalls/execve/execve04.c +4 -6
index c7b8c1614..c084af244 100644
@@ -63,15 +63,13 @@ static void do_child(void)
 	exit(0);
 }
 
-static const char *const resource_files[] = {
-	TEST_APP,
-	NULL,
-};
-
 static struct tst_test test = {
 	.test_all = verify_execve,
 	.forks_child = 1,
 	.child_needs_reinit = 1,
 	.needs_checkpoints = 1,
-	.resource_files = resource_files,
+	.resource_files = (const char *[]) {
+		"execve_child",
+		NULL,
+	},
 };
testcases/kernel/syscalls/execve/execve05.c +4 -6
index 63bfb0fbd..252abb9c2 100644
@@ -44,11 +44,6 @@ static int nchild = 8;
 
 static char *opt_nchild;
 
-static const char *const resource_files[] = {
-	TEST_APP,
-	NULL,
-};
-
 static void do_child(void)
 {
 	char *argv[3] = {TEST_APP, "canary", NULL};
@@ -86,6 +81,9 @@ static struct tst_test test = {
 	.forks_child = 1,
 	.child_needs_reinit = 1,
 	.needs_checkpoints = 1,
-	.resource_files = resource_files,
+	.resource_files = (const char *[]) {
+		"execve_child",
+		NULL,
+	},
 	.setup = setup,
 };
testcases/kernel/syscalls/execveat/execveat01.c +4 -6
index 16d27acf6..77fd0c68e 100644
@@ -84,13 +84,11 @@ static void cleanup(void)
 		SAFE_CLOSE(fd4);
 }
 
-static const char *const resource_files[] = {
-	TEST_APP,
-	NULL,
-};
-
 static struct tst_test test = {
-	.resource_files = resource_files,
+	.resource_files = (const char *[]) {
+		"execveat_child",
+		NULL,
+	},
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_execveat,
 	.child_needs_reinit = 1,
testcases/kernel/syscalls/execveat/execveat02.c +4 -6
index 9b08efb78..59c24efb3 100644
@@ -85,11 +85,6 @@ static void setup(void)
 	fd = SAFE_OPEN(TEST_REL_APP, O_PATH);
 }
 
-static const char *const resource_files[] = {
-	TEST_APP,
-	NULL,
-};
-
 static void cleanup(void)
 {
 	if (fd > 0)
@@ -97,7 +92,10 @@ static void cleanup(void)
 }
 
 static struct tst_test test = {
-	.resource_files = resource_files,
+	.resource_files = (const char *[]) {
+		"execveat_errno",
+		NULL,
+	},
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_execveat,
 	.child_needs_reinit = 1,
testcases/kernel/syscalls/execveat/execveat03.c +4 -6
index 1900c076b..bf341007e 100644
@@ -67,11 +67,6 @@ static void setup(void)
 	check_execveat();
 }
 
-static const char *const resource_files[] = {
-	TEST_APP,
-	NULL,
-};
-
 static struct tst_test test = {
 	.needs_root = 1,
 	.mount_device = 1,
@@ -81,7 +76,10 @@ static struct tst_test test = {
 	.child_needs_reinit = 1,
 	.setup = setup,
 	.test_all = verify_execveat,
-	.resource_files = resource_files,
+	.resource_files = (const char *[]) {
+		"execveat_child",
+		NULL,
+	},
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "8db6c34f1dbc"},
 		{"linux-git", "355139a8dba4"},
testcases/kernel/syscalls/fanotify/fanotify03.c +4 -6
index a3b9d5c37..d663ebc32 100644
@@ -337,11 +337,6 @@ static void cleanup(void)
 		SAFE_CLOSE(fd_notify);
 }
 
-static const char *const resource_files[] = {
-	TEST_APP,
-	NULL
-};
-
 static struct tst_test test = {
 	.test = test_fanotify,
 	.tcnt = ARRAY_SIZE(tcases),
@@ -351,7 +346,10 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.mount_device = 1,
 	.mntpoint = MOUNT_PATH,
-	.resource_files = resource_files
+	.resource_files = (const char *[]) {
+		"fanotify_child",
+		NULL,
+	},
 };
 
 #else
testcases/kernel/syscalls/fanotify/fanotify10.c +4 -6
index 52277d0b7..2ec28eaf6 100644
@@ -633,11 +633,6 @@ static void cleanup(void)
 	SAFE_FILE_PRINTF(CACHE_PRESSURE_FILE, "%d", old_cache_pressure);
 }
 
-static const char *const resource_files[] = {
-	TEST_APP,
-	NULL
-};
-
 static struct tst_test test = {
 	.test = test_fanotify,
 	.tcnt = ARRAY_SIZE(tcases),
@@ -647,7 +642,10 @@ static struct tst_test test = {
 	.mntpoint = MOUNT_PATH,
 	.needs_root = 1,
 	.forks_child = 1,
-	.resource_files = resource_files,
+	.resource_files = (const char *[]) {
+		"fanotify_child",
+		NULL,
+	},
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "9bdda4e9cf2d"},
 		{"linux-git", "2f02fd3fa13e"},
testcases/kernel/syscalls/fanotify/fanotify12.c +4 -6
index 52e728e2a..8ccc67a73 100644
@@ -235,11 +235,6 @@ static void do_cleanup(void)
 		SAFE_CLOSE(fd_notify);
 }
 
-static const char *const resource_files[] = {
-	TEST_APP,
-	NULL
-};
-
 static struct tst_test test = {
 	.setup = do_setup,
 	.test = do_test,
@@ -247,7 +242,10 @@ static struct tst_test test = {
 	.cleanup = do_cleanup,
 	.forks_child = 1,
 	.needs_root = 1,
-	.resource_files = resource_files
+	.resource_files = (const char *[]) {
+		"fanotify_child",
+		NULL,
+	},
 };
 #else
 	TST_TEST_TCONF("System does not contain required fanotify support");
testcases/kernel/syscalls/getrusage/getrusage03.c +4 -6
index 7e7a1f555..243d1b859 100644
@@ -26,11 +26,6 @@
 static struct rusage ru;
 static long maxrss_init;
 
-static const char *const resource[] = {
-	TESTBIN,
-	NULL,
-};
-
 static void inherit_fork1(void)
 {
 	SAFE_GETRUSAGE(RUSAGE_SELF, &ru);
@@ -176,7 +171,10 @@ static void run(unsigned int i)
 static struct tst_test test = {
 	.forks_child = 1,
 	.child_needs_reinit = 1,
-	.resource_files = resource,
+	.resource_files = (const char *[]) {
+		"getrusage03_child",
+		NULL,
+	},
 	.min_kver = "2.6.32",
 	.min_mem_avail = 512,
 	.tags = (const struct tst_tag[]) {
testcases/kernel/syscalls/pipe2/pipe2_02.c +4 -6
index 9ba69667b..953e4be9d 100644
@@ -54,13 +54,11 @@ static void verify_pipe2(void)
 	cleanup();
 }
 
-static const char *const resfile[] = {
-	TESTBIN,
-	NULL,
-};
-
 static struct tst_test test = {
-	.resource_files = resfile,
+	.resource_files = (const char *[]) {
+		"pipe2_02_child",
+		NULL,
+	},
 	.cleanup = cleanup,
 	.forks_child = 1,
 	.needs_root = 1,
testcases/kernel/syscalls/prctl/prctl06.c +4 -6
index 62c5a135b..f6b41b500 100644
@@ -113,13 +113,11 @@ static void setup(void)
 		"current environment doesn't permit PR_GET/SET_NO_NEW_PRIVS");
 }
 
-static const char *const resfile[] = {
-	TESTBIN,
-	NULL,
-};
-
 static struct tst_test test = {
-	.resource_files = resfile,
+	.resource_files = (const char *[]) {
+		"prctl06_execve",
+		NULL,
+	},
 	.setup = setup,
 	.test_all = verify_prctl,
 	.forks_child = 1,
Signature · 4 lines
2.31.1

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Chen, Cyril,

Quoted 6 lines

Currently from resource_files section of metadata doc, we usually get:

.resource_files TEST_APP

or

Quoted 7 lines

.resource_files resource_files

which do not help much.

This patch will inline reource file with its real name.

:).

Quoted 22 lines
---
 testcases/kernel/containers/userns/userns06.c     |  2 +-
 testcases/kernel/syscalls/creat/creat07.c         | 10 ++++------
 testcases/kernel/syscalls/execve/execve02.c       | 10 ++++------
 testcases/kernel/syscalls/execve/execve04.c       | 10 ++++------
 testcases/kernel/syscalls/execve/execve05.c       | 10 ++++------
 testcases/kernel/syscalls/execveat/execveat01.c   | 10 ++++------
 testcases/kernel/syscalls/execveat/execveat02.c   | 10 ++++------
 testcases/kernel/syscalls/execveat/execveat03.c   | 10 ++++------
 testcases/kernel/syscalls/fanotify/fanotify03.c   | 10 ++++------
 testcases/kernel/syscalls/fanotify/fanotify10.c   | 10 ++++------
 testcases/kernel/syscalls/fanotify/fanotify12.c   | 10 ++++------
 testcases/kernel/syscalls/getrusage/getrusage03.c | 10 ++++------
 testcases/kernel/syscalls/pipe2/pipe2_02.c        | 10 ++++------
 testcases/kernel/syscalls/prctl/prctl06.c         | 10 ++++------
 14 files changed, 53 insertions(+), 79 deletions(-)
testcases/kernel/containers/userns/userns06.c +0 -0
index 002c72907..9e900d94b 100644

testcases/kernel/containers/userns/userns06.c static struct tst_test test = { · line 126

Quoted 6 lines
testcases/kernel/containers/userns/userns06.c +1 -1
@@ -122,7 +122,7 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.needs_checkpoints = 1,
 	.resource_files = (const char *[]) {
-		TEST_APP,
+		"userns06_capcheck",
 		NULL,

Hardcode binary name when there is TESTBIN is no-go => I'd be for rejecting this.

@metan: what bothers me is that even adding a test directory as include does not help (yes, path relative to src root is correct):

$ ./metaparse -Iinclude -Itestcases/kernel/syscalls/utils/ -Itestcases/kernel/containers/userns/ ../testcases/kernel/containers/userns/userns06.c

I'd expect 36d6d745c ("docparse: Implement #define and #include") would fix this. What am I missing?

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
Quoted 50 lines

Hi Chen, Cyril,

Quoted 6 lines

Currently from resource_files section of metadata doc, we usually get:

.resource_files TEST_APP

or

Quoted 7 lines

.resource_files resource_files

which do not help much.

This patch will inline reource file with its real name.

:).

Quoted 22 lines
---
 testcases/kernel/containers/userns/userns06.c     |  2 +-
 testcases/kernel/syscalls/creat/creat07.c         | 10 ++++------
 testcases/kernel/syscalls/execve/execve02.c       | 10 ++++------
 testcases/kernel/syscalls/execve/execve04.c       | 10 ++++------
 testcases/kernel/syscalls/execve/execve05.c       | 10 ++++------
 testcases/kernel/syscalls/execveat/execveat01.c   | 10 ++++------
 testcases/kernel/syscalls/execveat/execveat02.c   | 10 ++++------
 testcases/kernel/syscalls/execveat/execveat03.c   | 10 ++++------
 testcases/kernel/syscalls/fanotify/fanotify03.c   | 10 ++++------
 testcases/kernel/syscalls/fanotify/fanotify10.c   | 10 ++++------
 testcases/kernel/syscalls/fanotify/fanotify12.c   | 10 ++++------
 testcases/kernel/syscalls/getrusage/getrusage03.c | 10 ++++------
 testcases/kernel/syscalls/pipe2/pipe2_02.c        | 10 ++++------
 testcases/kernel/syscalls/prctl/prctl06.c         | 10 ++++------
 14 files changed, 53 insertions(+), 79 deletions(-)
testcases/kernel/containers/userns/userns06.c +0 -0
index 002c72907..9e900d94b 100644

testcases/kernel/containers/userns/userns06.c static struct tst_test test = { · line 126

Quoted 6 lines
testcases/kernel/containers/userns/userns06.c +1 -1
@@ -122,7 +122,7 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.needs_checkpoints = 1,
 	.resource_files = (const char *[]) {
-		TEST_APP,
+		"userns06_capcheck",
 		NULL,

Hardcode binary name when there is TESTBIN is no-go => I'd be for rejecting this.

Quoted 4 lines

@metan: what bothers me is that even adding a test directory as include does not help (yes, path relative to src root is correct):

$ ./metaparse -Iinclude -Itestcases/kernel/syscalls/utils/ -Itestcases/kernel/containers/userns/ ../testcases/kernel/containers/userns/userns06.c

OK, running with -v shows only "common.h" is included, because there is no header in testcases/kernel/containers/userns/ and TEST_APP is defined in the file.

Also TEST_APP is correctly detected via parse_macro(f):
...
INCLUDE ../testcases/kernel/containers/userns/common.h
MACRO UID_MAP=0
MACRO GID_MAP=1
INCLUDE END
MACRO TEST_APP=userns06_capcheck
MACRO CHILD1UID=0
MACRO CHILD1GID=0
MACRO CHILD2UID=200
MACRO CHILD2GID=200

I'll have look why it's not replaced.

Kind regards,
Petr

Quoted 5 lines

I'd expect 36d6d745c ("docparse: Implement #define and #include") would fix this. What am I missing?

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp