43 const char *cp = strrchr(argv0,
'/');
46 cp = strrchr(argv0,
'\\');
56 char **argv = *argv_p;
60 for (i = 1; i<argc; i++)
62 if (strlen(argv[i]) >= 7 && !memcmp(argv[i],
"--test-", 7))
64 const char *suf = argv[i]+7;
65 if (i < argc-1 && !strcmp(suf,
"file"))
73 else if (i < argc-1 && !strcmp(suf,
"verbose"))
79 else if (i < argc && !strcmp(suf,
"stop"))
84 else if (!strcmp(suf,
"help"))
88 "--test-file fname output to fname\n"
89 "--test-stop stop at first failing test\n"
90 "--test-verbose level verbose level\n"
91 " 0=Quiet. Only exit code tells what's wrong\n"
92 " 1=Report+Summary only if tests fail.\n"
93 " 2=Report failures. Print summary always\n"
94 " 3=Report + summary always\n"
95 " 4=Report + summary + extra prints from tests\n"
101 fprintf(stderr,
"Unrecognized option for YAZ test: %s\n",
103 fprintf(stderr,
"Use --test-help for more info\n");
111 (*argv_p)[i-1] = **argv_p;
120 char logfilename[2048];
140 fprintf(
get_file(),
"%d out of %d tests failed for program %s"
141 " (%d TODO's remaining)\n",
144 fprintf(
get_file(),
"%d out of %d tests failed for program %s\n",
152 fprintf(
get_file(),
"%d tests passed for program %s"
153 " (%d TODO's remaining)\n",
156 fprintf(
get_file(),
"%d tests passed for program %s\n",
169 const char *left,
const char *right,
int lval,
int rval)
174 yaz_snprintf(formstr,
sizeof(formstr),
"%s == %s ", left, right);
176 yaz_snprintf(formstr,
sizeof(formstr),
"%s != %s\n %d != %d", left, right, lval,rval);
183 const char *msg =
"unknown";
203 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_snprintf(char *buf, size_t size, const char *fmt,...)
Header for config file reading utilities.
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
void yaz_check_inc_todo(void)
used by macro. Should not be called directly
static FILE * get_file(void)
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
#define YAZ_TEST_TYPE_FAIL
Test failed.
#define YAZ_TEST_TYPE_OK
Test OK.