While the use of the ! and ~ characters currently works, it is a bit
hacky, and conflicts with later patches that will require the
arguments to ll_entry_start() to be allowed at least as assembly
identifiers.

linker_lists.rst actually describes how one can do what the test
framework wants to do: We have one "outer" list, ut, with individual
"inner" lists (each suite). In order to be able to delineate the outer
list using the ordinary ll_ helpers, we just have to make sure that
all the inner lists use the section name ut_2_<suite> instead of
ut_<suite>.

Signed-off-by: Rasmus Villemoes <[email protected]>
---
 include/test/test.h | 15 +++++++--------
 test/cmd_ut.c       |  4 ++--
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/include/test/test.h b/include/test/test.h
index 0f2b68a5dee..6423f3486be 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -142,7 +142,7 @@ struct unit_test {
  * @_suite:    name of the test suite concatenated with "_test"
  */
 #define UNIT_TEST(_name, _flags, _suite)                               \
-       ll_entry_declare(struct unit_test, _name, ut_ ## _suite) = {    \
+       ll_entry_declare(struct unit_test, _name, ut_2_ ## _suite) = {  \
                .file = __FILE__,                                       \
                .name = #_name,                                         \
                .flags = _flags,                                        \
@@ -151,7 +151,7 @@ struct unit_test {
 
 /* init function for unit-test suite (the 'A' makes it first) */
 #define UNIT_TEST_INIT(_name, _flags, _suite)                          \
-       ll_entry_declare(struct unit_test, A ## _name, ut_ ## _suite) = {       
\
+       ll_entry_declare(struct unit_test, A ## _name, ut_2_ ## _suite) = {     
\
                .file = __FILE__,                                       \
                .name = #_name,                                         \
                .flags = (_flags) | UTF_INIT,                           \
@@ -160,7 +160,7 @@ struct unit_test {
 
 /* uninit function for unit-test suite (the 'aaa' makes it last) */
 #define UNIT_TEST_UNINIT(_name, _flags, _suite)                                
\
-       ll_entry_declare(struct unit_test, zzz ## _name, ut_ ## _suite) = { \
+       ll_entry_declare(struct unit_test, zzz ## _name, ut_2_ ## _suite) = { \
                .file = __FILE__,                                       \
                .name = #_name,                                         \
                .flags = (_flags) | UTF_UNINIT,                         \
@@ -169,13 +169,12 @@ struct unit_test {
 
 /* Get the start of a list of unit tests for a particular suite */
 #define UNIT_TEST_SUITE_START(_suite) \
-       ll_entry_start(struct unit_test, ut_ ## _suite)
+       ll_entry_start(struct unit_test, ut_2_ ## _suite)
 #define UNIT_TEST_SUITE_COUNT(_suite) \
-       ll_entry_count(struct unit_test, ut_ ## _suite)
+       ll_entry_count(struct unit_test, ut_2_ ## _suite)
 
-/* Use ! and ~ so that all tests will be sorted between these two values */
-#define UNIT_TEST_ALL_START()  ll_entry_start(struct unit_test, ut_!)
-#define UNIT_TEST_ALL_END()    ll_entry_start(struct unit_test, ut_~)
+#define UNIT_TEST_ALL_START()  ll_entry_start(struct unit_test, ut)
+#define UNIT_TEST_ALL_END()    ll_entry_end(struct unit_test, ut)
 #define UNIT_TEST_ALL_COUNT()  (UNIT_TEST_ALL_END() - UNIT_TEST_ALL_START())
 
 /* Sizes for devres tests */
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 44e5fdfdaa6..9d74f091138 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -36,8 +36,8 @@ static int do_ut_info(bool show_suites);
 
 /* declare linker-list symbols for the start and end of a suite */
 #define SUITE_DECL(_name) \
-       ll_start_decl(suite_start_ ## _name, struct unit_test, ut_ ## _name); \
-       ll_end_decl(suite_end_ ## _name, struct unit_test, ut_ ## _name)
+       ll_start_decl(suite_start_ ## _name, struct unit_test, ut_2_ ## _name); 
\
+       ll_end_decl(suite_end_ ## _name, struct unit_test, ut_2_ ## _name)
 
 /* declare a test suite which can be run directly without a subcommand */
 #define SUITE(_name, _help) { \
-- 
2.54.0

Reply via email to