From: Martin Quinson Date: Sat, 13 Feb 2021 08:14:59 +0000 (+0100) Subject: Improve the behavior of wait_for(0), and activate some tests X-Git-Tag: v3.27~394 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/fe9bc43645009c208f366d61193cd2e940b6e2ca Improve the behavior of wait_for(0), and activate some tests This only fixes some of the tests, some remain broken. There must be other bugs around. --- diff --git a/src/kernel/activity/ActivityImpl.cpp b/src/kernel/activity/ActivityImpl.cpp index def6d95fbe..6c26b6386c 100644 --- a/src/kernel/activity/ActivityImpl.cpp +++ b/src/kernel/activity/ActivityImpl.cpp @@ -80,8 +80,12 @@ void ActivityImpl::wait_for(actor::ActorImpl* issuer, double timeout) /* If the synchro is already finished then perform the error handling */ if (state_ != simgrid::kernel::activity::State::RUNNING) finish(); - else { - /* we need a sleep action (even when there is no timeout) to be notified of host failures */ + else if (timeout == 0.) { + // still running and timeout == 0 ? We need to report a timeout + state_ = simgrid::kernel::activity::State::TIMEOUT; + finish(); + } else { + /* we need a sleep action (even when the timeout is infinite) to be notified of host failures */ set_timeout(timeout); } } diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index 382ed6eca7..0e380119ca 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -80,7 +80,7 @@ ExecImpl& ExecImpl::set_hosts(const std::vector& hosts) ExecImpl& ExecImpl::set_timeout(double timeout) { - if (timeout > 0 && not MC_is_active() && not MC_record_replay_is_active()) { + if (timeout >= 0 && not MC_is_active() && not MC_record_replay_is_active()) { timeout_detector_.reset(hosts_.front()->pimpl_cpu->sleep(timeout)); timeout_detector_->set_activity(this); } diff --git a/teshsuite/s4u/activity-lifecycle/testing_test-wait.cpp b/teshsuite/s4u/activity-lifecycle/testing_test-wait.cpp index 0e15dcd1e3..9dd62c01e5 100644 --- a/teshsuite/s4u/activity-lifecycle/testing_test-wait.cpp +++ b/teshsuite/s4u/activity-lifecycle/testing_test-wait.cpp @@ -224,10 +224,12 @@ TEST_CASE("Activity test/wait: using >") XBT_INFO("#####[ launch next test ]#####"); RUN_SECTION("exec: run and wait<0> once", test_trivial>); - // exec: run and wait<0> many + RUN_SECTION("exec: run and wait<0> many", test_basic>); RUN_SECTION("exec: cancel and wait<0>", test_cancel>); - // exec: actor failure and wait<0> / sleep - // exec: host failure and wait<0> / sleep + RUN_SECTION("exec: actor failure and wait<0> / sleep", + test_failure_actor, waiter_sleep6>); + RUN_SECTION("exec: host failure and wait<0> / sleep", + test_failure_host, waiter_sleep6>); // exec: actor failure and wait<0> / wait // exec: host failure and wait<0> / wait @@ -299,14 +301,6 @@ TEST_CASE("Activity test/wait: tests currently failing", "[.][failing]") // with tester_wait<0> // -> wait_for() should return immediately and signal a timeout (timeout == 0) - RUN_SECTION("exec: run and wait<0> many", test_basic>); - // -> wait_for() should return immediately and signal a timeout (timeout == 0) - RUN_SECTION("exec: actor failure and wait<0> / sleep", - test_failure_actor, waiter_sleep6>); - // -> wait_for() should return immediately and signal a timeout (timeout == 0) - RUN_SECTION("exec: host failure and wait<0> / sleep", - test_failure_host, waiter_sleep6>); - // -> wait_for() should return immediately and signal a timeout (timeout == 0) RUN_SECTION("exec: actor failure and wait<0> / wait", test_failure_actor, waiter_wait>); // -> wait_for() should return immediately and signal a timeout (timeout == 0)