@@ -107,12 +107,12 @@ static int cleanup_test(struct ztest_unit_test *test)
107
107
#ifdef KERNEL
108
108
109
109
#if defined(CONFIG_SMP ) && (CONFIG_MP_MAX_NUM_CPUS > 1 )
110
- #define MAX_NUM_CPUHOLD (CONFIG_MP_MAX_NUM_CPUS - 1)
110
+ #define MAX_NUM_CPUHOLD (CONFIG_MP_MAX_NUM_CPUS - 1)
111
111
#define CPUHOLD_STACK_SZ (512 + CONFIG_TEST_EXTRA_STACK_SIZE)
112
112
113
113
struct cpuhold_pool_item {
114
- struct k_thread thread ;
115
- bool used ;
114
+ struct k_thread thread ;
115
+ bool used ;
116
116
};
117
117
118
118
static struct cpuhold_pool_item cpuhold_pool_items [MAX_NUM_CPUHOLD + 1 ];
@@ -184,10 +184,8 @@ static void cpu_hold(void *arg1, void *arg2, void *arg3)
184
184
cpuhold_spawned = false;
185
185
186
186
cpuhold_pool_items [i ].used = true;
187
- k_thread_create (& cpuhold_pool_items [i ].thread ,
188
- cpuhold_stacks [i ], CPUHOLD_STACK_SZ ,
189
- cpu_hold , k_current_get (),
190
- (void * )(uintptr_t )idx , NULL ,
187
+ k_thread_create (& cpuhold_pool_items [i ].thread , cpuhold_stacks [i ], CPUHOLD_STACK_SZ ,
188
+ cpu_hold , k_current_get (), (void * )(uintptr_t )idx , NULL ,
191
189
K_HIGHEST_THREAD_PRIO , 0 , K_NO_WAIT );
192
190
193
191
/*
@@ -217,7 +215,6 @@ static void cpu_hold(void *arg1, void *arg2, void *arg3)
217
215
k_thread_name_set (k_current_get (), tname );
218
216
}
219
217
220
-
221
218
uint32_t dt , start_ms = k_uptime_get_32 ();
222
219
unsigned int key = arch_irq_lock ();
223
220
@@ -243,8 +240,7 @@ static void cpu_hold(void *arg1, void *arg2, void *arg3)
243
240
* logic views it as one "job") and cause other test failures.
244
241
*/
245
242
dt = k_uptime_get_32 () - start_ms ;
246
- zassert_true (dt < CONFIG_ZTEST_CPU_HOLD_TIME_MS ,
247
- "1cpu test took too long (%d ms)" , dt );
243
+ zassert_true (dt < CONFIG_ZTEST_CPU_HOLD_TIME_MS , "1cpu test took too long (%d ms)" , dt );
248
244
arch_irq_unlock (key );
249
245
}
250
246
#endif /* CONFIG_SMP && (CONFIG_MP_MAX_NUM_CPUS > 1) */
@@ -268,10 +264,9 @@ void z_impl_z_test_1cpu_start(void)
268
264
__ASSERT_NO_MSG (j != -1 );
269
265
270
266
cpuhold_pool_items [j ].used = true;
271
- k_thread_create (& cpuhold_pool_items [j ].thread ,
272
- cpuhold_stacks [j ], CPUHOLD_STACK_SZ ,
273
- cpu_hold , NULL , (void * )(uintptr_t )i , NULL ,
274
- K_HIGHEST_THREAD_PRIO , 0 , K_NO_WAIT );
267
+ k_thread_create (& cpuhold_pool_items [j ].thread , cpuhold_stacks [j ], CPUHOLD_STACK_SZ ,
268
+ cpu_hold , NULL , (void * )(uintptr_t )i , NULL , K_HIGHEST_THREAD_PRIO ,
269
+ 0 , K_NO_WAIT );
275
270
k_sem_take (& cpuhold_sem , K_FOREVER );
276
271
}
277
272
#endif
@@ -292,10 +287,16 @@ void z_impl_z_test_1cpu_stop(void)
292
287
}
293
288
294
289
#ifdef CONFIG_USERSPACE
295
- void z_vrfy_z_test_1cpu_start (void ) { z_impl_z_test_1cpu_start (); }
290
+ void z_vrfy_z_test_1cpu_start (void )
291
+ {
292
+ z_impl_z_test_1cpu_start ();
293
+ }
296
294
#include <zephyr/syscalls/z_test_1cpu_start_mrsh.c>
297
295
298
- void z_vrfy_z_test_1cpu_stop (void ) { z_impl_z_test_1cpu_stop (); }
296
+ void z_vrfy_z_test_1cpu_stop (void )
297
+ {
298
+ z_impl_z_test_1cpu_stop ();
299
+ }
299
300
#include <zephyr/syscalls/z_test_1cpu_stop_mrsh.c>
300
301
#endif /* CONFIG_USERSPACE */
301
302
#endif
@@ -671,10 +672,8 @@ static int run_test(struct ztest_suite_node *suite, struct ztest_unit_test *test
671
672
if (IS_ENABLED (CONFIG_MULTITHREADING )) {
672
673
get_start_time_cyc ();
673
674
k_thread_create (& ztest_thread , ztest_thread_stack ,
674
- K_THREAD_STACK_SIZEOF (ztest_thread_stack ),
675
- test_cb , suite , test , data ,
676
- CONFIG_ZTEST_THREAD_PRIORITY ,
677
- K_INHERIT_PERMS , K_FOREVER );
675
+ K_THREAD_STACK_SIZEOF (ztest_thread_stack ), test_cb , suite , test ,
676
+ data , CONFIG_ZTEST_THREAD_PRIORITY , K_INHERIT_PERMS , K_FOREVER );
678
677
679
678
k_thread_access_grant (& ztest_thread , suite , test , suite -> stats );
680
679
if (test -> name != NULL ) {
@@ -765,8 +764,8 @@ struct ztest_unit_test *z_ztest_get_next_test(const char *suite, struct ztest_un
765
764
}
766
765
767
766
#if CONFIG_ZTEST_SHUFFLE
768
- static void z_ztest_shuffle (bool shuffle , void * dest [], intptr_t start ,
769
- size_t num_items , size_t element_size )
767
+ static void z_ztest_shuffle (bool shuffle , void * dest [], intptr_t start , size_t num_items ,
768
+ size_t element_size )
770
769
{
771
770
/* Initialize dest array */
772
771
for (size_t i = 0 ; i < num_items ; ++ i ) {
@@ -789,8 +788,8 @@ static void z_ztest_shuffle(bool shuffle, void *dest[], intptr_t start,
789
788
}
790
789
#endif
791
790
792
- static int z_ztest_run_test_suite_ptr (struct ztest_suite_node * suite ,
793
- bool shuffle , int suite_iter , int case_iter )
791
+ static int z_ztest_run_test_suite_ptr (struct ztest_suite_node * suite , bool shuffle , int suite_iter ,
792
+ int case_iter )
794
793
{
795
794
struct ztest_unit_test * test = NULL ;
796
795
void * data = NULL ;
@@ -836,8 +835,8 @@ static int z_ztest_run_test_suite_ptr(struct ztest_suite_node *suite,
836
835
837
836
memset (tests_to_run , 0 , ZTEST_TEST_COUNT * sizeof (struct ztest_unit_test * ));
838
837
z_ztest_shuffle (shuffle , (void * * )tests_to_run ,
839
- (intptr_t )_ztest_unit_test_list_start ,
840
- ZTEST_TEST_COUNT , sizeof (struct ztest_unit_test ));
838
+ (intptr_t )_ztest_unit_test_list_start , ZTEST_TEST_COUNT ,
839
+ sizeof (struct ztest_unit_test ));
841
840
for (size_t j = 0 ; j < ZTEST_TEST_COUNT ; ++ j ) {
842
841
test = tests_to_run [j ];
843
842
/* Make sure that the test belongs to this suite */
@@ -902,8 +901,8 @@ static int z_ztest_run_test_suite_ptr(struct ztest_suite_node *suite,
902
901
903
902
int z_ztest_run_test_suite (const char * name , bool shuffle , int suite_iter , int case_iter )
904
903
{
905
- return z_ztest_run_test_suite_ptr (ztest_find_test_suite (name ),
906
- shuffle , suite_iter , case_iter );
904
+ return z_ztest_run_test_suite_ptr (ztest_find_test_suite (name ), shuffle , suite_iter ,
905
+ case_iter );
907
906
}
908
907
909
908
#ifdef CONFIG_USERSPACE
@@ -979,12 +978,10 @@ static void __ztest_show_suite_summary_oneline(struct ztest_suite_node *suite)
979
978
}
980
979
981
980
TC_SUMMARY_PRINT ("SUITE %s - %3d.%02d%% [%s]: pass = %d, fail = %d, "
982
- "skip = %d, total = %d duration = %u.%03u seconds\n" ,
983
- TC_RESULT_TO_STR (suite_result ),
984
- passrate_major , passrate_minor ,
985
- suite -> name , distinct_pass , distinct_fail ,
986
- distinct_skip , distinct_total ,
987
- suite_duration_worst_ms / 1000 , suite_duration_worst_ms % 1000 );
981
+ "skip = %d, total = %d duration = %u.%03u seconds\n" ,
982
+ TC_RESULT_TO_STR (suite_result ), passrate_major , passrate_minor ,
983
+ suite -> name , distinct_pass , distinct_fail , distinct_skip , distinct_total ,
984
+ suite_duration_worst_ms / 1000 , suite_duration_worst_ms % 1000 );
988
985
flush_log ();
989
986
}
990
987
@@ -1010,20 +1007,18 @@ static void __ztest_show_suite_summary_verbose(struct ztest_suite_node *suite)
1010
1007
}
1011
1008
1012
1009
if (tc_result == TC_FLAKY ) {
1013
- TC_SUMMARY_PRINT (" - %s - [%s.%s] - (Failed %d of %d attempts)"
1014
- " - duration = %u.%03u seconds\n" ,
1015
- TC_RESULT_TO_STR (tc_result ),
1016
- test -> test_suite_name , test -> name ,
1017
- test -> stats -> run_count - test -> stats -> pass_count ,
1018
- test -> stats -> run_count ,
1019
- test -> stats -> duration_worst_ms / 1000 ,
1020
- test -> stats -> duration_worst_ms % 1000 );
1010
+ TC_SUMMARY_PRINT (
1011
+ " - %s - [%s.%s] - (Failed %d of %d attempts)"
1012
+ " - duration = %u.%03u seconds\n" ,
1013
+ TC_RESULT_TO_STR (tc_result ), test -> test_suite_name , test -> name ,
1014
+ test -> stats -> run_count - test -> stats -> pass_count ,
1015
+ test -> stats -> run_count , test -> stats -> duration_worst_ms / 1000 ,
1016
+ test -> stats -> duration_worst_ms % 1000 );
1021
1017
} else {
1022
1018
TC_SUMMARY_PRINT (" - %s - [%s.%s] duration = %u.%03u seconds\n" ,
1023
- TC_RESULT_TO_STR (tc_result ),
1024
- test -> test_suite_name , test -> name ,
1025
- test -> stats -> duration_worst_ms / 1000 ,
1026
- test -> stats -> duration_worst_ms % 1000 );
1019
+ TC_RESULT_TO_STR (tc_result ), test -> test_suite_name ,
1020
+ test -> name , test -> stats -> duration_worst_ms / 1000 ,
1021
+ test -> stats -> duration_worst_ms % 1000 );
1027
1022
}
1028
1023
1029
1024
if (flush_frequency % 3 == 0 ) {
@@ -1057,8 +1052,8 @@ static void __ztest_show_suite_summary(void)
1057
1052
flush_log ();
1058
1053
}
1059
1054
1060
- static int __ztest_run_test_suite (struct ztest_suite_node * ptr ,
1061
- const void * state , bool shuffle , int suite_iter , int case_iter )
1055
+ static int __ztest_run_test_suite (struct ztest_suite_node * ptr , const void * state , bool shuffle ,
1056
+ int suite_iter , int case_iter )
1062
1057
{
1063
1058
struct ztest_suite_stats * stats = ptr -> stats ;
1064
1059
int count = 0 ;
@@ -1100,26 +1095,26 @@ int z_impl_ztest_run_test_suites(const void *state, bool shuffle, int suite_iter
1100
1095
__ztest_init_unit_test_result_for_suite (suites_to_run [i ]);
1101
1096
}
1102
1097
for (size_t i = 0 ; i < ZTEST_SUITE_COUNT ; ++ i ) {
1103
- count += __ztest_run_test_suite (suites_to_run [i ],
1104
- state , shuffle , suite_iter , case_iter );
1098
+ count += __ztest_run_test_suite (suites_to_run [i ], state , shuffle , suite_iter ,
1099
+ case_iter );
1105
1100
/* Stop running tests if we have a critical error or if we have a failure and
1106
1101
* FAIL_FAST was set
1107
1102
*/
1108
1103
if (test_status == ZTEST_STATUS_CRITICAL_ERROR ||
1109
- (test_status == ZTEST_STATUS_HAS_FAILURE && FAIL_FAST )) {
1104
+ (test_status == ZTEST_STATUS_HAS_FAILURE && FAIL_FAST )) {
1110
1105
break ;
1111
1106
}
1112
1107
}
1113
1108
#else
1114
1109
for (struct ztest_suite_node * ptr = _ztest_suite_node_list_start ;
1115
- ptr < _ztest_suite_node_list_end ; ++ ptr ) {
1110
+ ptr < _ztest_suite_node_list_end ; ++ ptr ) {
1116
1111
__ztest_init_unit_test_result_for_suite (ptr );
1117
1112
count += __ztest_run_test_suite (ptr , state , shuffle , suite_iter , case_iter );
1118
1113
/* Stop running tests if we have a critical error or if we have a failure and
1119
1114
* FAIL_FAST was set
1120
1115
*/
1121
1116
if (test_status == ZTEST_STATUS_CRITICAL_ERROR ||
1122
- (test_status == ZTEST_STATUS_HAS_FAILURE && FAIL_FAST )) {
1117
+ (test_status == ZTEST_STATUS_HAS_FAILURE && FAIL_FAST )) {
1123
1118
break ;
1124
1119
}
1125
1120
}
@@ -1274,8 +1269,8 @@ static int cmd_shuffle(const struct shell *sh, size_t argc, char **argv)
1274
1269
struct getopt_state * state ;
1275
1270
int opt ;
1276
1271
static struct option long_options [] = {{"suite_iter" , required_argument , 0 , 's' },
1277
- {"case_iter" , required_argument , 0 , 'c' },
1278
- {0 , 0 , 0 , 0 }};
1272
+ {"case_iter" , required_argument , 0 , 'c' },
1273
+ {0 , 0 , 0 , 0 }};
1279
1274
int opt_index = 0 ;
1280
1275
int val ;
1281
1276
int opt_num = 0 ;
@@ -1290,7 +1285,7 @@ static int cmd_shuffle(const struct shell *sh, size_t argc, char **argv)
1290
1285
val = atoi (state -> optarg );
1291
1286
if (val < 1 ) {
1292
1287
shell_fprintf (sh , SHELL_ERROR ,
1293
- "Invalid number of suite interations\n" );
1288
+ "Invalid number of suite interations\n" );
1294
1289
return - ENOEXEC ;
1295
1290
}
1296
1291
suite_iter = val ;
@@ -1300,15 +1295,15 @@ static int cmd_shuffle(const struct shell *sh, size_t argc, char **argv)
1300
1295
val = atoi (state -> optarg );
1301
1296
if (val < 1 ) {
1302
1297
shell_fprintf (sh , SHELL_ERROR ,
1303
- "Invalid number of case interations\n" );
1298
+ "Invalid number of case interations\n" );
1304
1299
return - ENOEXEC ;
1305
1300
}
1306
1301
case_iter = val ;
1307
1302
opt_num ++ ;
1308
1303
break ;
1309
1304
default :
1310
- shell_fprintf (sh , SHELL_ERROR ,
1311
- "Invalid option or option usage: %s\n" , argv [opt_index + 1 ]);
1305
+ shell_fprintf (sh , SHELL_ERROR , "Invalid option or option usage: %s\n" ,
1306
+ argv [opt_index + 1 ]);
1312
1307
return - ENOEXEC ;
1313
1308
}
1314
1309
}
@@ -1327,11 +1322,11 @@ static int cmd_run_suite(const struct shell *sh, size_t argc, char **argv)
1327
1322
ztest_set_test_args (argv [1 ]);
1328
1323
1329
1324
for (struct ztest_suite_node * ptr = _ztest_suite_node_list_start ;
1330
- ptr < _ztest_suite_node_list_end ; ++ ptr ) {
1325
+ ptr < _ztest_suite_node_list_end ; ++ ptr ) {
1331
1326
__ztest_init_unit_test_result_for_suite (ptr );
1332
1327
count += __ztest_run_test_suite (ptr , NULL , shuffle , 1 , 1 );
1333
1328
if (test_status == ZTEST_STATUS_CRITICAL_ERROR ||
1334
- (test_status == ZTEST_STATUS_HAS_FAILURE && FAIL_FAST )) {
1329
+ (test_status == ZTEST_STATUS_HAS_FAILURE && FAIL_FAST )) {
1335
1330
break ;
1336
1331
}
1337
1332
}
@@ -1357,8 +1352,7 @@ static const struct ztest_suite_node *suite_lookup(size_t idx, const char *prefi
1357
1352
1358
1353
while (suite < suite_end ) {
1359
1354
if ((suite -> name != NULL ) && (strlen (suite -> name ) != 0 ) &&
1360
- ((prefix == NULL ) ||
1361
- (strncmp (prefix , suite -> name , strlen (prefix )) == 0 ))) {
1355
+ ((prefix == NULL ) || (strncmp (prefix , suite -> name , strlen (prefix )) == 0 ))) {
1362
1356
if (match_idx == idx ) {
1363
1357
return suite ;
1364
1358
}
@@ -1380,6 +1374,7 @@ static void testsuite_list_get(size_t idx, struct shell_static_entry *entry)
1380
1374
entry -> subcmd = NULL ;
1381
1375
}
1382
1376
1377
+ /* clang-format off */
1383
1378
SHELL_STATIC_SUBCMD_SET_CREATE (
1384
1379
sub_ztest_cmds ,
1385
1380
SHELL_CMD_ARG (run - all , NULL , "Run all tests" , cmd_runall , 0 , 0 ),
@@ -1396,6 +1391,7 @@ static void testsuite_list_get(size_t idx, struct shell_static_entry *entry)
1396
1391
SHELL_CMD_ARG (run - testcase , NULL , "Run testcase" , cmd_run_suite , 2 , 0 ),
1397
1392
SHELL_SUBCMD_SET_END /* Array terminated. */
1398
1393
);
1394
+ /* clang-format on */
1399
1395
1400
1396
SHELL_CMD_REGISTER (ztest , & sub_ztest_cmds , "Ztest commands" , NULL );
1401
1397
#endif /* CONFIG_ZTEST_SHELL */
0 commit comments