This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/scheduled_event_on_event_thread in repository https://gitbox.apache.org/repos/asf/celix.git
commit 95e39ad0cf2ae219861425e8b3326b7458b855b1 Author: Pepijn Noltes <[email protected]> AuthorDate: Tue Jun 20 19:55:29 2023 +0200 Update more scheduled event tests with a "becomes" approach --- libs/framework/gtest/src/CelixFrameworkTestSuite.cc | 4 ++-- libs/framework/gtest/src/ScheduledEventTestSuite.cc | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/libs/framework/gtest/src/CelixFrameworkTestSuite.cc b/libs/framework/gtest/src/CelixFrameworkTestSuite.cc index db9a168a..459f7e75 100644 --- a/libs/framework/gtest/src/CelixFrameworkTestSuite.cc +++ b/libs/framework/gtest/src/CelixFrameworkTestSuite.cc @@ -93,8 +93,8 @@ TEST_F(CelixFrameworkTestSuite, TimedWaitEventQueueTest) { celix_status_t status = celix_framework_waitForEmptyEventQueueFor(framework.get(), 0.005); EXPECT_EQ(ETIMEDOUT, status) << "Expected timeout, but got " << celix_strerror(status); - //And a wait for empty event queue for max 30ms will return success - status = celix_framework_waitForEmptyEventQueueFor(framework.get(), 0.03); + //And a wait for empty event queue for max 1s will return success + status = celix_framework_waitForEmptyEventQueueFor(framework.get(), 1); EXPECT_EQ(CELIX_SUCCESS, status); } diff --git a/libs/framework/gtest/src/ScheduledEventTestSuite.cc b/libs/framework/gtest/src/ScheduledEventTestSuite.cc index c38d470a..023b5c3d 100644 --- a/libs/framework/gtest/src/ScheduledEventTestSuite.cc +++ b/libs/framework/gtest/src/ScheduledEventTestSuite.cc @@ -276,10 +276,7 @@ TEST_F(ScheduledEventTestSuite, WakeUpEventTest) { // Then the status is CELIX_SUCCESS ASSERT_EQ(CELIX_SUCCESS, status); - // When waiting a bit to let the scheduled event trigger - std::this_thread::sleep_for(std::chrono::milliseconds{5}); - - // Then the count becomes 1 within the error margin + // And the count becomes 1 within the error margin waitFor([&]() { return count.load() == 1; }, std::chrono::milliseconds{ALLOWED_ERROR_MARGIN_IN_MS}); EXPECT_EQ(1, count.load());
