@@ -96,6 +96,19 @@ static char g_kasan_heap[65536] aligned_data(8);
96
96
* Private Functions
97
97
****************************************************************************/
98
98
99
+ static void error_handler (void )
100
+ {
101
+ int i ;
102
+
103
+ printf ("Usage: kasantest [-h] [case_number]\n" );
104
+ printf ("options:\n-h: show this help message\n" );
105
+ printf ("case_number:\n" );
106
+ for (i = 0 ; i < nitems (g_kasan_test ); i ++ )
107
+ {
108
+ printf ("%d: %s\n" , i + 1 , g_kasan_test [i ].name );
109
+ }
110
+ }
111
+
99
112
static bool test_heap_underflow (FAR struct mm_heap_s * heap , size_t size )
100
113
{
101
114
FAR uint8_t * mem = mm_malloc (heap , size );
@@ -197,12 +210,6 @@ static bool test_heap_memmove(FAR struct mm_heap_s *heap, size_t size)
197
210
return false;
198
211
}
199
212
200
- static int run_testcase (int argc , FAR char * argv [])
201
- {
202
- FAR run_t * run = (FAR run_t * )(uintptr_t )strtoul (argv [1 ], NULL , 0 );
203
- return run -> testcase -> func (run -> heap , run -> size );
204
- }
205
-
206
213
static int run_test (FAR const testcase_t * test )
207
214
{
208
215
size_t heap_size = 65536 ;
@@ -250,6 +257,37 @@ static int run_test(FAR const testcase_t *test)
250
257
return 0 ;
251
258
}
252
259
260
+ static int run_testcase (int argc , FAR char * argv [])
261
+ {
262
+ uintptr_t index = strtoul (argv [1 ], NULL , 0 );
263
+ FAR run_t * run ;
264
+
265
+ /* Pass in the number to run the specified case,
266
+ * and the string of the number will not be very long
267
+ */
268
+
269
+ if (strlen (argv [1 ]) <= 3 )
270
+ {
271
+ if (memcmp (argv [1 ], "-h" , 2 ) == 0
272
+ || index <= 0 || index > nitems (g_kasan_test ))
273
+ {
274
+ error_handler ();
275
+ }
276
+ else
277
+ {
278
+ if (run_test (& g_kasan_test [index - 1 ]) < 0 )
279
+ {
280
+ return EXIT_FAILURE ;
281
+ }
282
+ }
283
+
284
+ return EXIT_SUCCESS ;
285
+ }
286
+
287
+ run = (FAR run_t * )index ;
288
+ return run -> testcase -> func (run -> heap , run -> size );
289
+ }
290
+
253
291
/****************************************************************************
254
292
* Public Functions
255
293
****************************************************************************/
0 commit comments