Fixed regression tests sometimes failing because of them being time-dependent

This commit is contained in:
Snaipe 2015-10-06 15:44:09 +02:00
parent ec6ea15491
commit 3733c858cb
22 changed files with 42 additions and 38 deletions

View file

@ -37,6 +37,7 @@ struct criterion_options {
const char *pattern;
bool short_filename;
size_t jobs;
bool measure_time;
};
CR_BEGIN_C_API

View file

@ -67,6 +67,7 @@ macro(add_samples DIR_ SAMPLES_)
ENVIRONMENT "CRITERION_SHORT_FILENAME=1"
ENVIRONMENT "CRITERION_NO_EARLY_EXIT=1" # for coverage
ENVIRONMENT "CRITERION_JOBS=1" # for output ordering
ENVIRONMENT "CRITERION_DISABLE_TIME_MEASUREMENTS=1" # do not compare timings
)
endif ()
endforeach()

View file

@ -1,7 +1,7 @@
[----] asserts.c:11: Assertion failed: assert is fatal, expect isn't
[----] asserts.c:12: Assertion failed: This assert runs
[FAIL] asserts::base: (0.00s)
[FAIL] asserts::base
[----] asserts.c:17: Assertion failed: You can fail an assertion with a message from anywhere
[----] asserts.c:18: Assertion failed: The conditions for this assertion were not met.
[FAIL] asserts::old_school: (0.00s)
[FAIL] asserts::old_school
[====] Synthesis: Tested: 6 | Passing: 4 | Failing: 2 | Crashing: 0 

View file

@ -1,11 +1,11 @@
[----] asserts.cc:83: Assertion failed: The expression (&s1)[0 .. 2] == (&s2)[0 .. 2] is false.
[FAIL] asserts::array: (0.00s)
[FAIL] asserts::array
[----] asserts.cc:13: Assertion failed: assert is fatal, expect isn't
[----] asserts.cc:14: Assertion failed: This assert runs
[FAIL] asserts::base: (0.00s)
[FAIL] asserts::base
[----] asserts.cc:89: Assertion failed: The statement `throw std::exception()` did not throw an instance of the `std::bad_alloc` exception.
[FAIL] asserts::exception: (0.00s)
[FAIL] asserts::exception
[----] asserts.cc:19: Assertion failed: You can fail an assertion with a message from anywhere
[----] asserts.cc:20: Assertion failed: The conditions for this assertion were not met.
[FAIL] asserts::old_school: (0.00s)
[FAIL] asserts::old_school
[====] Synthesis: Tested: 7 | Passing: 3 | Failing: 4 | Crashing: 0 

View file

@ -1,3 +1,3 @@
[----] description.c:4: Assertion failed: The expression 0 is false.
[FAIL] misc::failing: (0.00s)
[FAIL] misc::failing
[====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0 

View file

@ -1,3 +1,3 @@
[----] description.cc:4: Assertion failed: The expression 0 is false.
[FAIL] misc::failing: (0.00s)
[FAIL] misc::failing
[====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0 

View file

@ -1,19 +1,19 @@
[----] parameterized.c:76: Assertion failed: Parameters: (1, 2.000000)
[FAIL] params::cleanup: (0.00s)
[FAIL] params::cleanup
[----] parameterized.c:76: Assertion failed: Parameters: (3, 4.000000)
[FAIL] params::cleanup: (0.00s)
[FAIL] params::cleanup
[----] parameterized.c:76: Assertion failed: Parameters: (5, 6.000000)
[FAIL] params::cleanup: (0.00s)
[FAIL] params::cleanup
[----] parameterized.c:36: Assertion failed: Parameters: (1, 2.000000)
[FAIL] params::multiple: (0.00s)
[FAIL] params::multiple
[----] parameterized.c:36: Assertion failed: Parameters: (3, 4.000000)
[FAIL] params::multiple: (0.00s)
[FAIL] params::multiple
[----] parameterized.c:36: Assertion failed: Parameters: (5, 6.000000)
[FAIL] params::multiple: (0.00s)
[FAIL] params::multiple
[----] parameterized.c:15: Assertion failed: Parameter: foo
[FAIL] params::str: (0.00s)
[FAIL] params::str
[----] parameterized.c:15: Assertion failed: Parameter: bar
[FAIL] params::str: (0.00s)
[FAIL] params::str
[----] parameterized.c:15: Assertion failed: Parameter: baz
[FAIL] params::str: (0.00s)
[FAIL] params::str
[====] Synthesis: Tested: 9 | Passing: 0 | Failing: 9 | Crashing: 0 

View file

@ -1,3 +1,3 @@
[----] report.c:5: Assertion failed: The expression 0 is false.
[FAIL] sample::test: (0.00s)
[FAIL] sample::test
[====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0 

View file

@ -1,3 +1,3 @@
[----] report.cc:5: Assertion failed: The expression 0 is false.
[FAIL] sample::test: (0.00s)
[FAIL] sample::test
[====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0 

View file

@ -1,4 +1,4 @@
[----] signal.c:16: Unexpected signal caught below this line!
[FAIL] simple::uncaught: CRASH!
[FAIL] simple::wrong_signal: (0.00s)
[FAIL] simple::wrong_signal
[====] Synthesis: Tested: 3 | Passing: 1 | Failing: 2 | Crashing: 1 

View file

@ -1,4 +1,4 @@
[----] signal.cc:16: Unexpected signal caught below this line!
[FAIL] simple::uncaught: CRASH!
[FAIL] simple::wrong_signal: (0.00s)
[FAIL] simple::wrong_signal
[====] Synthesis: Tested: 3 | Passing: 1 | Failing: 2 | Crashing: 1 

View file

@ -1,3 +1,3 @@
[----] simple.c:4: Assertion failed: The expression 0 is false.
[FAIL] misc::failing: (0.00s)
[FAIL] misc::failing
[====] Synthesis: Tested: 2 | Passing: 1 | Failing: 1 | Crashing: 0 

View file

@ -1,3 +1,3 @@
[----] simple.cc:4: Assertion failed: The expression 0 is false.
[FAIL] misc::failing: (0.00s)
[FAIL] misc::failing
[====] Synthesis: Tested: 2 | Passing: 1 | Failing: 1 | Crashing: 0 

View file

@ -17,7 +17,7 @@
[----] failmessages.c:22: Assertion failed: The expression (as strings) ("abc") <= ("aba") is false.
[----] failmessages.c:23: Assertion failed: The expression (as strings) ("abc") > ("abd") is false.
[----] failmessages.c:24: Assertion failed: The expression (as strings) ("abc") >= ("abd") is false.
[FAIL] messages::default: (0.00s)
[FAIL] messages::default
[----] failmessages.c:28: Assertion failed: foo bar
[----] failmessages.c:29: Assertion failed: foo bar
[----] failmessages.c:30: Assertion failed: foo bar
@ -37,5 +37,5 @@
[----] failmessages.c:46: Assertion failed: foo bar
[----] failmessages.c:47: Assertion failed: foo bar
[----] failmessages.c:48: Assertion failed: foo bar
[FAIL] messages::user: (0.00s)
[FAIL] messages::user
[====] Synthesis: Tested: 2 | Passing: 0 | Failing: 2 | Crashing: 0 

View file

@ -21,7 +21,7 @@
[----] failmessages.cc:28: Assertion failed: The statement `throw std::exception()` did throw an instance of the `std::exception` exception.
[----] failmessages.cc:29: Assertion failed: The statement `{}` did not throw any exception.
[----] failmessages.cc:30: Assertion failed: The statement `throw std::exception()` threw some exception.
[FAIL] messages::default: (0.00s)
[FAIL] messages::default
[----] failmessages.cc:34: Assertion failed: foo bar
[----] failmessages.cc:35: Assertion failed: foo bar
[----] failmessages.cc:36: Assertion failed: foo bar
@ -45,5 +45,5 @@
[----] failmessages.cc:57: Assertion failed: foo bar
[----] failmessages.cc:58: Assertion failed: foo bar
[----] failmessages.cc:59: Assertion failed: foo bar
[FAIL] messages::user: (0.00s)
[FAIL] messages::user
[====] Synthesis: Tested: 2 | Passing: 0 | Failing: 2 | Crashing: 0 

View file

@ -2,5 +2,5 @@
[----] A long message
[----] Spawning multiple lines.
[----] Formatting is respected.
[FAIL] sample::long_msg: (0.00s)
[FAIL] sample::long_msg
[====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0 

View file

@ -2,5 +2,5 @@
[----] A long message
[----] Spawning multiple lines.
[----] Formatting is respected.
[FAIL] sample::long_msg: (0.00s)
[FAIL] sample::long_msg
[====] Synthesis: Tested: 1 | Passing: 0 | Failing: 1 | Crashing: 0 

View file

@ -8,8 +8,8 @@
[----] Theory theory::gen failed with the following parameters: (4)
[----] theories_regression.c:51: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::gen failed with the following parameters: (5)
[FAIL] theory::gen: (0.00s)
[FAIL] theory::gen
[----] theories_regression.c:34: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::misc failed with the following parameters: ('a', true, 1, 1, 3.14f, 3.14, "test", "other test")
[FAIL] theory::misc: (0.00s)
[FAIL] theory::misc
[====] Synthesis: Tested: 2 | Passing: 0 | Failing: 2 | Crashing: 0 

View file

@ -8,8 +8,8 @@
[----] Theory theory::gen failed with the following parameters: (4)
[----] theories_regression.cc:53: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::gen failed with the following parameters: (5)
[FAIL] theory::gen: (0.00s)
[FAIL] theory::gen
[----] theories_regression.cc:36: Assertion failed: The conditions for this assertion were not met.
[----] Theory theory::misc failed with the following parameters: ('a', true, 1, 1, 3.14f, 3.14, "test", "other test")
[FAIL] theory::misc: (0.00s)
[FAIL] theory::misc
[====] Synthesis: Tested: 2 | Passing: 0 | Failing: 2 | Crashing: 0 

View file

@ -2,6 +2,7 @@
#include <inttypes.h>
#include <stdlib.h>
#include "criterion/common.h"
#include "criterion/options.h"
#include "compat/time.h"
#include "compat/posix.h"
@ -28,6 +29,9 @@ extern __attribute__ ((weak)) int clock_gettime(clockid_t, struct timespec *);
#endif
bool can_measure_time(void) {
if (!criterion_options.measure_time)
return false;
#if defined(__unix__) && !defined(__CYGWIN__)
return clock_gettime != NULL;
#else
@ -128,11 +132,6 @@ int setup_timeout(uint64_t nanos) {
CloseHandle(thread);
return 0;
#elif defined(__unix__)
if (!can_measure_time()) {
errno = ENOTSUP;
return -1;
}
timer_t timer;
int res = timer_create(CLOCK_MONOTONIC, &(struct sigevent) {
.sigev_notify = SIGEV_SIGNAL,

View file

@ -183,6 +183,8 @@ int criterion_handle_args(int argc, char *argv[], bool handle_unknown_arg) {
bool use_tap = !strcmp("1", DEF(getenv("CRITERION_ENABLE_TAP"), "0"));
opt->measure_time = !!strcmp("1", DEF(getenv("CRITERION_DISABLE_TIME_MEASUREMENTS"), "0"));
bool do_list_tests = false;
bool do_print_version = false;
bool do_print_usage = false;

View file

@ -26,4 +26,5 @@
struct criterion_options criterion_options = {
.logging_threshold = CRITERION_IMPORTANT,
.output_provider = &normal_logging,
.measure_time = true,
};