Skip to content

Commit

Permalink
spawn_test: prolong termination time to be more tolerant.
Browse files Browse the repository at this point in the history
pidfd_open(2) can fail on old kernels due to several reasons (e.g.
syscall not supported, O_NONBLOCK flags not supported), in which
case process:wait() falls back to waitpid(2) with backoff (at least
20ms), which may make it longer than 10ms.

Here we add the minimal backoff to 10ms so that the test can pass
on old kernels.

Signed-off-by: Jianyong Chen <baluschch@gmail.com>
  • Loading branch information
balusch committed Feb 9, 2023
1 parent 4021203 commit 26b4d55
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/unit/spawn_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,14 @@ SEASTAR_TEST_CASE(test_spawn_kill) {
auto* wait_signaled = std::get_if<experimental::process::wait_signaled>(&wait_status);
BOOST_REQUIRE(wait_signaled != nullptr);
BOOST_CHECK_EQUAL(wait_signaled->terminating_signal, SIGTERM);
// sleep should be terminated in 10ms
auto end = std::chrono::high_resolution_clock::now();
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
BOOST_CHECK_LE(ms, 10);
// sleep should be terminated in 10ms.
// pidfd_open(2) may fail and thus p.wait() falls back to
// waitpid(2) with backoff (at least 20ms).
// the minimal backoff is added to 10ms, so the test can pass on
// older kernels as well.
BOOST_CHECK_LE(ms, 10 + 20);
});
});
}

0 comments on commit 26b4d55

Please sign in to comment.