CTest doesn't use monotonic times leading to timeouts if device time changes
Hi,
we've started to use CTest for our test running and it's generally running well.
It has been noticed that ctest doesn't use monotonic test timers, but instead relies on gettimeofday()
. When running on some of our devices, they start up thinking that it is the year 2000 but during the test run, NTP kicks in, and fast forwards the time to be 2017.
Using gettimeofday()
, such a test would seem to have taken 17 years. It's generally preferred in such cases to use clock_gettime(CLOCK_MONOTONIC)
instead.
We've found at least two instances in the CTest code base, and an attached is a patch to change kwsysProcessTimeGetCurrent()
and SystemTools::GetTime()
to use clock_gettime()
in order to use monotonic timers.
Do these changes make sense?
0001-Use-monotonic-timers-where-gettimeofday-was-used-to-.patch