@@ -238,6 +238,7 @@ post_coro(io_context::executor_type& ex, std::coroutine_handle<> h)
238238 ex.post (h);
239239}
240240
241+ template <auto Backend>
241242struct io_context_test
242243{
243244 void testConstruction ()
@@ -278,7 +279,7 @@ struct io_context_test
278279 {
279280 io_context_options opts;
280281 opts.thread_pool_size = 4 ;
281- io_context ioc (opts, 2 );
282+ io_context ioc (Backend, opts, 2 );
282283 BOOST_TEST (!ioc.stopped ());
283284 }
284285
@@ -287,7 +288,7 @@ struct io_context_test
287288 // concurrency_hint == 1 enables single-threaded mode automatically.
288289 io_context_options opts;
289290 opts.single_threaded = true ;
290- io_context ioc (opts, 1 );
291+ io_context ioc (Backend, opts, 1 );
291292 BOOST_TEST (!ioc.stopped ());
292293
293294 int counter = 0 ;
@@ -300,7 +301,7 @@ struct io_context_test
300301
301302 void testGetExecutor ()
302303 {
303- io_context ioc;
304+ io_context ioc (Backend) ;
304305 auto ex = ioc.get_executor ();
305306
306307 // Executor should be valid
@@ -310,7 +311,7 @@ struct io_context_test
310311
311312 void testRun ()
312313 {
313- io_context ioc;
314+ io_context ioc (Backend) ;
314315 auto ex = ioc.get_executor ();
315316 int counter = 0 ;
316317
@@ -327,7 +328,7 @@ struct io_context_test
327328
328329 void testRunOne ()
329330 {
330- io_context ioc;
331+ io_context ioc (Backend) ;
331332 auto ex = ioc.get_executor ();
332333 int counter = 0 ;
333334
@@ -349,7 +350,7 @@ struct io_context_test
349350
350351 void testPoll ()
351352 {
352- io_context ioc;
353+ io_context ioc (Backend) ;
353354 auto ex = ioc.get_executor ();
354355 int counter = 0 ;
355356
@@ -373,7 +374,7 @@ struct io_context_test
373374
374375 void testPollOne ()
375376 {
376- io_context ioc;
377+ io_context ioc (Backend) ;
377378 auto ex = ioc.get_executor ();
378379 int counter = 0 ;
379380
@@ -405,7 +406,7 @@ struct io_context_test
405406
406407 void testStopAndRestart ()
407408 {
408- io_context ioc;
409+ io_context ioc (Backend) ;
409410 auto ex = ioc.get_executor ();
410411 int counter = 0 ;
411412
@@ -435,7 +436,7 @@ struct io_context_test
435436
436437 void testRunOneFor ()
437438 {
438- io_context ioc;
439+ io_context ioc (Backend) ;
439440 auto ex = ioc.get_executor ();
440441 int counter = 0 ;
441442
@@ -457,7 +458,7 @@ struct io_context_test
457458
458459 void testRunOneUntil ()
459460 {
460- io_context ioc;
461+ io_context ioc (Backend) ;
461462 auto ex = ioc.get_executor ();
462463 int counter = 0 ;
463464
@@ -488,7 +489,7 @@ struct io_context_test
488489 // is the deterministic form of a valgrind/CI flake where the thread
489490 // is preempted past the deadline before the first loop check, so
490491 // wait_one (which holds the "no work -> stop" logic) was skipped.
491- io_context ioc;
492+ io_context ioc (Backend) ;
492493
493494 auto past =
494495 std::chrono::steady_clock::now () - std::chrono::milliseconds (1 );
@@ -505,7 +506,7 @@ struct io_context_test
505506
506507 void testRunFor ()
507508 {
508- io_context ioc;
509+ io_context ioc (Backend) ;
509510 auto ex = ioc.get_executor ();
510511 int counter = 0 ;
511512
@@ -532,7 +533,7 @@ struct io_context_test
532533
533534 void testRunForWithOutstandingWork ()
534535 {
535- io_context ioc;
536+ io_context ioc (Backend) ;
536537 auto ex = ioc.get_executor ();
537538
538539 // Simulate persistent outstanding work (like a listening acceptor)
@@ -555,7 +556,7 @@ struct io_context_test
555556
556557 void testRunOneForWithOutstandingWork ()
557558 {
558- io_context ioc;
559+ io_context ioc (Backend) ;
559560 auto ex = ioc.get_executor ();
560561
561562 ex.on_work_started ();
@@ -576,7 +577,7 @@ struct io_context_test
576577
577578 void testExecutorRunningInThisThread ()
578579 {
579- io_context ioc;
580+ io_context ioc (Backend) ;
580581 auto ex = ioc.get_executor ();
581582
582583 // Not running yet - should return false
@@ -592,7 +593,7 @@ struct io_context_test
592593
593594 void testMultithreaded ()
594595 {
595- io_context ioc;
596+ io_context ioc (Backend) ;
596597 auto ex = ioc.get_executor ();
597598 std::atomic<int > counter{0 };
598599 constexpr int num_threads = 4 ;
@@ -636,7 +637,7 @@ struct io_context_test
636637
637638 for (int iter = 0 ; iter < iterations; ++iter)
638639 {
639- io_context ioc;
640+ io_context ioc (Backend) ;
640641 auto ex = ioc.get_executor ();
641642 std::atomic<int > counter{0 };
642643
@@ -696,7 +697,7 @@ struct io_context_test
696697 int destroyed = 0 ;
697698
698699 {
699- io_context ioc;
700+ io_context ioc (Backend) ;
700701 auto ex = ioc.get_executor ();
701702
702703 post_coro (ex, make_destroy_coro (destroyed));
@@ -726,7 +727,7 @@ struct io_context_test
726727 op2.cont .h = make_destroy_coro (destroyed);
727728
728729 {
729- io_context ioc;
730+ io_context ioc (Backend) ;
730731 auto ex = ioc.get_executor ();
731732
732733 ex.post (op1.cont );
@@ -744,7 +745,7 @@ struct io_context_test
744745 // iterates with rel_time clamped to 1s before returning 0.
745746 void testRunOneUntilLongDeadlineNoWork ()
746747 {
747- io_context ioc;
748+ io_context ioc (Backend) ;
748749
749750 // Deadline >1s but tiny outstanding work so wait_one is not
750751 // entered: scheduler is empty, wait_one immediately stops and
@@ -766,7 +767,7 @@ struct io_context_test
766767 // timing.
767768 void testMultithreadedNotifyAndWaitFor ()
768769 {
769- io_context ioc; // default hint => MT mode
770+ io_context ioc (Backend) ; // default hint => MT mode
770771 auto ex = ioc.get_executor ();
771772 std::atomic<int > counter{0 };
772773
@@ -821,7 +822,7 @@ struct io_context_test
821822 }
822823};
823824
824- TEST_SUITE (io_context_test, " boost.corosio.io_context" );
825+ COROSIO_BACKEND_TESTS (io_context_test, " boost.corosio.io_context" )
825826
826827// Backend-parameterized tests for shutdown paths that differ per backend
827828template <auto Backend>
0 commit comments