diff --git a/tests/ScheduleOnTest.cpp b/tests/ScheduleOnTest.cpp index f458a99dd16ed3557d7c9d848334bcb406c23598..6b7f5ceb69e095d42a84103bca27e1dd6805e7d4 100644 --- a/tests/ScheduleOnTest.cpp +++ b/tests/ScheduleOnTest.cpp @@ -1,6 +1,10 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright © 2021 Florian Fischer +#include <chrono> +#include <thread> + #include "CountingPrivateSemaphore.hpp" +#include "Emper.hpp" #include "Fiber.hpp" #include "Runtime.hpp" #include "Worker.hpp" @@ -25,7 +29,12 @@ static void scheduleOnTest() { ASSERT(runtime); workerCount = runtime->getWorkerCount(); - emper::sleep(1); + // Wait so all workers can suspend themselves + if constexpr (emper::IO) { + emper::sleep(1); + } else { // We can not sleep using emper mechanisms -> block the worker thread + std::this_thread::sleep_for(std::chrono::seconds(1)); + } CPS cps(1); runtime->scheduleOn(*Fiber::from([&] { runOn(cps); }), (iteration % workerCount));