From 8ccba5e2047434156e0c02cc7e066996747a512c Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Mon, 14 Mar 2016 11:59:05 +0100 Subject: [PATCH] Write unit test log's to separate log files For each tested event loop --- src/test/Makefile.in | 2 +- src/test/check_getdns.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/test/Makefile.in b/src/test/Makefile.in index 016b9e22..b76c6224 100644 --- a/src/test/Makefile.in +++ b/src/test/Makefile.in @@ -175,7 +175,7 @@ test: $(NOLIBCHECK) $(NOLIBLDNS) all clean: rm -f *.o *.lo $(PROGRAMS) scratchpad rm -rf .libs - rm -f check_getdns.log + rm -f check_getdns.log check_getdns_event.log check_getdns_ev.log check_getdns_uv.log distclean : clean rm -f scratchpad.c diff --git a/src/test/check_getdns.c b/src/test/check_getdns.c index 2b1b7e9e..a77c40f0 100644 --- a/src/test/check_getdns.c +++ b/src/test/check_getdns.c @@ -76,6 +76,7 @@ main (int argc, char** argv) { int number_failed; SRunner *sr ; + char log_fn[1024], *exe_fn; Suite *getdns_general_suite(void); Suite *getdns_general_sync_suite(void); @@ -152,7 +153,20 @@ main (int argc, char** argv) srunner_add_suite(sr,getdns_service_sync_suite()); srunner_add_suite(sr,getdns_transport_suite()); - srunner_set_log(sr, "check_getdns.log"); + if ((exe_fn = strrchr(argv[0], '/')) && *exe_fn) { + exe_fn += 1; + if (exe_fn[0] == 'l' && exe_fn[1] == 't' && exe_fn[2] == '-') { + exe_fn += 3; + } + if (strlen(strncpy(log_fn, exe_fn, sizeof(log_fn) - 1)) < sizeof(log_fn) - 5) { + (void) strncat(log_fn, ".log", 4); + srunner_set_log(sr, log_fn); + } + else + srunner_set_log(sr, "check_getdns.log"); + } + else + srunner_set_log(sr, "check_getdns.log"); srunner_run_all(sr, CK_NORMAL); number_failed = srunner_ntests_failed(sr); srunner_free(sr);