From 1f1b7e8e0dba873aaeedbdaf8d78914501e6de1b Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 14 Feb 2016 12:51:38 +0100 Subject: test: add option -l to list all testcases --- test/main.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/main.c b/test/main.c index 4fe93a0..90f67d7 100644 --- a/test/main.c +++ b/test/main.c @@ -53,11 +53,31 @@ static int run_tests(void) } +static void test_listcases(void) +{ + size_t i, n; + + n = ARRAY_SIZE(tests); + + (void)re_printf("\n%zu test cases:\n", n); + + for (i=0; i<(n+1)/2; i++) { + + (void)re_printf(" %-32s %s\n", + tests[i].name, + (i+(n+1)/2) < n ? tests[i+(n+1)/2].name : ""); + } + + (void)re_printf("\n"); +} + + static void usage(void) { (void)re_fprintf(stderr, "Usage: selftest [options]\n" "options:\n" + "\t-l List all testcases and exit\n" "\t-v Verbose output (INFO level)\n" ); } @@ -75,7 +95,7 @@ int main(int argc, char *argv[]) log_enable_info(false); for (;;) { - const int c = getopt(argc, argv, "v"); + const int c = getopt(argc, argv, "hlv"); if (0 > c) break; @@ -86,6 +106,10 @@ int main(int argc, char *argv[]) usage(); return -2; + case 'l': + test_listcases(); + return 0; + case 'v': log_enable_info(true); break; -- cgit v1.2.3