summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2016-01-09 20:48:07 +0100
committerAlfred E. Heggestad <aeh@db.org>2016-01-09 20:48:07 +0100
commitfba45710a563c655b56379b86d8577fdd96a302a (patch)
tree00adc8895434953e8295edb01a0608cebfef9b07 /test
parent4d8a30e750cfcbb6de91b1a4ee9c55411a146821 (diff)
selftest: silent output, add optional verbose -v
Diffstat (limited to 'test')
-rw-r--r--test/call.c2
-rw-r--r--test/cplusplus.cpp2
-rw-r--r--test/main.c50
3 files changed, 43 insertions, 11 deletions
diff --git a/test/call.c b/test/call.c
index dfb39dd..7ca1815 100644
--- a/test/call.c
+++ b/test/call.c
@@ -134,7 +134,6 @@ static void event_handler(struct ua *ua, enum ua_event ev,
++ag->n_established;
if (ag->peer->n_established) {
- re_printf("@@@ test complete\n");
re_cancel();
}
break;
@@ -146,7 +145,6 @@ static void event_handler(struct ua *ua, enum ua_event ev,
ag->close_scode = call_scode(call);
if (ag->peer->n_closed) {
- re_printf("@@@ test complete\n");
re_cancel();
}
break;
diff --git a/test/cplusplus.cpp b/test/cplusplus.cpp
index 7d2b208..e6ec89f 100644
--- a/test/cplusplus.cpp
+++ b/test/cplusplus.cpp
@@ -15,7 +15,7 @@ int test_cplusplus(void)
int err = 0;
ASSERT_TRUE(str_isset(version));
- re_printf("c++ ok\n");
+ info("c++ ok\n");
out:
return err;
diff --git a/test/main.c b/test/main.c
index 8215ed4..4fe93a0 100644
--- a/test/main.c
+++ b/test/main.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2010 Creytiv.com
*/
+#include <getopt.h>
#include <re.h>
#include <baresip.h>
#include "test.h"
@@ -29,17 +30,14 @@ static const struct test tests[] = {
};
-static int run_tests(bool verbose)
+static int run_tests(void)
{
size_t i;
int err;
for (i=0; i<ARRAY_SIZE(tests); i++) {
- if (verbose) {
- re_printf("test %u -- %s\n",
- i, tests[i].name);
- }
+ re_printf("[ RUN ] %s\n", tests[i].name);
err = tests[i].exec();
if (err) {
@@ -47,13 +45,25 @@ static int run_tests(bool verbose)
tests[i].name, err);
return err;
}
+
+ re_printf("[ OK ]\n");
}
return 0;
}
-int main(void)
+static void usage(void)
+{
+ (void)re_fprintf(stderr,
+ "Usage: selftest [options]\n"
+ "options:\n"
+ "\t-v Verbose output (INFO level)\n"
+ );
+}
+
+
+int main(int argc, char *argv[])
{
struct config *config;
int err;
@@ -62,7 +72,31 @@ int main(void)
if (err)
return err;
- re_printf("running test version %s\n", BARESIP_VERSION);
+ log_enable_info(false);
+
+ for (;;) {
+ const int c = getopt(argc, argv, "v");
+ if (0 > c)
+ break;
+
+ switch (c) {
+
+ case '?':
+ case 'h':
+ usage();
+ return -2;
+
+ case 'v':
+ log_enable_info(true);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ re_printf("running baresip selftest version %s with %zu tests\n",
+ BARESIP_VERSION, ARRAY_SIZE(tests));
/* note: run SIP-traffic on localhost */
config = conf_config();
@@ -77,7 +111,7 @@ int main(void)
if (err)
goto out;
- err = run_tests(false);
+ err = run_tests();
if (err)
goto out;