@@ -81,6 +81,7 @@ static void help(void) {
8181 printf ("Run the test suite for the project with optional configuration.\n\n" );
8282 printf ("Options:\n" );
8383 printf (" --help, -h Show this help message\n" );
84+ printf (" --list_tests, -l Display list of all available tests and modules\n" );
8485 printf (" --jobs=<num>, -j=<num> Number of parallel worker processes (default: 0 = sequential)\n" );
8586 printf (" --iterations=<num>, -i=<num> Number of iterations for each test (default: 16)\n" );
8687 printf (" --seed=<hex> Set a specific RNG seed (default: random)\n" );
@@ -95,6 +96,24 @@ static void help(void) {
9596 printf (" - Iterations and seed can also be passed as positional arguments before any other argument for backward compatibility.\n" );
9697}
9798
99+ /* Print all tests in registry */
100+ static void print_test_list (struct tf_framework * tf ) {
101+ int m , t , total = 0 ;
102+ printf ("\nAvailable tests (%d modules):\n" , tf -> num_modules );
103+ printf ("========================================\n" );
104+ for (m = 0 ; m < tf -> num_modules ; m ++ ) {
105+ const struct tf_test_module * mod = & tf -> registry_modules [m ];
106+ printf ("Module: %s (%d tests)\n" , mod -> name , mod -> size );
107+ for (t = 0 ; t < mod -> size ; t ++ ) {
108+ printf ("\t[%3d] %s\n" , total + 1 , mod -> data [t ].name );
109+ total ++ ;
110+ }
111+ printf ("----------------------------------------\n" );
112+ }
113+ printf ("\nRun specific module: ./tests -t=<module_name>\n" );
114+ printf ("Run specific test: ./tests -t=<test_name>\n\n" );
115+ }
116+
98117static int parse_jobs_count (const char * key , const char * value , struct tf_framework * tf ) {
99118 char * ptr_val ;
100119 long val = strtol (value , & ptr_val , 10 ); /* base 10 */
@@ -178,7 +197,7 @@ static int parse_target(const char* key, const char* value, struct tf_framework*
178197 if (add_all ) return 0 ;
179198 }
180199 fprintf (stderr , "Error: target '%s' not found (missing or module disabled).\n"
181- "Run program with -print_tests option to display available tests and modules.\n" , value );
200+ "Run program with -list_tests option to display available tests and modules.\n" , value );
182201 return -1 ;
183202}
184203
@@ -209,6 +228,10 @@ static int read_args(int argc, char** argv, int start, struct tf_framework* tf)
209228 tf -> args .help = 1 ;
210229 return 0 ;
211230 }
231+ if (strcmp (key , "l" ) == 0 || strcmp (key , "list_tests" ) == 0 ) {
232+ tf -> args .list_tests = 1 ;
233+ return 0 ;
234+ }
212235 fprintf (stderr , "Invalid arg '%s': must be -k=value or --key=value\n" , raw_arg );
213236 return -1 ;
214237 }
@@ -322,6 +345,7 @@ static int tf_init(struct tf_framework* tf, int argc, char** argv)
322345 tf -> args .custom_seed = NULL ;
323346 tf -> args .help = 0 ;
324347 tf -> args .targets .size = 0 ;
348+ tf -> args .list_tests = 0 ;
325349
326350 /* Disable buffering for stdout to improve reliability of getting
327351 * diagnostic information. Happens right at the start of main because
@@ -358,6 +382,11 @@ static int tf_init(struct tf_framework* tf, int argc, char** argv)
358382 help ();
359383 exit (EXIT_SUCCESS );
360384 }
385+
386+ if (tf -> args .list_tests ) {
387+ print_test_list (tf );
388+ exit (EXIT_SUCCESS );
389+ }
361390 }
362391
363392 return EXIT_SUCCESS ;
0 commit comments