@@ -52,12 +52,14 @@ static char *eat_asterisk_space(char *c)
5252}
5353
5454/*
55- * Add a group to the groups array, skipping 'kernel' as it's too generic.
56- * Returns 0 if no group was added, 1 otherwise.
55+ * Add a group to the groups array, skipping path components that are too
56+ * generic ('kernel') or assigned from a more reliable source ('cve', which
57+ * is derived from the CVE tag instead). Returns 0 if no group was added,
58+ * 1 otherwise.
5759 */
5860static int add_group (struct data_node * groups , const char * name )
5961{
60- if (name && strcmp (name , "kernel" )) {
62+ if (name && strcmp (name , "kernel" ) && strcmp ( name , "cve" ) ) {
6163 data_node_array_add (groups , data_node_string (name ));
6264 return 1 ;
6365 }
@@ -971,11 +973,11 @@ static void load_internal_macros(void)
971973 * Add groups derived from the source file path.
972974 *
973975 * Groups are the two nearest parent directories (immediate parent
974- * first), skipping 'kernel' as it's too generic:
976+ * first), skipping 'kernel' (too generic) and 'cve' (assigned from the
977+ * CVE tag instead, see add_tag_groups()):
975978 *
976979 * testcases/kernel/syscalls/clone/clone01.c -> clone, syscalls
977980 * testcases/kernel/kvm/kvm_pagefault01.c -> kvm
978- * testcases/cve/cve-2017-16939.c -> cve
979981 */
980982static void add_path_groups (struct data_node * groups , const char * fname )
981983{
@@ -1010,6 +1012,38 @@ static void add_path_groups(struct data_node *groups, const char *fname)
10101012 free (buf );
10111013}
10121014
1015+ /*
1016+ * Add group to specific test tags.
1017+ */
1018+ static void add_tag_groups (struct data_node * groups , struct data_node * res )
1019+ {
1020+ struct data_node * tags = data_node_hash_get (res , "tags" );
1021+ int has_cve = 0 , has_regression = 0 ;
1022+
1023+ if (!tags || tags -> type != DATA_ARRAY )
1024+ return ;
1025+
1026+ for (unsigned int i = 0 ; i < data_node_array_len (tags ); i ++ ) {
1027+ struct data_node * tag = tags -> array .array [i ];
1028+ struct data_node * name ;
1029+
1030+ if (tag -> type != DATA_ARRAY || !data_node_array_len (tag ))
1031+ continue ;
1032+
1033+ name = tag -> array .array [0 ];
1034+ if (name -> type != DATA_STRING )
1035+ continue ;
1036+
1037+ if (!has_cve && !strcmp (name -> string .val , "CVE" )) {
1038+ data_node_array_add (groups , data_node_string ("cve" ));
1039+ has_cve = 1 ;
1040+ } else if (!has_regression && !strcmp (name -> string .val , "linux-git" )) {
1041+ data_node_array_add (groups , data_node_string ("regression" ));
1042+ has_regression = 1 ;
1043+ }
1044+ }
1045+ }
1046+
10131047static struct data_node * parse_file (const char * fname )
10141048{
10151049 int state = 0 , found = 0 ;
@@ -1064,6 +1098,8 @@ static struct data_node *parse_file(const char *fname)
10641098 data_node_free (doc );
10651099 }
10661100
1101+ add_tag_groups (groups , res );
1102+
10671103 /*
10681104 * Always emit groups, even when empty: tests outside testcases/
10691105 * and files whose only parent dir is 'kernel' produce no groups.
0 commit comments