Fix GetTimeOfDayClock_test for race condition. #87

This commit is contained in:
Penn, John M 047828115 2021-08-02 11:49:39 -05:00
parent 0b823bb6f2
commit 93b683540d
2 changed files with 7 additions and 3 deletions

View File

@ -6,8 +6,6 @@
#include "trick/Clock.hh"
#include "trick/clock_proto.h"
#include "trick/GetTimeOfDayClock.hh"
#include "trick/TPROCTEClock.hh"
#include "trick/BC635Clock.hh"
#include "trick/JobData.hh"
namespace Trick {

View File

@ -116,7 +116,13 @@ TEST_F(GetTimeOfDayClockTest, ClockSpin) {
tim_curr = timclk->wall_clock_time();
dClk.clock_spin(tim_curr + spin_time);
EXPECT_EQ((timclk->wall_clock_time() - tim_curr), spin_time);
// I think we have to account for a race condition between
// wall_clock_time() and the execution time of this test code. (J.Penn)
// We know that the time difference must be at least as long as the spin_time.
EXPECT_GE((timclk->wall_clock_time() - tim_curr), spin_time);
// But, it can't be much longer. Allow 2 micro-seconds to allow for code execution time.
EXPECT_LE((timclk->wall_clock_time() - tim_curr), spin_time+2);
delete timclk;
}