summaryrefslogtreecommitdiffstats
path: root/staging_vespalib/src/tests/clock/clock_test.cpp
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-12-03 14:24:41 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-12-04 18:15:16 +0000
commit8946dbea418f760e4f0a5cbe2eb2bcbcddd25032 (patch)
treefc254ea5dea29ddf6a395b8bcdcb8c7540d22238 /staging_vespalib/src/tests/clock/clock_test.cpp
parent7700f411ea6f4a3e7c0599fae239ec84c18c0038 (diff)
FastOS_THread::Sleep -> std::chrono::sleep_for
Renamed Timer -> ScheduledExecutor. Do not include thread.h when not needed in header files.
Diffstat (limited to 'staging_vespalib/src/tests/clock/clock_test.cpp')
-rw-r--r--staging_vespalib/src/tests/clock/clock_test.cpp19
1 files changed, 5 insertions, 14 deletions
diff --git a/staging_vespalib/src/tests/clock/clock_test.cpp b/staging_vespalib/src/tests/clock/clock_test.cpp
index bf7e3773055..b5650244a45 100644
--- a/staging_vespalib/src/tests/clock/clock_test.cpp
+++ b/staging_vespalib/src/tests/clock/clock_test.cpp
@@ -2,36 +2,27 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/clock.h>
+#include <vespa/vespalib/util/time.h>
#include <vespa/fastos/thread.h>
using vespalib::Clock;
using fastos::TimeStamp;
-class Test : public vespalib::TestApp
-{
-public:
- int Main() override;
-};
-
-int
-Test::Main()
-{
- TEST_INIT("clock_test");
+TEST("Test that clock is ticking forward") {
Clock clock(0.050);
FastOS_ThreadPool pool(0x10000);
ASSERT_TRUE(pool.NewThread(clock.getRunnable(), nullptr) != nullptr);
fastos::SteadyTimeStamp start = clock.getTimeNS();
- FastOS_Thread::Sleep(5000);
+ std::this_thread::sleep_for(5s);
fastos::SteadyTimeStamp stop = clock.getTimeNS();
EXPECT_TRUE(stop > start);
- FastOS_Thread::Sleep(6000);
+ std::this_thread::sleep_for(6s);
clock.stop();
fastos::SteadyTimeStamp stop2 = clock.getTimeNS();
EXPECT_TRUE(stop2 > stop);
EXPECT_TRUE((stop2 - stop)/TimeStamp::MICRO > 1000);
- TEST_DONE();
}
-TEST_APPHOOK(Test)
+TEST_MAIN() { TEST_RUN_ALL(); } \ No newline at end of file