Metaswitch/cpp-common — pull request #28 by AlexHockey (2014-01-31 11:05:39+00:00)
Title: [Reviewer: Matt][From: Alex] Fix up complete control of time in the UTs. 

Hi Matt,

As you reviewed my previous change to allow the test scripts to completely control time, could you also review this fix?

The issue was that CLOCK_REALTIME and CLOCK_MONOTONIC don't have to resemble each other in any way. As such my previous approach of reading CLOCK_MONOTONIC and using it as a baseline for all time reads (CLOCK_REALTIME, CLOCK_MONOTONIC, and time()) causes time to jump around by decades during the scripts, and causes various issues.

I've fixed this by reading CLOCK_REALTIME, CLOCK_MONOTONIC and time() when the test takes control of time, and using the right baseline to respond to subsequent queries.

I've also fixed up the locking so that the absolute times are read within the same lock as `completely_control_time`.

Tested by running the homestead and sprout UTs.