Commit 9405bf98 authored by Chris Müller's avatar Chris Müller

lib: unittest uses now an Allow-flag for showing stdout messages from test cases.

parent ed27dafa
......@@ -48,6 +48,7 @@ static char* Testlog = 0;
static int Colors = 0;
static int Repeat = 1;
static int Verbose = 0;
static int Allow = 0;
static const char* FilterPattern = 0;
// Statistics
......@@ -78,10 +79,11 @@ cry_unittest_initialize(int argc, char** argv)
{"colors", no_argument, 0, 'c'},
{"verbose", no_argument, 0, 'v'},
{"repeat", optional_argument, 0, 'r'},
{"filter", optional_argument, 0, 'f'}
{"filter", optional_argument, 0, 'f'},
{"allow", optional_argument, 0, 'a'}
};
while( (ch = getopt_long(argc, argv, "vhcr:f:", options, 0)) != -1 ) {
while( (ch = getopt_long(argc, argv, "vhacr:f:", options, 0)) != -1 ) {
switch(ch) {
case 'h':
print_usage(stdout, argv[0], EXIT_SUCCESS);
......@@ -94,6 +96,9 @@ cry_unittest_initialize(int argc, char** argv)
case 'f':
FilterPattern = optarg;
break;
case 'a':
Allow = 1;
break;
case 'v':
Verbose = 1;
break;
......@@ -189,13 +194,17 @@ cry_unittest_run(const char* desc, cry_modulechecker handler, const_pointer data
// Process for running test case
freopen(Testlog, "w+", stderr);
freopen("/dev/null", "w", stdout);
if(!Allow)
freopen("/dev/null", "w", stdout);
for(i = 0; i < Repeat; ++i)
handler(data);
fclose(stderr);
fclose(stdout);
if(!Allow)
fclose(stdout);
cry_free(Testlog);
......@@ -214,6 +223,7 @@ print_usage(FILE* stream, const char* programm, int exit_code)
" -c --colors Enable color support for test output.\n"
" -v --verbose Show more details about the testing progress.\n"
" -r --repeat=INT Set number of repeats for each testcase.\n"
" -a --allow Allow stdout output for test files.\n"
" -f --filter=PATTERN Set a regular expression filter for all testcases.\n");
exit(exit_code);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment