@@ -191,7 +191,7 @@ static int utest_help(void)
191191 return 0 ;
192192}
193193
194- static void utest_run (const char * utest_name )
194+ static void utest_do_run (const char * utest_name )
195195{
196196 rt_size_t i ;
197197 rt_uint32_t index ;
@@ -300,45 +300,60 @@ static void utest_run(const char *utest_name)
300300 }
301301}
302302
303- static void utest_thr_entry (const char * utest_name )
303+ static void utest_thr_entry (void * para )
304304{
305- /* see commit:0dc7b9a for details */
306- rt_thread_mdelay (1000 );
305+ char * utest_name = (char * )para ;
306+ rt_thread_mdelay (1000 ); /* see commit:0dc7b9a for details */
307+ rt_kprintf ("\n" );
308+ utest_do_run (utest_name );
309+ }
307310
308- utest_run (utest_name );
311+ static void utest_thread_create (const char * utest_name )
312+ {
313+ rt_thread_t tid = RT_NULL ;
314+ tid = rt_thread_create ("utest" ,
315+ utest_thr_entry , (void * )utest_name ,
316+ UTEST_THREAD_STACK_SIZE , UTEST_THREAD_PRIORITY , 10 );
317+ if (tid != RT_NULL )
318+ {
319+ rt_thread_startup (tid );
320+ }
309321}
310322
311- long utest_testcase_run (int argc , char * * argv )
323+ #ifdef RT_USING_CI_ACTION
324+ static int utest_ci_action (void )
312325{
326+ tc_loop = 1 ;
327+ utest_thread_create (RT_NULL );
328+ return RT_EOK ;
329+ }
330+ INIT_APP_EXPORT (utest_ci_action );
331+ #endif /* RT_USING_CI_ACTION */
313332
333+ int utest_testcase_run (int argc , char * * argv )
334+ {
314335 static char utest_name [UTEST_NAME_MAX_LEN ];
315336 rt_memset (utest_name , 0x0 , sizeof (utest_name ));
316337
317338 tc_loop = 1 ;
318339
319340 if (argc == 1 )
320341 {
321- utest_run (RT_NULL );
322- return 0 ;
342+ utest_thread_create (RT_NULL );
323343 }
324344 else if (argc == 2 || argc == 3 || argc == 4 )
325345 {
326346 if (rt_strcmp (argv [1 ], "-thread" ) == 0 )
327347 {
328- rt_thread_t tid = RT_NULL ;
329348 if (argc == 3 || argc == 4 )
330349 {
331350 rt_strncpy (utest_name , argv [2 ], sizeof (utest_name ) - 1 );
332-
333- if (argc == 4 ) tc_loop = atoi (argv [3 ]);
334- }
335- tid = rt_thread_create ("utest" ,
336- (void (* )(void * ))utest_thr_entry , utest_name ,
337- UTEST_THREAD_STACK_SIZE , UTEST_THREAD_PRIORITY , 10 );
338- if (tid != NULL )
339- {
340- rt_thread_startup (tid );
351+ if (argc == 4 )
352+ {
353+ tc_loop = atoi (argv [3 ]);
354+ }
341355 }
356+ utest_thread_create (utest_name );
342357 }
343358 else if (rt_strcmp (argv [1 ], "-help" ) == 0 )
344359 {
@@ -347,16 +362,20 @@ long utest_testcase_run(int argc, char** argv)
347362 else
348363 {
349364 rt_strncpy (utest_name , argv [1 ], sizeof (utest_name ) - 1 );
350- if (argc == 3 ) tc_loop = atoi (argv [2 ]);
351- utest_run (utest_name );
365+ if (argc == 3 )
366+ {
367+ tc_loop = atoi (argv [2 ]);
368+ }
369+ utest_do_run (utest_name );
352370 }
353371 }
354372 else
355373 {
356374 LOG_E ("[ error ] at (%s:%d), in param error." , __func__ , __LINE__ );
357375 utest_help ();
358376 }
359- return 0 ;
377+
378+ return RT_EOK ;
360379}
361380MSH_CMD_EXPORT_ALIAS (utest_testcase_run , utest_run , utest_run [- thread or - help ] [testcase name ] [loop num ]);
362381
0 commit comments