From 105f2620b98bfd4e5d7ed576b5cc4b2317dcf634 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 20 Jun 2017 21:02:42 +0100 Subject: Reduce precision of common timer test Ideally timers would be perfectly accurate and we could sleep for 1.0 seconds, but on OSX in particular they could fire 50-100 ms late (I've seen 4 ms in practice) and we don't want the tests to fail because of this, because we don't really need that kind of precision in practice. So we reduce the timer intervals by 100ms to be safe. Increase logging level and add timestamps in testcommon. Should help to debug frequent test failures such as Condition [t2.HasExpired()] on OSX hosts on Travis. Add a SettingsGuard to the Console logger for its specific settings, such as showing times and microseconds. (cherry picked from commit a5e6cff1d435329b0121417ed9509e315ce0edd5) (cherry picked from commit 8d02eebce553ed822e0fcd60d6e319384e15ba4b) --- lib/common/Logging.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lib') diff --git a/lib/common/Logging.h b/lib/common/Logging.h index 01358617..3dc3e69c 100644 --- a/lib/common/Logging.h +++ b/lib/common/Logging.h @@ -295,6 +295,32 @@ class Console : public Logger static void SetShowTimeMicros(bool enabled); static void SetShowPID(bool enabled); static bool GetShowTag() { return sShowTag; } + + class SettingsGuard + { + private: + bool mShowTag; + bool mShowTime; + bool mShowTimeMicros; + bool mShowPID; + std::string mTag; + public: + SettingsGuard() + : mShowTag(Console::sShowTag), + mShowTime(Console::sShowTime), + mShowTimeMicros(Console::sShowTimeMicros), + mShowPID(Console::sShowPID), + mTag(Console::sTag) + { } + ~SettingsGuard() + { + Console::SetShowTag(mShowTag); + Console::SetShowTime(mShowTime); + Console::SetShowTimeMicros(mShowTimeMicros); + Console::SetShowPID(mShowPID); + Console::sTag = mTag; + } + }; }; // -------------------------------------------------------------------------- -- cgit v1.2.3