From: Tim Kientzle Date: Sat, 13 Dec 2025 01:19:37 +0000 (-0800) Subject: Merge pull request #2807 from KlaraSystems/des/list-tests X-Git-Tag: v3.8.5~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b86d49bcf46a91e5107415f5a00eef4cc9e2a674;p=thirdparty%2Flibarchive.git Merge pull request #2807 from KlaraSystems/des/list-tests Add option to list tests (cherry picked from commit b51e59bcfb28bed745daf20bf1cabb22a44e65f2) --- diff --git a/test_utils/test_main.c b/test_utils/test_main.c index f31678166..dbd3fcf60 100644 --- a/test_utils/test_main.c +++ b/test_utils/test_main.c @@ -3681,11 +3681,19 @@ test_run(int i, const char *tmpdir) */ static void -usage(const char *program) +list_tests(void) { static const int limit = nitems(tests); int i; + for (i = 0; i < limit; i++) + printf(" %d: %s\n", i, tests[i].name); +} + +static void +usage(const char *program) +{ + printf("Usage: %s [options] ...\n", program); printf("Default is to run all tests.\n"); printf("Otherwise, specify the numbers of the tests you wish to run.\n"); @@ -3693,6 +3701,8 @@ usage(const char *program) printf(" -d Dump core after any failure, for debugging.\n"); printf(" -k Keep all temp files.\n"); printf(" Default: temp files for successful tests deleted.\n"); + printf(" -l List available tests and exit, ignoring all other.\n"); + printf(" options and arguments.\n"); #ifdef PROGRAM printf(" -p Path to executable to be tested.\n"); printf(" Default: path taken from " ENVBASE " environment variable.\n"); @@ -3704,8 +3714,7 @@ usage(const char *program) printf(" -u Keep running specified tests until one fails.\n"); printf(" -v Verbose.\n"); printf("Available tests:\n"); - for (i = 0; i < limit; i++) - printf(" %d: %s\n", i, tests[i].name); + list_tests(); exit(1); } @@ -4079,6 +4088,10 @@ main(int argc, char **argv) case 'k': keep_temp_files = 1; break; + case 'l': + list_tests(); + exit(0); + break; case 'p': #ifdef PROGRAM testprogfile = option_arg;