aboutsummaryrefslogtreecommitdiffstats
path: root/config/src/tests/configholder/configholder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'config/src/tests/configholder/configholder.cpp')
-rw-r--r--config/src/tests/configholder/configholder.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/config/src/tests/configholder/configholder.cpp b/config/src/tests/configholder/configholder.cpp
index a488cca705a..ce7e4f0531d 100644
--- a/config/src/tests/configholder/configholder.cpp
+++ b/config/src/tests/configholder/configholder.cpp
@@ -1,14 +1,15 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/config/common/configholder.h>
+#include <vespa/fastos/timestamp.h>
using namespace config;
using namespace std::chrono_literals;
namespace {
-constexpr double ONE_SEC = 1000.0;
-constexpr double ONE_MINUTE = 60 * ONE_SEC;
+constexpr long ONE_SEC = 1000;
+constexpr long ONE_MINUTE = 60 * ONE_SEC;
}
@@ -33,11 +34,10 @@ TEST("Require that waiting is done")
ConfigValue value;
ConfigHolder holder;
- FastOS_Time timer;
- timer.SetNow();
+ fastos::StopWatch timer;
holder.wait(1000ms);
- EXPECT_GREATER_EQUAL(timer.MilliSecsToNow(), ONE_SEC);
- EXPECT_LESS(timer.MilliSecsToNow(), ONE_MINUTE);
+ EXPECT_GREATER_EQUAL(timer.elapsed().ms(), ONE_SEC);
+ EXPECT_LESS(timer.elapsed().ms(), ONE_MINUTE);
holder.handle(std::make_unique<ConfigUpdate>(value, true, 0));
ASSERT_TRUE(holder.wait(100ms));
@@ -57,25 +57,23 @@ TEST("Require that polling for elements work")
TEST("Require that negative time does not mean forever.") {
ConfigHolder holder;
- FastOS_Time timer;
- timer.SetNow();
+ fastos::StopWatch timer;
ASSERT_FALSE(holder.poll());
- ASSERT_FALSE(holder.wait(10));
- ASSERT_FALSE(holder.wait(0));
- ASSERT_FALSE(holder.wait(-1));
- ASSERT_FALSE(holder.wait(-7));
- EXPECT_LESS(timer.MilliSecsToNow(), ONE_MINUTE);
+ ASSERT_FALSE(holder.wait(10ms));
+ ASSERT_FALSE(holder.wait(0ms));
+ ASSERT_FALSE(holder.wait(-1ms));
+ ASSERT_FALSE(holder.wait(-7ms));
+ EXPECT_LESS(timer.elapsed().ms(), ONE_MINUTE);
}
TEST_MT_F("Require that wait is interrupted", 2, ConfigHolder)
{
if (thread_id == 0) {
- FastOS_Time timer;
- timer.SetNow();
+ fastos::StopWatch timer;
TEST_BARRIER();
f.wait(1000ms);
- EXPECT_LESS(timer.MilliSecsToNow(), ONE_MINUTE);
- EXPECT_GREATER(timer.MilliSecsToNow(), 400.0);
+ EXPECT_LESS(timer.elapsed().ms(), ONE_MINUTE);
+ EXPECT_GREATER(timer.elapsed().ms(), 400.0);
TEST_BARRIER();
} else {
TEST_BARRIER();