tree:
https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git
kunit-fixes
head: c1610aae495bae98319445d322a875556bbe3cba
commit: c9d80ffc5a0a30955de0b8c5c46a05906d417800 [21/24] kunit: add unit test for
filtering suites by names
config: m68k-randconfig-r012-20210622 (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
#
https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git...
git remote add kselftest
https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git
git fetch --no-tags kselftest kunit-fixes
git checkout c9d80ffc5a0a30955de0b8c5c46a05906d417800
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All errors (new ones prefixed by >>):
lib/kunit/executor.c:26:1: error: expected identifier or '(' before '+'
token
26 | +kunit_filter_subsuite(struct kunit_suite * const * const subsuite,
| ^
lib/kunit/executor.c: In function 'kunit_filter_suites':
lib/kunit/executor.c:77:23: error: implicit declaration of function
'kunit_filter_subsuite'; did you mean 'kunit_filter_suites'?
[-Werror=implicit-function-declaration]
77 | filtered_subsuite = kunit_filter_subsuite(suite_set->start[i],
filter_glob);
| ^~~~~~~~~~~~~~~~~~~~~
| kunit_filter_suites
lib/kunit/executor.c:77:21: warning: assignment to 'struct kunit_suite *
const*' from 'int' makes pointer from integer without a cast
[-Wint-conversion]
77 | filtered_subsuite = kunit_filter_subsuite(suite_set->start[i],
filter_glob);
| ^
lib/kunit/executor.c: At top level:
> lib/kunit/executor.c:140:10: fatal error: executor_test.c: No
such file or directory
140 | #include "executor_test.c"
| ^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
compilation terminated.
vim +140 lib/kunit/executor.c
59
60 static struct suite_set kunit_filter_suites(const struct suite_set *suite_set,
61 const char *filter_glob)
62 {
63 int i;
64 struct kunit_suite * const **copy, * const *filtered_subsuite;
65 struct suite_set filtered;
66
67 const size_t max = suite_set->end - suite_set->start;
68
69 copy = kmalloc_array(max, sizeof(*filtered.start), GFP_KERNEL);
70 filtered.start = copy;
71 if (!copy) { /* won't be able to run anything, return an empty set */
72 filtered.end = copy;
73 return filtered;
74 }
75
76 for (i = 0; i < max; ++i) {
77 filtered_subsuite =
kunit_filter_subsuite(suite_set->start[i], filter_glob);
78 if
(filtered_subsuite)
79 *copy++ = filtered_subsuite;
80 }
81 filtered.end = copy;
82 return filtered;
83 }
84
85 static void kunit_handle_shutdown(void)
86 {
87 if (!kunit_shutdown)
88 return;
89
90 if (!strcmp(kunit_shutdown, "poweroff"))
91 kernel_power_off();
92 else if (!strcmp(kunit_shutdown, "halt"))
93 kernel_halt();
94 else if (!strcmp(kunit_shutdown, "reboot"))
95 kernel_restart(NULL);
96
97 }
98
99 static void kunit_print_tap_header(struct suite_set *suite_set)
100 {
101 struct kunit_suite * const * const *suites, * const *subsuite;
102 int num_of_suites = 0;
103
104 for (suites = suite_set->start; suites < suite_set->end; suites++)
105 for (subsuite = *suites; *subsuite != NULL; subsuite++)
106 num_of_suites++;
107
108 pr_info("TAP version 14\n");
109 pr_info("1..%d\n", num_of_suites);
110 }
111
112 int kunit_run_all_tests(void)
113 {
114 struct kunit_suite * const * const *suites;
115 struct suite_set suite_set = {
116 .start = __kunit_suites_start,
117 .end = __kunit_suites_end,
118 };
119
120 if (filter_glob_param)
121 suite_set = kunit_filter_suites(&suite_set, filter_glob_param);
122
123 kunit_print_tap_header(&suite_set);
124
125 for (suites = suite_set.start; suites < suite_set.end; suites++)
126 __kunit_test_suites_init(*suites);
127
128 if (filter_glob_param) { /* a copy was made of each array */
129 for (suites = suite_set.start; suites < suite_set.end; suites++)
130 kfree(*suites);
131 kfree(suite_set.start);
132 }
133
134 kunit_handle_shutdown();
135
136 return 0;
137 }
138
139 #if IS_BUILTIN(CONFIG_KUNIT_TEST)
140 #include "executor_test.c"
141 #endif
142
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org