summaryrefslogtreecommitdiffstats
path: root/staging_vespalib/src/tests
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-02-21 18:59:31 +0100
committerGitHub <noreply@github.com>2022-02-21 18:59:31 +0100
commit9d83cff2851b2126700b1b3cf7b4080ac7c8fb81 (patch)
tree49b08e0b66fdec37bce82643b5c310db0cb41a7b /staging_vespalib/src/tests
parenta7e8bb9dcf3c674a3756e0f0383384593856415a (diff)
Revert "Use a common FNET_Transport owned by Proton in both SceduledExecutor …"
Diffstat (limited to 'staging_vespalib/src/tests')
-rw-r--r--staging_vespalib/src/tests/timer/timer_test.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/staging_vespalib/src/tests/timer/timer_test.cpp b/staging_vespalib/src/tests/timer/timer_test.cpp
index 1f0ee81e4e6..9d04500b8cd 100644
--- a/staging_vespalib/src/tests/timer/timer_test.cpp
+++ b/staging_vespalib/src/tests/timer/timer_test.cpp
@@ -2,15 +2,18 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/scheduledexecutor.h>
-#include <vespa/vespalib/util/size_literals.h>
-#include <vespa/fnet/transport.h>
-#include <vespa/fastos/thread.h>
using namespace vespalib;
using vespalib::Executor;
typedef Executor::Task Task;
-namespace {
+class Test : public TestApp
+{
+public:
+ int Main() override;
+ void testScheduling();
+ void testReset();
+};
class TestTask : public Task {
private:
@@ -20,36 +23,35 @@ public:
void run() override { _latch.countDown(); }
};
+int
+Test::Main()
+{
+ TEST_INIT("timer_test");
+ testScheduling();
+ testReset();
+ TEST_DONE();
}
-TEST("testScheduling") {
+void Test::testScheduling()
+{
vespalib::CountDownLatch latch1(3);
vespalib::CountDownLatch latch2(2);
- FastOS_ThreadPool threadPool(64_Ki);
- FNET_Transport transport;
- transport.Start(&threadPool);
- ScheduledExecutor timer(transport);
+ ScheduledExecutor timer;
timer.scheduleAtFixedRate(std::make_unique<TestTask>(latch1), 100ms, 200ms);
timer.scheduleAtFixedRate(std::make_unique<TestTask>(latch2), 500ms, 500ms);
EXPECT_TRUE(latch1.await(60s));
EXPECT_TRUE(latch2.await(60s));
- timer.reset();
- transport.ShutDown(true);
}
-TEST("testReset") {
+void Test::testReset()
+{
vespalib::CountDownLatch latch1(2);
- FastOS_ThreadPool threadPool(64_Ki);
- FNET_Transport transport;
- transport.Start(&threadPool);
- ScheduledExecutor timer(transport);
+ ScheduledExecutor timer;
timer.scheduleAtFixedRate(std::make_unique<TestTask>(latch1), 2s, 3s);
timer.reset();
EXPECT_TRUE(!latch1.await(3s));
timer.scheduleAtFixedRate(std::make_unique<TestTask>(latch1), 200ms, 300ms);
EXPECT_TRUE(latch1.await(60s));
- timer.reset();
- transport.ShutDown(true);
}
-TEST_MAIN() { TEST_RUN_ALL(); }
+TEST_APPHOOK(Test)