wolfcw/libfaketime — pull request #49 by misterdjules (2014-07-25 23:03:26+00:00)
Title: Add --exclude-monotonic command line option.

This PR adds the --exclude-monotonic command line flag to faketime.
It prevents faketime from overriding the clock with id CLOCK_MONOTONIC when using clock_gettime.

It also adds support to libfaketime for an env variable named DONT_FAKE_MONOTONIC that
has the same effect.

Functional tests for DONT_FAKE_MONOTONIC support are included.

This change came out of the need to test that high-level (JavaScript API) timers in Node.js are actually implemented using monotonic time and not wall-clock time. To test this, we use faketime (with this change) to freeze wall-clock time, but not monotonic time. If our timers are implemented correctly, when the low-level timers (always implemented using monotonic time) fire, if our high-level timers have already fired, it means that they're correctly implemented too.

I think other developers could benefit from this PR if they want to test their timers-related code too.

I made this PR against master and not develop because I hadn't read README.developers until now. I noticed that the develop branch hasn't seen any commit for a while, so just in case README.developers is out of date and developers now submit PRs on master, I'm sending it to be merged on master. If you want it made against develop, just let me know and I'll create another one.

Finally, this PR is just to get the ball rolling and to open a discussion. If we can agree on this initial concept, it would be nice to add other things. For instance, I'd like to be able to prevent faketime to override any type of clock (monotonic, monotonic_raw and realtime), and to have a command line API that is easier to use (like --exclude-clock=comma_separated_list_of_clock_ids ). Depending on the outcome of this discussion, I will implement that too.

I welcome your comments and suggestions!

Thank you,