testing_clock.h 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef TESTING_CLOCK_H_
  5. #define TESTING_CLOCK_H_
  6. #include "ua_types.h"
  7. /**
  8. * Simulate the system clock
  9. * ------------------------- */
  10. /* The testing clock is used for reproducible unit tests that require precise
  11. * timings. It implements the following functions from ua_types.h. They return a
  12. * deterministic time that can be advanced manually with UA_sleep.
  13. *
  14. * UA_DateTime UA_EXPORT UA_DateTime_now(void);
  15. * UA_DateTime UA_EXPORT UA_DateTime_nowMonotonic(void); */
  16. /* Forwards the testing clock by the given duration in ms */
  17. void UA_fakeSleep(UA_UInt32 duration);
  18. /* Sleep for the duration in milliseconds. Used to wait for workers to complete. */
  19. void UA_realSleep(UA_UInt32 duration);
  20. /* Sleep for the duration in milliseconds and update the current time.
  21. * combines fakeSleep and realSleep.
  22. * */
  23. void UA_comboSleep(UA_UInt32 duration);
  24. #endif /* TESTING_CLOCK_H_ */