42 const char *cp = strrchr(argv0,
'/');
45 cp = strrchr(argv0,
'\\');
55 char **argv = *argv_p;
59 for (i = 1; i<argc; i++)
61 if (strlen(argv[i]) >= 7 && !memcmp(argv[i],
"--test-", 7))
63 const char *suf = argv[i]+7;
64 if (i < argc-1 && !strcmp(suf,
"file"))
72 else if (i < argc-1 && !strcmp(suf,
"verbose"))
78 else if (i < argc && !strcmp(suf,
"stop"))
83 else if (!strcmp(suf,
"help"))
87 "--test-file fname output to fname\n"
88 "--test-stop stop at first failing test\n"
89 "--test-verbose level verbose level\n"
90 " 0=Quiet. Only exit code tells what's wrong\n"
91 " 1=Report+Summary only if tests fail.\n"
92 " 2=Report failures. Print summary always\n"
93 " 3=Report + summary always\n"
94 " 4=Report + summary + extra prints from tests\n"
100 fprintf(stderr,
"Unrecognized option for YAZ test: %s\n",
102 fprintf(stderr,
"Use --test-help for more info\n");
110 (*argv_p)[i-1] = **argv_p;
119 char logfilename[2048];
121 sprintf(logfilename,
"%s.log",
progname(argv0) );
139 fprintf(
get_file(),
"%d out of %d tests failed for program %s"
140 " (%d TODO's remaining)\n",
143 fprintf(
get_file(),
"%d out of %d tests failed for program %s\n",
151 fprintf(
get_file(),
"%d tests passed for program %s"
152 " (%d TODO's remaining)\n",
155 fprintf(
get_file(),
"%d tests passed for program %s\n",
168 const char *left,
const char *right,
int lval,
int rval)
173 sprintf(formstr,
"%.500s == %.500s ", left, right);
175 sprintf(formstr,
"%.500s != %.500s\n %d != %d", left, right, lval,rval);
182 const char *msg =
"unknown";
202 fprintf(
get_file(),
"%s:%d: %s: ", file, line, msg);
void yaz_deinit_globals(void)
void yaz_log(int level, const char *fmt,...)
Writes log message.
void yaz_log_init_file(const char *fname)
sets log file
void yaz_log_trunc()
Truncate the log file.
#define YLOG_LOG
log level: log (regular)
void yaz_check_init1(int *argc_p, char ***argv_p)
used by macro. Should not be called directly
int yaz_test_get_verbosity()
Get the verbosity level.
static const char * test_prog
void yaz_check_init_log(const char *argv0)
Initialize the log system.
void yaz_check_term1(void)
used by macro. Should not be called directly
static FILE * get_file(void)
void yaz_check_inc_todo(void)
used by macro. Should not be called directly
void yaz_check_print1(int type, const char *file, int line, const char *expr)
used by macro. Should not be called directly
void yaz_check_eq1(int type, const char *file, int line, const char *left, const char *right, int lval, int rval)
used by macro. Should not be called directly
static const char * progname(const char *argv0)
#define YAZ_TEST_TYPE_FAIL
Test failed.
#define YAZ_TEST_TYPE_OK
Test OK.