From 50a10f5cf062b7dcd3780983b035cc7ffe06778e Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 14 Feb 2016 13:27:47 +0100 Subject: test: add option to specify which testcase(s) to run --- test/main.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/main.c b/test/main.c index 90f67d7..de46b11 100644 --- a/test/main.c +++ b/test/main.c @@ -30,6 +30,25 @@ static const struct test tests[] = { }; +static int run_one_test(const struct test *test) +{ + int err; + + re_printf("[ RUN ] %s\n", test->name); + + err = test->exec(); + if (err) { + warning("%s: test failed (%m)\n", + test->name, err); + return err; + } + + re_printf("[ OK ]\n"); + + return 0; +} + + static int run_tests(void) { size_t i; @@ -72,10 +91,24 @@ static void test_listcases(void) } +static const struct test *find_test(const char *name) +{ + size_t i; + + for (i=0; i\n" "options:\n" "\t-l List all testcases and exit\n" "\t-v Verbose output (INFO level)\n" @@ -86,6 +119,7 @@ static void usage(void) int main(int argc, char *argv[]) { struct config *config; + size_t i, ntests; int err; err = libre_init(); @@ -119,8 +153,13 @@ int main(int argc, char *argv[]) } } + if (argc >= (optind + 1)) + ntests = argc - optind; + else + ntests = ARRAY_SIZE(tests); + re_printf("running baresip selftest version %s with %zu tests\n", - BARESIP_VERSION, ARRAY_SIZE(tests)); + BARESIP_VERSION, ntests); /* note: run SIP-traffic on localhost */ config = conf_config(); @@ -135,16 +174,39 @@ int main(int argc, char *argv[]) if (err) goto out; - err = run_tests(); - if (err) - goto out; + if (argc >= (optind + 1)) { + + for (i=0; i