Message ID | 20220722083529.209-1-chenhx.fnst@fujitsu.com |
---|---|
State | Changes Requested |
Headers | show |
Series | resource_files: inline resource file for readable doc | expand |
Hi Chen, Cyril, > 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. > Signed-off-by: Chen Hanxiao <chenhx.fnst@fujitsu.com> Suggested-by: Petr Vorel <pvorel@suse.cz> :). > --- > 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(-) > diff --git a/testcases/kernel/containers/userns/userns06.c b/testcases/kernel/containers/userns/userns06.c > index 002c72907..9e900d94b 100644 > --- a/testcases/kernel/containers/userns/userns06.c > +++ b/testcases/kernel/containers/userns/userns06.c > @@ -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
> Hi Chen, Cyril, > > 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. > > Signed-off-by: Chen Hanxiao <chenhx.fnst@fujitsu.com> > Suggested-by: Petr Vorel <pvorel@suse.cz> > :). > > --- > > 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(-) > > diff --git a/testcases/kernel/containers/userns/userns06.c b/testcases/kernel/containers/userns/userns06.c > > index 002c72907..9e900d94b 100644 > > --- a/testcases/kernel/containers/userns/userns06.c > > +++ b/testcases/kernel/containers/userns/userns06.c > > @@ -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 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 > I'd expect 36d6d745c ("docparse: Implement #define and #include") would fix > this. What am I missing? > Kind regards, > Petr
Hi Chen, Cyril, I was wrong, inlining arrays does any change in the docparse output when constant is kept being used. I'd be still for inlining with kept constant, due better readability. I tried to address replacing constant in separate patch: https://lore.kernel.org/ltp/20220729153246.1213-1-pvorel@suse.cz/ https://patchwork.ozlabs.org/project/ltp/patch/20220729153246.1213-1-pvorel@suse.cz/ Kind regards, Petr
diff --git a/testcases/kernel/containers/userns/userns06.c b/testcases/kernel/containers/userns/userns06.c index 002c72907..9e900d94b 100644 --- a/testcases/kernel/containers/userns/userns06.c +++ b/testcases/kernel/containers/userns/userns06.c @@ -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 *[]) { diff --git a/testcases/kernel/syscalls/creat/creat07.c b/testcases/kernel/syscalls/creat/creat07.c index 1e9779476..327bd2ee3 100644 --- a/testcases/kernel/syscalls/creat/creat07.c +++ b/testcases/kernel/syscalls/creat/creat07.c @@ -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, + }, }; diff --git a/testcases/kernel/syscalls/execve/execve02.c b/testcases/kernel/syscalls/execve/execve02.c index 0574f5c8b..4f43c8f0f 100644 --- a/testcases/kernel/syscalls/execve/execve02.c +++ b/testcases/kernel/syscalls/execve/execve02.c @@ -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, }; diff --git a/testcases/kernel/syscalls/execve/execve04.c b/testcases/kernel/syscalls/execve/execve04.c index c7b8c1614..c084af244 100644 --- a/testcases/kernel/syscalls/execve/execve04.c +++ b/testcases/kernel/syscalls/execve/execve04.c @@ -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, + }, }; diff --git a/testcases/kernel/syscalls/execve/execve05.c b/testcases/kernel/syscalls/execve/execve05.c index 63bfb0fbd..252abb9c2 100644 --- a/testcases/kernel/syscalls/execve/execve05.c +++ b/testcases/kernel/syscalls/execve/execve05.c @@ -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, }; diff --git a/testcases/kernel/syscalls/execveat/execveat01.c b/testcases/kernel/syscalls/execveat/execveat01.c index 16d27acf6..77fd0c68e 100644 --- a/testcases/kernel/syscalls/execveat/execveat01.c +++ b/testcases/kernel/syscalls/execveat/execveat01.c @@ -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, diff --git a/testcases/kernel/syscalls/execveat/execveat02.c b/testcases/kernel/syscalls/execveat/execveat02.c index 9b08efb78..59c24efb3 100644 --- a/testcases/kernel/syscalls/execveat/execveat02.c +++ b/testcases/kernel/syscalls/execveat/execveat02.c @@ -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, diff --git a/testcases/kernel/syscalls/execveat/execveat03.c b/testcases/kernel/syscalls/execveat/execveat03.c index 1900c076b..bf341007e 100644 --- a/testcases/kernel/syscalls/execveat/execveat03.c +++ b/testcases/kernel/syscalls/execveat/execveat03.c @@ -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"}, diff --git a/testcases/kernel/syscalls/fanotify/fanotify03.c b/testcases/kernel/syscalls/fanotify/fanotify03.c index a3b9d5c37..d663ebc32 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify03.c +++ b/testcases/kernel/syscalls/fanotify/fanotify03.c @@ -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 diff --git a/testcases/kernel/syscalls/fanotify/fanotify10.c b/testcases/kernel/syscalls/fanotify/fanotify10.c index 52277d0b7..2ec28eaf6 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify10.c +++ b/testcases/kernel/syscalls/fanotify/fanotify10.c @@ -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"}, diff --git a/testcases/kernel/syscalls/fanotify/fanotify12.c b/testcases/kernel/syscalls/fanotify/fanotify12.c index 52e728e2a..8ccc67a73 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify12.c +++ b/testcases/kernel/syscalls/fanotify/fanotify12.c @@ -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"); diff --git a/testcases/kernel/syscalls/getrusage/getrusage03.c b/testcases/kernel/syscalls/getrusage/getrusage03.c index 7e7a1f555..243d1b859 100644 --- a/testcases/kernel/syscalls/getrusage/getrusage03.c +++ b/testcases/kernel/syscalls/getrusage/getrusage03.c @@ -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[]) { diff --git a/testcases/kernel/syscalls/pipe2/pipe2_02.c b/testcases/kernel/syscalls/pipe2/pipe2_02.c index 9ba69667b..953e4be9d 100644 --- a/testcases/kernel/syscalls/pipe2/pipe2_02.c +++ b/testcases/kernel/syscalls/pipe2/pipe2_02.c @@ -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, diff --git a/testcases/kernel/syscalls/prctl/prctl06.c b/testcases/kernel/syscalls/prctl/prctl06.c index 62c5a135b..f6b41b500 100644 --- a/testcases/kernel/syscalls/prctl/prctl06.c +++ b/testcases/kernel/syscalls/prctl/prctl06.c @@ -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,
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. Signed-off-by: Chen Hanxiao <chenhx.fnst@fujitsu.com> --- 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(-)