Override `time` from libc

Prior to this change, there were spurious build failures seen in Github
CI, especially on macOS builds, where one test out of ~2000 would fail
randomly. After adding an option to display the diagnostics, it was
determined that the failure was only in the tests that included the
timestamp. This was because the time call was returning different values
between `test_setup` and `pinelog_log_message`. Even though they may
have been called milliseconds apart, the time skew was enough to have a
1 second difference between the two returned values.

This change overrides the `time` method from libc, and returns a static
value. With this change, CI should work fine regardless of how slow the
tests run.
master
nirenjan 2021-11-11 07:02:21 -08:00
parent b9a0f71983
commit 347b65df92
1 changed files with 6 additions and 0 deletions

View File

@ -34,6 +34,12 @@ static FILE *observed_stream_r;
static char expected_output[1024];
static size_t expected_len;
time_t time(time_t *p)
{
// Override the time function from libc
return 1636671600;
}
static void test_case(const char *desc, bool test)
{
test_id++;