Hi Daniel, > > I like it! This seems to make a lot of logic simpler (and from the > > sounds makes Jeremy's proposed module patch easier?). > > This would make the subsequent cleanup easier. > > Jemery, correct me if I misread, but it sounded like you were thinking > of leaving the current kunit_suite*** layout until afterwards. Then > we'd flatten it as a cleanup. Yep, that was my rough plan. From the current situation: An object (module or built-in) defines a: kunit_test_suite(my_suite) [or, equivalently, a kunit_test_suites(&my_suite). The only place that I can see where we add more than one suite through kunit_test_suites is the kunit code, so let's ignore that for now..] That expands to: static struct kunit_suite *unique_array[] = { &my_suite, NULL }; static struct kunit_suite **unique_suites __used __section(".kunit_test_suites") = unique_array; [assume actual unique values for unique_array & unique_suites] So the .kunit_test_suites section content ends up being: an array of pointers to (null-terminated) arrays of pointers to struct kunit_suite. But those latter arrays only have one entry anyway. Once we're reading the suites out of the section, we have the section size too, so can determine the number of "things" (suites/arrays-of-suites/whatever) from that. So, given we only have one entry in the array, we can probably drop the null-termination, and expand the kunit_test_suite() macro to: kunit_test_suite(my_suite) -> static struct kunit_suite *unique_array[] = { &my_suite }; kunit_test_suites_for_module(unique_array); static struct kunit_suite **unique_suites __used __section(".kunit_test_suites") = unique_array; Then, the array becomes pretty pointless, so we can reduce that to: kunit_test_suite(my_suite) -> static struct kunit_suite *unique_array = &my_suite; kunit_test_suites_for_module(unique_array); static struct kunit_suite *unique_suites __used __section(".kunit_test_suites") = unique_array; But then there's no need for the double pointers, so we could just do: kunit_test_suite(my_suite) -> static struct kunit_suite *unique_suite __used __section(".kunit_test_suites") = &my_suite; Resulting in the .kunit_test_suites section just being a set of contiguous pointers to struct kunit_suite. We get the number of suites from the section size. [We could go one step further and put the suites themselves in .kunit_test_suites, rather than the pointers. However, the downside there is that we'd need macros for the suite declarations, which isn't as clean] Modules with multiple suites (currently: kunit itself) can just have multiple occurrences of kunit_test_suite(), as they no longer conflict, and we'd no longer need kunit_test_suites() at all. That was my thinking, anyway. I think it probably makes sense to do that cleanup after the section patch, as that means we don't need any post-processing on the suites arrays. Cheers, Jeremy