Merge pull request #147 from wtoorop/devel/check_separate_logfiles

Write unit test log's to separate log files
This commit is contained in:
Melinda Shore 2016-03-14 20:08:10 -08:00
commit 28edb1dc5a
2 changed files with 16 additions and 2 deletions

View File

@ -162,7 +162,7 @@ test: $(NOLIBCHECK) 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

View File

@ -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);