17
17
#include <init.h>
18
18
#include <stdbool.h>
19
19
20
- #if defined(CONFIG_USERSPACE ) || defined(CONFIG_TEST_USERSPACE )
21
- #define __USERSPACE_FLAGS (K_USER)
22
- #else
23
- #define __USERSPACE_FLAGS (0)
24
- #endif
25
-
26
20
#ifdef __cplusplus
27
21
extern "C" {
28
22
#endif
@@ -55,41 +49,41 @@ struct ztest_suite_stats {
55
49
*/
56
50
struct ztest_suite_node {
57
51
/** The name of the test suite. */
58
- const char * const name ;
52
+ const char * name ;
59
53
/**
60
54
* Setup function to run before running this suite
61
55
*
62
56
* @return Pointer to the data structure that will be used throughout this test suite
63
57
*/
64
- void * (* const setup )(void );
58
+ void * (* setup )(void );
65
59
/**
66
60
* Function to run before each test in this suite
67
61
*
68
62
* @param data The test suite's data returned from setup()
69
63
*/
70
- void (* const before )(void * data );
64
+ void (* before )(void * data );
71
65
/**
72
66
* Function to run after each test in this suite
73
67
*
74
68
* @param data The test suite's data returned from setup()
75
69
*/
76
- void (* const after )(void * data );
70
+ void (* after )(void * data );
77
71
/**
78
72
* Teardown function to run after running this suite
79
73
*
80
74
* @param data The test suite's data returned from setup()
81
75
*/
82
- void (* const teardown )(void * data );
76
+ void (* teardown )(void * data );
83
77
/**
84
78
* An optional predicate function to determine if the test should run. If NULL, then the
85
79
* test will only run once on the first attempt.
86
80
*
87
81
* @param state The current state of the test application.
88
82
* @return True if the suite should be run; false to skip.
89
83
*/
90
- bool (* const predicate )(const void * state );
84
+ bool (* predicate )(const void * state );
91
85
/** Stats */
92
- struct ztest_suite_stats * const stats ;
86
+ struct ztest_suite_stats stats ;
93
87
};
94
88
95
89
extern struct ztest_suite_node _ztest_suite_node_list_start [];
@@ -109,18 +103,17 @@ extern struct ztest_suite_node _ztest_suite_node_list_end[];
109
103
* @param after_fn The function to call after each unit test in this suite
110
104
* @param teardown_fn The function to call after running all the tests in this suite
111
105
*/
112
- #define ZTEST_SUITE (SUITE_NAME , PREDICATE , setup_fn , before_fn , after_fn , teardown_fn ) \
113
- static struct ztest_suite_stats UTIL_CAT(z_ztest_test_node_stats_, SUITE_NAME); \
114
- static const STRUCT_SECTION_ITERABLE(ztest_suite_node, \
115
- UTIL_CAT(z_ztest_test_node_, SUITE_NAME)) = { \
116
- .name = STRINGIFY(SUITE_NAME), \
117
- .setup = (setup_fn), \
118
- .before = (before_fn), \
119
- .after = (after_fn), \
120
- .teardown = (teardown_fn), \
121
- .predicate = PREDICATE, \
122
- .stats = &UTIL_CAT(z_ztest_test_node_stats_, SUITE_NAME), \
106
+ #define ZTEST_SUITE (SUITE_NAME , PREDICATE , setup_fn , before_fn , after_fn , teardown_fn ) \
107
+ static STRUCT_SECTION_ITERABLE(ztest_suite_node, \
108
+ UTIL_CAT(z_ztest_test_node_, SUITE_NAME)) = { \
109
+ .name = STRINGIFY(SUITE_NAME), \
110
+ .setup = (setup_fn), \
111
+ .before = (before_fn), \
112
+ .after = (after_fn), \
113
+ .teardown = (teardown_fn), \
114
+ .predicate = PREDICATE, \
123
115
}
116
+
124
117
/**
125
118
* Run the registered unit tests which return true from their pragma function.
126
119
*
@@ -247,7 +240,7 @@ static inline void unit_test_noop(void)
247
240
* @param suite The name of the test suite to attach this test
248
241
* @param fn The test function to call.
249
242
*/
250
- #define ZTEST_USER (suite , fn ) Z_ZTEST(suite, fn, __USERSPACE_FLAGS )
243
+ #define ZTEST_USER (suite , fn ) Z_ZTEST(suite, fn, COND_CODE_1(CONFIG_USERSPACE, (K_USER), (0)) )
251
244
252
245
/**
253
246
* @brief Define a test function
@@ -269,7 +262,7 @@ static inline void unit_test_noop(void)
269
262
* @param suite The name of the test suite to attach this test
270
263
* @param fn The test function to call.
271
264
*/
272
- #define ZTEST_USER_F (suite , fn ) Z_ZTEST_F(suite, fn, __USERSPACE_FLAGS )
265
+ #define ZTEST_USER_F (suite , fn ) Z_ZTEST_F(suite, fn, COND_CODE_1(CONFIG_USERSPACE, (K_USER), (0)) )
273
266
274
267
/**
275
268
* @brief Test rule callback function signature
0 commit comments