From 001f5168086fc05c4c40698cb9693ec599f72cc5 Mon Sep 17 00:00:00 2001 From: Coldwings Date: Wed, 22 Jul 2026 07:10:42 +0800 Subject: [PATCH] test(coro): stabilize task group completion regression --- tests/unit/test_task_group.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_task_group.cpp b/tests/unit/test_task_group.cpp index 8e4da115..008e91f6 100644 --- a/tests/unit/test_task_group.cpp +++ b/tests/unit/test_task_group.cpp @@ -1159,11 +1159,21 @@ TEST_CASE("task_group publishes completion after child state release", } } pause_guard; elio::sync::event enter_join; + elio::sync::event allow_child_failure; + std::atomic child_running_on_worker_1{false}; + std::atomic owner_running_on_worker_0{false}; std::atomic failure_observed{false}; - auto owner = sched.go_joinable([&]() -> task { + auto owner = sched.go_joinable_to(0, [&]() -> task { + co_await elio::set_affinity(0); + owner_running_on_worker_0.store( + elio::current_worker_id() == 0, std::memory_order_release); task_group group; - group.spawn([]() -> task { + group.spawn([&]() -> task { + co_await elio::set_affinity(1); + child_running_on_worker_1.store( + elio::current_worker_id() == 1, std::memory_order_release); + co_await allow_child_failure.wait(); throw std::runtime_error("child failure"); co_return; }); @@ -1176,6 +1186,8 @@ TEST_CASE("task_group publishes completion after child state release", } }); + const bool child_running = wait_for_flag(child_running_on_worker_1); + allow_child_failure.set(); const bool completion_paused = wait_for_flag( elio::coro::detail::task_group_completion_paused_for_test); enter_join.set(); @@ -1189,6 +1201,8 @@ TEST_CASE("task_group publishes completion after child state release", }); const bool shutdown_ok = sched.shutdown(std::chrono::seconds(5)); + REQUIRE(child_running); + REQUIRE(owner_running_on_worker_0); REQUIRE(completion_paused); REQUIRE(join_observed_pending); REQUIRE(owner_destroyed);