Skip to content

Commit 91d2da4

Browse files
authored
itest: add timeout for participant modes test (#252)
also add a 300 sec timeout for running ctests on the CI
1 parent d9e3677 commit 91d2da4

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

.github/actions/build-cmake-preset/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ runs:
6565
id: ctests
6666
run: |
6767
export PATH=${{ inputs.extra-path }}$PATH
68-
ctest --preset ${{ inputs.preset-name }} --output-on-failure -R '^(I|T)'
68+
ctest --preset ${{ inputs.preset-name }} --output-on-failure -R '^(I|T)' --timeout 300
6969
7070
shell: ${{ inputs.shell }}
7171

SilKit/IntegrationTests/ITest_Internals_ParticipantModes.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ std::atomic<bool> abortSystemControllerRequested{false};
4141
static size_t expectedReceptions = 0;
4242
static size_t globalParticipantIndex = 0;
4343

44+
static constexpr std::chrono::seconds TEST_TIMEOUT{20};
45+
4446
std::chrono::milliseconds communicationTimeout{10000ms};
4547
std::chrono::milliseconds asyncDelayBetweenPublication{50ms};
4648

@@ -256,7 +258,7 @@ class ITest_Internals_ParticipantModes : public testing::Test
256258
if (testParticipant.lifeCycleOperationMode != OperationMode::Invalid)
257259
{
258260
auto finalStateFuture = lifecycleService->StartLifecycle();
259-
finalStateFuture.get();
261+
finalStateFuture.wait_for(TEST_TIMEOUT);
260262
}
261263
}
262264

@@ -364,12 +366,12 @@ class ITest_Internals_ParticipantModes : public testing::Test
364366

365367
// Wait for task to have received a stop request
366368
auto simTaskFinishedFuture = testParticipant.simTaskFinishedPromise.get_future();
367-
simTaskFinishedFuture.get();
369+
(void)simTaskFinishedFuture.wait_for(TEST_TIMEOUT);
368370

369371
// Stop the lifecycle
370372
lifecycleService->Stop("End Test");
371373

372-
finalStateFuture.get();
374+
(void)finalStateFuture.wait_for(TEST_TIMEOUT);
373375

374376
if (runTaskThread.joinable())
375377
{
@@ -466,14 +468,14 @@ class ITest_Internals_ParticipantModes : public testing::Test
466468
};
467469
std::thread abortThread{waitForAbortTask};
468470
abortThread.detach();
469-
abortThreadDone.get_future().get();
471+
abortThreadDone.get_future().wait_for(TEST_TIMEOUT);
470472
if (abortThread.joinable())
471473
{
472474
abortThread.join();
473475
}
474476
abortSystemControllerRequested = false;
475477

476-
finalState.get();
478+
finalState.wait_for(TEST_TIMEOUT);
477479
}
478480

479481
void RunSystemController(const std::vector<std::string>& requiredParticipants)
@@ -495,7 +497,7 @@ class ITest_Internals_ParticipantModes : public testing::Test
495497
void AbortSystemController()
496498
{
497499
abortSystemControllerRequested = true;
498-
participantThread_SystemController.shutdownFuture.get();
500+
participantThread_SystemController.shutdownFuture.wait_for(TEST_TIMEOUT);
499501
if (participantThread_SystemController.thread.joinable())
500502
{
501503
participantThread_SystemController.thread.join();
@@ -595,7 +597,7 @@ class ITest_Internals_ParticipantModes : public testing::Test
595597
{
596598
try
597599
{
598-
shutdownFuture.wait();
600+
(void)shutdownFuture.wait_for(TEST_TIMEOUT);
599601
}
600602
catch (...)
601603
{
@@ -623,6 +625,8 @@ class ITest_Internals_ParticipantModes : public testing::Test
623625
{
624626
if (thread.shutdownFuture.valid())
625627
{
628+
auto&& status = thread.shutdownFuture.wait_for(TEST_TIMEOUT);
629+
ASSERT_EQ(status, std::future_status::ready); // signal failure
626630
thread.shutdownFuture.get();
627631
}
628632
}

0 commit comments

Comments
 (0)