X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Ftest.c;h=7d521b8033a9b290e9ee200a403cd3505dcb299c;hp=c7267e361df5fe5c710ede3bcf0e491b62f26771;hb=fc42e0dc251df1d80ffc4c9279478d64d8a7027c;hpb=fc6d778b923000b5c6ad8e108b0b184178a9d33f diff --git a/src/test.c b/src/test.c index c7267e3..7d521b8 100644 --- a/src/test.c +++ b/src/test.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: test.c,v 1.7 2006-05-10 12:52:28 heikki Exp $ + * $Id: test.c,v 1.8 2006-07-06 13:10:31 heikki Exp $ */ /** \file test.c @@ -16,14 +16,17 @@ #include #include #include +#include #include +#include static FILE *test_fout = 0; /* can't use '= stdout' on some systems */ static int test_total = 0; static int test_failed = 0; static int test_verbose = 1; static char *test_prog = 0; +static int log_tests = 0; static FILE *get_file() { @@ -102,6 +105,18 @@ void yaz_check_init1(int *argc_p, char ***argv_p) *argv_p += i; } +/** \brief Initialize the log system */ +void yaz_check_init_log(char *argv0) +{ + char logfilename[2048]; + log_tests = 1; + sprintf(logfilename,"%s.log", progname(argv0) ); + unlink(logfilename); + yaz_log_init_file(logfilename); + yaz_log_trunc(); + +} + void yaz_check_term1(void) { /* summary */ @@ -140,6 +155,7 @@ void yaz_check_print1(int type, const char *file, int line, const char *expr) { const char *msg = "unknown"; + int printit=1; test_total++; switch(type) @@ -148,16 +164,22 @@ void yaz_check_print1(int type, const char *file, int line, test_failed++; msg = "FAILED"; if (test_verbose < 1) - return; + printit=0; break; case YAZ_TEST_TYPE_OK: msg = "ok"; if (test_verbose < 3) - return; + printit=0; break; } - fprintf(get_file(), "%s:%d %s: ", file, line, msg); - fprintf(get_file(), "%s\n", expr); + if (printit) { + fprintf(get_file(), "%s:%d %s: ", file, line, msg); + fprintf(get_file(), "%s\n", expr); + } + if (log_tests) { + yaz_log(YLOG_LOG, "%s:%d %s: ", file, line, msg); + yaz_log(YLOG_LOG, "%s\n", expr); + } }