@@ -73,6 +73,34 @@ void utest_log_lv_set(rt_uint8_t lv)
7373 }
7474}
7575
76+ static struct msh_cmd_opt utest_testcase_run_msh_options [RT_UTEST_MAX_OPTIONS ];
77+ static void utest_build_options (void );
78+ static void utest_build_options (void )
79+ {
80+ rt_size_t i ;
81+ rt_size_t option_index = 0 ;
82+
83+ if (tc_num >= RT_UTEST_MAX_OPTIONS - 1 )
84+ {
85+ LOG_W ("Too many test cases (%d), only first %d will have completion" , tc_num , RT_UTEST_MAX_OPTIONS - 1 );
86+ }
87+
88+ rt_memset (utest_testcase_run_msh_options , 0 , sizeof (utest_testcase_run_msh_options ));
89+
90+ rt_size_t max_cases = (tc_num < RT_UTEST_MAX_OPTIONS - 1 ) ? tc_num : RT_UTEST_MAX_OPTIONS - 1 ;
91+ for (i = 0 ; i < max_cases ; i ++ )
92+ {
93+ utest_testcase_run_msh_options [option_index ].id = i + 1 ;
94+ utest_testcase_run_msh_options [option_index ].name = tc_table [i ].name ;
95+ utest_testcase_run_msh_options [option_index ].des = tc_table [i ].name ;
96+ option_index ++ ;
97+ }
98+
99+ utest_testcase_run_msh_options [option_index ].id = 0 ;
100+ utest_testcase_run_msh_options [option_index ].name = RT_NULL ;
101+ utest_testcase_run_msh_options [option_index ].des = RT_NULL ;
102+ }
103+
76104int utest_init (void )
77105{
78106 /* initialize the utest commands table.*/
@@ -123,6 +151,9 @@ int utest_init(void)
123151 LOG_E ("no memory, tc_fail_list init failed!" );
124152 }
125153 }
154+
155+ utest_build_options ();
156+
126157 return tc_num ;
127158}
128159INIT_COMPONENT_EXPORT (utest_init );
@@ -379,7 +410,7 @@ int utest_testcase_run(int argc, char** argv)
379410
380411 return RT_EOK ;
381412}
382- MSH_CMD_EXPORT_ALIAS (utest_testcase_run , utest_run , utest_run [- thread or - help ] [testcase name ] [loop num ]);
413+ MSH_CMD_EXPORT_ALIAS (utest_testcase_run , utest_run , utest_run [- thread or - help ] [testcase name ] [loop num ], optenable );
383414
384415utest_t utest_handle_get (void )
385416{
0 commit comments