Support metadata groups
v2 cover Support metadata groups
---
Changes in v2:
- switch from @group to @groups
- use Cyril snippet to folter out groups from description
- optimize code
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Andrea Cervesato (2):
metadata: add tests grouping support
doc: conf.py: Show groups in test catalog
doc/conf.py | 10 +++ metadata/metaparse.c | 159 +++++++++++++++++++++++++++++++++++-------- metadata/tests/groups.c | 11 +++ metadata/tests/groups.c.json | 12 ++++ 4 files changed, 162 insertions(+), 30 deletions(-)
---
base-commit: bc9cfca5c7b6599e501d580bb42b9538390fd9a6
change-id: 20260612-metadata_groups-dd2430e21901
Best regards,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/2 metadata: add tests grouping support
From: Andrea Cervesato <[email protected]>
Add groups field to metaparse JSON output, so we can filter out tests in kirk. Groups are derived from:
1. Source file path - the two nearest parent directories (immediate parent first), skipping 'kernel' as too generic. For example:
- testcases/kernel/syscalls/clone/clone01.c -> clone, syscalls
- testcases/kernel/kvm/kvm_pagefault01.c -> kvm
- testcases/cve/cve-2017-16939.c -> cve
2. @groups tags in the doc comment block, e.g.:
/*\
* Test description.
*
* @groups stress syscalls
* @groups memory
*/
Add test case for @groups tag parsing.
--- metadata/metaparse.c | 159 +++++++++++++++++++++++++++++++++++-------- metadata/tests/groups.c | 11 +++ metadata/tests/groups.c.json | 12 ++++ 3 files changed, 152 insertions(+), 30 deletions(-)
metadata/metaparse.c +129 -30
@@ -17,6 +17,7 @@#include "data_storage.h" #define INCLUDE_PATH_MAX 5 +#define GROUPS_TAG "groups"static int verbose;static char *cmdline_includepath[INCLUDE_PATH_MAX ];
@@ -50,7 +51,49 @@ static const char *eat_asterisk_space(const char *c)return c; } -static void multiline_comment (FILE *f,struct data_node *doc) +/* +* Add a group to the groups array, skipping 'kernel' as it's too generic. +* Returns 0 if no group was added, 1 otherwise. +*/ +static int add_group (struct data_node *groups,const char *name) +{ +if (name &&strcmp (name,"kernel" )) { +data_node_array_add (groups,data_node_string (name)); +return 1 ; + } + +return 0 ; +} + +/* +* Parse a '@groups foo bar baz' doc comment line, adding each +* whitespace-separated name to the groups array. Returns 1 if the line +* was a @groups tag (and should be consumed), 0 otherwise. +*/ +static int parse_groups (struct data_node *groups,char *line) +{ +char *s; +char *name; + +if (!groups) +return 0 ; + + s = (char *)eat_asterisk_space (line); +if (strncmp (s,GROUPS_TAG ,sizeof (GROUPS_TAG ) -1 )) +return 0 ; + + s +=sizeof (GROUPS_TAG ) -1 ; +if (*s && *s !=' ' && *s !='\t' ) +return 0 ; + +for (name =strtok (s," \t" ); name; name =strtok (NULL ," \t" )) +add_group (groups, name); + +return 1 ; +} + +static void multiline_comment (FILE *f,struct data_node *doc, +struct data_node *groups) {int c;int state =0 ;
@@ -62,12 +105,14 @@ static void multiline_comment(FILE *f, struct data_node *doc)if (doc) {if (c =='\n' ) { -struct data_node *line; +char *str; buf[bufp] =0 ; - line =data_node_string (eat_asterisk_space (buf)); -if (data_node_array_add (doc, line)) -WARN ("doc string comment truncated" ); + str = (char *)eat_asterisk_space (buf); bufp =0 ; +if (parse_groups (groups, str)) +continue ; +if (data_node_array_add (doc,data_node_string (str))) +WARN ("doc string comment truncated" );continue ; }
@@ -100,7 +145,8 @@ static void multiline_comment(FILE *f, struct data_node *doc)static const char doc_prefix[] ="\\\n" ; -static void maybe_doc_comment (FILE *f,struct data_node *doc) +static void maybe_doc_comment (FILE *f,struct data_node *doc, +struct data_node *groups) {int c, i;
@@ -113,14 +159,15 @@ static void maybe_doc_comment(FILE *f, struct data_node *doc)if (c =='*' )ungetc (c, f); -multiline_comment (f,NULL ); +multiline_comment (f,NULL ,NULL );return ; } -multiline_comment (f, doc); +multiline_comment (f, doc, groups); } -static void maybe_comment (FILE *f,struct data_node *doc) +static void maybe_comment (FILE *f,struct data_node *doc, +struct data_node *groups) {int c =getc (f);
@@ -129,7 +176,7 @@ static void maybe_comment(FILE *f, struct data_node *doc)remove_to_newline (f);break ;case '*' : -maybe_doc_comment (f, doc); +maybe_doc_comment (f, doc, groups);break ;default :ungetc (c, f);
@@ -137,7 +184,8 @@ static void maybe_comment(FILE *f, struct data_node *doc) } } -static char *next_token2 (FILE *f,char *buf,size_t buf_len,struct data_node *doc) +static char *next_token2 (FILE *f,char *buf,size_t buf_len, +struct data_node *doc,struct data_node *groups) {size_t i =0 ;int c;
@@ -194,7 +242,7 @@ static char *next_token2(FILE *f, char *buf, size_t buf_len, struct data_node *d buf[i++] = c;break ;case '/' : -maybe_comment (f, doc); +maybe_comment (f, doc, groups);break ;case '"' : in_str =1 ;
@@ -216,11 +264,11 @@ exit:return buf; } -static char *next_token (FILE *f,struct data_node *doc) +static char *next_token (FILE *f,struct data_node *doc,struct data_node *groups) {static char buf[4096 ]; -return next_token2 (f, buf,sizeof (buf), doc); +return next_token2 (f, buf,sizeof (buf), doc, groups); }static FILE *open_file (const char *dir,const char *fname)
@@ -383,7 +431,7 @@ static int array_is_hash(FILE *f)int in_id =1 ;char *token; -while ((token =next_token (f,NULL ))) { +while ((token =next_token (f,NULL ,NULL ))) {if (!strcmp (token,"}" )) {if (in_id && !comma_last)
@@ -402,7 +450,7 @@ static int array_is_hash(FILE *f)int level =1 ;for (;;) { - token =next_token (f,NULL ); + token =next_token (f,NULL ,NULL );if (!token) goto ret;
@@ -453,7 +501,7 @@ static int parse_array(FILE *f, const char *arr_id, struct data_node **ret) *ret =data_node_array ();for (;;) { -if (!(token =next_token (f,NULL ))) +if (!(token =next_token (f,NULL ,NULL )))return 1 ;if (!strcmp (token,"{" )) {
@@ -529,14 +577,14 @@ static int parse_get_array_len(FILE *f)const char *token;int cnt =0 , depth =0 , prev_comma =0 ; -if (!(token =next_token (f,NULL ))) +if (!(token =next_token (f,NULL ,NULL )))return 0 ;if (strcmp (token,"{" ))return 0 ;for (;;) { -if (!(token =next_token (f,NULL ))) +if (!(token =next_token (f,NULL ,NULL )))return 0 ;if (!strcmp (token,"{" ))
@@ -565,7 +613,7 @@ static void look_for_array_size(FILE *f, const char *arr_id, struct data_node **int prev_buf =1 ;for (;;) { -if (!(token =next_token2 (f, buf[cur_buf],sizeof (buf[cur_buf]),NULL ))) +if (!(token =next_token2 (f, buf[cur_buf],sizeof (buf[cur_buf]),NULL ,NULL )))break ;if (!strcmp (token,"=" ) && !strcmp (buf[prev_buf], arr_id)) {
@@ -595,13 +643,13 @@ static int parse_array_size(FILE *f, struct data_node **res) *res =NULL ; -if (!(token =next_token (f,NULL ))) +if (!(token =next_token (f,NULL ,NULL )))return 1 ;if (strcmp (token,"(" ))return 1 ; -if (!(token =next_token (f,NULL ))) +if (!(token =next_token (f,NULL ,NULL )))return 1 ; arr_id =strdup (token);
@@ -621,7 +669,7 @@ static int parse_array_size(FILE *f, struct data_node **res)rewind (f);for (;;) { -if (!(token =next_token (f,NULL ))) +if (!(token =next_token (f,NULL ,NULL )))break ;if (token[0 ] =='#' ) {
@@ -654,7 +702,8 @@ static int parse_array_size(FILE *f, struct data_node **res)return 0 ; } -static int parse_test_struct (FILE *f,struct data_node *doc,struct data_node *node) +static int parse_test_struct (FILE *f,struct data_node *doc, +struct data_node *groups,struct data_node *node) {char *token;char *id =NULL ;
@@ -662,7 +711,7 @@ static int parse_test_struct(FILE *f, struct data_node *doc, struct data_node *nstruct data_node *ret;for (;;) { -if (!(token =next_token (f, doc))) +if (!(token =next_token (f, doc, groups)))return 1 ;if (!strcmp (token,"}" ))
@@ -842,7 +891,7 @@ static void parse_include_macros(FILE *f, int level)if (!inc)return ; -while ((token =next_token (inc,NULL ))) { +while ((token =next_token (inc,NULL ,NULL ))) {if (token[0 ] =='#' ) { hash =1 ;continue ;
@@ -907,6 +956,47 @@ static void load_internal_macros(void)fprintf (stderr,"END PREDEFINED MACROS\n" ); } +/* +* Add groups derived from the source file path. +* +* Groups are the two nearest parent directories (immediate parent +* first), skipping 'kernel' as it's too generic: +* +* testcases/kernel/syscalls/clone/clone01.c -> clone, syscalls +* testcases/kernel/kvm/kvm_pagefault01.c -> kvm +* testcases/cve/cve-2017-16939.c -> cve +*/ +static void add_path_groups (struct data_node *groups,const char *fname) +{ +char *buf; +char *dirs[8 ]; +int ndirs =0 ; +char *p; + +if (strncmp (fname,"testcases/" ,10 )) +return ; + + buf =strdup (fname +10 ); +if (!buf) +return ; + + p =strtok (buf,"/" ); +while (p && ndirs <8 ) { + dirs[ndirs++] = p; + p =strtok (NULL ,"/" ); + } + +/* Last element is the filename, skip it */ + ndirs--; + +if (ndirs >=1 ) +add_group (groups, dirs[ndirs -1 ]); +if (ndirs >=2 ) +add_group (groups, dirs[ndirs -2 ]); + +free (buf); +} +static struct data_node *parse_file (const char *fname) {int state =0 , found =0 ;
@@ -923,15 +1013,18 @@ static struct data_node *parse_file(const char *fname)struct data_node *res =data_node_hash ();struct data_node *doc =data_node_array (); +struct data_node *groups =data_node_array (); + +add_path_groups (groups, fname);load_internal_macros (); -while ((token =next_token (f, doc))) { +while ((token =next_token (f, doc, groups))) {if (state <6 && !strcmp (tokens[state], token)) { state++; }else {if (token[0 ] =='#' ) { - token =next_token (f, doc); + token =next_token (f, doc, groups);if (token) {if (!strcmp (token,"define" ))parse_macro (f);
@@ -948,7 +1041,7 @@ static struct data_node *parse_file(const char *fname)continue ; found =1 ; -parse_test_struct (f, doc, res); +parse_test_struct (f, doc, groups, res); }if (data_node_array_len (doc)) {
@@ -958,6 +1051,11 @@ static struct data_node *parse_file(const char *fname)data_node_free (doc); } +if (data_node_array_len (groups)) +data_node_hash_add (res,"groups" , groups); +else +data_node_free (groups); +fclose (f);if (!found) {
@@ -985,7 +1083,7 @@ static void parse_must_files(void)if (!f)continue ; -while ((token =next_token (f,NULL ))) { +while ((token =next_token (f,NULL ,NULL ))) {if (!strcmp (token,"define" ))parse_macro (f); }
@@ -1238,6 +1336,7 @@ int main(int argc, char *argv[]) }data_node_hash_add (res,"fname" ,data_node_string (argv[optind])); +printf (" \"%s\": " ,strip_name (argv[optind]));data_to_json (res, stdout,2 );data_node_free (res);
metadata/tests/groups.c new file +11 -0
@@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +/*\ +* Test for @groups tag parsing. +* +* @groups stress regression +* @groups smoke +*/ + +static struct tst_test test = { +};
metadata/tests/groups.c.json new file +12 -0
@@ -0,0 +1,12 @@ + "groups": { + "doc": [ + "Test for @groups tag parsing.", + "" + ], + "groups": [ + "stress", + "regression", + "smoke" + ], + "fname": "groups.c" + }
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] metadata: add tests grouping support
Hi Andrea,
Quoted 1 line · Andrea Cervesato
metadata: add tests grouping support
--- [PATCH 1/2] ---
metadata/metaparse.c static const char *eat_asterisk_space(const char *c) · line 83
Quoted 7 lines
metadata/metaparse.c +6
-0+#define GROUPS_TAG "groups" +static int parse_groups (struct data_node *groups,char *line) +{ + s = (char *)eat_asterisk_space (line); +if (strncmp (s,GROUPS_TAG ,sizeof (GROUPS_TAG ) -1 )) +return 0 ;
After eat_asterisk_space() strips the leading " * " from a doc comment line, the string still begins with '@' (e.g. "@groups stress regression"). The strncmp therefore compares "@group" against "groups", which never matches.
Should GROUPS_TAG be "@groups" instead?
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 1/2] metadata: add tests grouping support
In reply to Andrea CervesatoHi!
Quoted 42 lines
Signed-off-by Andrea Cervesato <[email protected]>--- metadata/metaparse.c | 159 +++++++++++++++++++++++++++++++++++-------- metadata/tests/groups.c | 11 +++ metadata/tests/groups.c.json | 12 ++++ 3 files changed, 152 insertions(+), 30 deletions(-)metadata/metaparse.c +19
-1@@ -17,6 +17,7 @@#include "data_storage.h" #define INCLUDE_PATH_MAX 5 +#define GROUPS_TAG "groups"static int verbose;static char *cmdline_includepath[INCLUDE_PATH_MAX ];@@ -50,7 +51,49 @@ static const char *eat_asterisk_space(const char *c)return c; } -static void multiline_comment (FILE *f,struct data_node *doc) +/* +* Add a group to the groups array, skipping 'kernel' as it's too generic. +* Returns 0 if no group was added, 1 otherwise. +*/ +static int add_group (struct data_node *groups,const char *name) +{ +if (name &&strcmp (name,"kernel" )) { +data_node_array_add (groups,data_node_string (name)); +return 1 ; + } + +return 0 ; +} + +/* +* Parse a '@groups foo bar baz' doc comment line, adding each +* whitespace-separated name to the groups array. Returns 1 if the line +* was a @groups tag (and should be consumed), 0 otherwise.
metadata/metaparse.c static const char *eat_asterisk_space(const char *c) · line 81
Quoted 10 lines
metadata/metaparse.c +10
-0+*/ +static int parse_groups (struct data_node *groups,char *line) +{ +char *s; +char *name; + +if (!groups) +return 0 ; + + s = (char *)eat_asterisk_space (line);
It's way cleaner to drop the const from the eat_asterisk_space() fuction than this ugly cast.
metadata/metaparse.c static const char *eat_asterisk_space(const char *c) · line 87
Quoted 6 lines
metadata/metaparse.c +6
-0+if (strncmp (s,GROUPS_TAG ,sizeof (GROUPS_TAG ) -1 )) +return 0 ; + + s +=sizeof (GROUPS_TAG ) -1 ; +if (*s && *s !=' ' && *s !='\t' ) +return 0 ;
I guess that we should WARN() here about empty groups tag and return 1 so that it's "consumed".
Quoted 224 lines
metadata/metaparse.c +52
-25+for (name =strtok (s," \t" ); name; name =strtok (NULL ," \t" )) +add_group (groups, name); + +return 1 ; +} + +static void multiline_comment (FILE *f,struct data_node *doc, +struct data_node *groups) {int c;int state =0 ;@@ -62,12 +105,14 @@ static void multiline_comment(FILE *f, struct data_node *doc)if (doc) {if (c =='\n' ) { -struct data_node *line; +char *str; buf[bufp] =0 ; - line =data_node_string (eat_asterisk_space (buf)); -if (data_node_array_add (doc, line)) -WARN ("doc string comment truncated" ); + str = (char *)eat_asterisk_space (buf); bufp =0 ; +if (parse_groups (groups, str)) +continue ; +if (data_node_array_add (doc,data_node_string (str))) +WARN ("doc string comment truncated" );continue ; }@@ -100,7 +145,8 @@ static void multiline_comment(FILE *f, struct data_node *doc)static const char doc_prefix[] ="\\\n" ; -static void maybe_doc_comment (FILE *f,struct data_node *doc) +static void maybe_doc_comment (FILE *f,struct data_node *doc, +struct data_node *groups) {int c, i;@@ -113,14 +159,15 @@ static void maybe_doc_comment(FILE *f, struct data_node *doc)if (c =='*' )ungetc (c, f); -multiline_comment (f,NULL ); +multiline_comment (f,NULL ,NULL );return ; } -multiline_comment (f, doc); +multiline_comment (f, doc, groups); } -static void maybe_comment (FILE *f,struct data_node *doc) +static void maybe_comment (FILE *f,struct data_node *doc, +struct data_node *groups) {int c =getc (f);@@ -129,7 +176,7 @@ static void maybe_comment(FILE *f, struct data_node *doc)remove_to_newline (f);break ;case '*' : -maybe_doc_comment (f, doc); +maybe_doc_comment (f, doc, groups);break ;default :ungetc (c, f);@@ -137,7 +184,8 @@ static void maybe_comment(FILE *f, struct data_node *doc) } } -static char *next_token2 (FILE *f,char *buf,size_t buf_len,struct data_node *doc) +static char *next_token2 (FILE *f,char *buf,size_t buf_len, +struct data_node *doc,struct data_node *groups) {size_t i =0 ;int c;@@ -194,7 +242,7 @@ static char *next_token2(FILE *f, char *buf, size_t buf_len, struct data_node *d buf[i++] = c;break ;case '/' : -maybe_comment (f, doc); +maybe_comment (f, doc, groups);break ;case '"' : in_str =1 ;@@ -216,11 +264,11 @@ exit:return buf; } -static char *next_token (FILE *f,struct data_node *doc) +static char *next_token (FILE *f,struct data_node *doc,struct data_node *groups) {static char buf[4096 ]; -return next_token2 (f, buf,sizeof (buf), doc); +return next_token2 (f, buf,sizeof (buf), doc, groups); }static FILE *open_file (const char *dir,const char *fname)@@ -383,7 +431,7 @@ static int array_is_hash(FILE *f)int in_id =1 ;char *token; -while ((token =next_token (f,NULL ))) { +while ((token =next_token (f,NULL ,NULL ))) {if (!strcmp (token,"}" )) {if (in_id && !comma_last)@@ -402,7 +450,7 @@ static int array_is_hash(FILE *f)int level =1 ;for (;;) { - token =next_token (f,NULL ); + token =next_token (f,NULL ,NULL );if (!token) goto ret;@@ -453,7 +501,7 @@ static int parse_array(FILE *f, const char *arr_id, struct data_node **ret) *ret =data_node_array ();for (;;) { -if (!(token =next_token (f,NULL ))) +if (!(token =next_token (f,NULL ,NULL )))return 1 ;if (!strcmp (token,"{" )) {@@ -529,14 +577,14 @@ static int parse_get_array_len(FILE *f)const char *token;int cnt =0 , depth =0 , prev_comma =0 ; -if (!(token =next_token (f,NULL ))) +if (!(token =next_token (f,NULL ,NULL )))return 0 ;if (strcmp (token,"{" ))return 0 ;for (;;) { -if (!(token =next_token (f,NULL ))) +if (!(token =next_token (f,NULL ,NULL )))return 0 ;if (!strcmp (token,"{" ))@@ -565,7 +613,7 @@ static void look_for_array_size(FILE *f, const char *arr_id, struct data_node **int prev_buf =1 ;for (;;) { -if (!(token =next_token2 (f, buf[cur_buf],sizeof (buf[cur_buf]),NULL ))) +if (!(token =next_token2 (f, buf[cur_buf],sizeof (buf[cur_buf]),NULL ,NULL )))break ;if (!strcmp (token,"=" ) && !strcmp (buf[prev_buf], arr_id)) {@@ -595,13 +643,13 @@ static int parse_array_size(FILE *f, struct data_node **res) *res =NULL ; -if (!(token =next_token (f,NULL ))) +if (!(token =next_token (f,NULL ,NULL )))return 1 ;if (strcmp (token,"(" ))return 1 ; -if (!(token =next_token (f,NULL ))) +if (!(token =next_token (f,NULL ,NULL )))return 1 ; arr_id =strdup (token);@@ -621,7 +669,7 @@ static int parse_array_size(FILE *f, struct data_node **res)rewind (f);for (;;) { -if (!(token =next_token (f,NULL ))) +if (!(token =next_token (f,NULL ,NULL )))break ;if (token[0 ] =='#' ) {@@ -654,7 +702,8 @@ static int parse_array_size(FILE *f, struct data_node **res)return 0 ; } -static int parse_test_struct (FILE *f,struct data_node *doc,struct data_node *node) +static int parse_test_struct (FILE *f,struct data_node *doc, +struct data_node *groups,struct data_node *node) {char *token;char *id =NULL ;@@ -662,7 +711,7 @@ static int parse_test_struct(FILE *f, struct data_node *doc, struct data_node *nstruct data_node *ret;for (;;) { -if (!(token =next_token (f, doc))) +if (!(token =next_token (f, doc, groups)))return 1 ;if (!strcmp (token,"}" ))@@ -842,7 +891,7 @@ static void parse_include_macros(FILE *f, int level)if (!inc)return ; -while ((token =next_token (inc,NULL ))) { +while ((token =next_token (inc,NULL ,NULL ))) {if (token[0 ] =='#' ) { hash =1 ;continue ;@@ -907,6 +956,47 @@ static void load_internal_macros(void)fprintf (stderr,"END PREDEFINED MACROS\n" ); } +/* +* Add groups derived from the source file path. +* +* Groups are the two nearest parent directories (immediate parent +* first), skipping 'kernel' as it's too generic: +* +* testcases/kernel/syscalls/clone/clone01.c -> clone, syscalls +* testcases/kernel/kvm/kvm_pagefault01.c -> kvm +* testcases/cve/cve-2017-16939.c -> cve +*/ +static void add_path_groups (struct data_node *groups,const char *fname) +{ +char *buf;
metadata/metaparse.c static void load_internal_macros(void) · line 981
Quoted 10 lines
metadata/metaparse.c +10
-0+char *dirs[8 ]; +int ndirs =0 ; +char *p; + +if (strncmp (fname,"testcases/" ,10 )) +return ; + + buf =strdup (fname +10 ); +if (!buf) +return ;
We should do fprintf(stderr, "Allocation failed!\n"); exit(1); here instead of silently dropping the tags if the strdup failed.
Maybe we should add ERR() macro that does print a message and calls exit(1) since we have that pattern in many places, but that is a completely unrelated refactor.
Quoted 51 lines
metadata/metaparse.c +23
-3+ p =strtok (buf,"/" ); +while (p && ndirs <8 ) { + dirs[ndirs++] = p; + p =strtok (NULL ,"/" ); + } + +/* Last element is the filename, skip it */ + ndirs--; + +if (ndirs >=1 ) +add_group (groups, dirs[ndirs -1 ]); +if (ndirs >=2 ) +add_group (groups, dirs[ndirs -2 ]); + +free (buf); +} +static struct data_node *parse_file (const char *fname) {int state =0 , found =0 ;@@ -923,15 +1013,18 @@ static struct data_node *parse_file(const char *fname)struct data_node *res =data_node_hash ();struct data_node *doc =data_node_array (); +struct data_node *groups =data_node_array (); + +add_path_groups (groups, fname);load_internal_macros (); -while ((token =next_token (f, doc))) { +while ((token =next_token (f, doc, groups))) {if (state <6 && !strcmp (tokens[state], token)) { state++; }else {if (token[0 ] =='#' ) { - token =next_token (f, doc); + token =next_token (f, doc, groups);if (token) {if (!strcmp (token,"define" ))parse_macro (f);@@ -948,7 +1041,7 @@ static struct data_node *parse_file(const char *fname)continue ; found =1 ; -parse_test_struct (f, doc, res); +parse_test_struct (f, doc, groups, res); }if (data_node_array_len (doc)) {
metadata/metaparse.c static struct data_node *parse_file(const char *fname) · line 1057
Quoted 7 lines
metadata/metaparse.c +4
-0@@ -958,6 +1051,11 @@ static struct data_node *parse_file(const char *fname)data_node_free (doc); } +if (data_node_array_len (groups)) +data_node_hash_add (res,"groups" , groups); +else +data_node_free (groups);
The fuction that adds groups from path will add at least one group, so this can be just data_node_hash_add(res, "groups", groups).
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 2/2 doc: conf.py: Show groups in test catalog
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Display the groups field from metadata in the generated test catalog pages. Groups appear after the source link and before the test description.
--- doc/conf.py | 10 ++++++++++ 1 file changed, 10 insertions(+)
doc/conf.py +10 -0
@@ -394,6 +394,7 @@ def _generate_setup_table(keys): 'needs_checkpoints', 'forks_child', 'tags', + 'groups', ] my_keys = {k: v for k, v in keys.items() if k not in exclude} if len(my_keys) == 0:
@@ -482,6 +483,15 @@ def generate_test_catalog(_): '' ]) + # groups information + groups = conf.get('groups', None) + if groups: + text.extend([ + '', + f"**Groups**: {', '.join(groups)}", + '' + ]) + # test description desc = conf.get('doc', None) if desc:
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 2/2] doc: conf.py: Show groups in test catalog
Hi!
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp