Skip to content

Commit

Permalink
testing: prevent test scheduling after reactor exit
Browse files Browse the repository at this point in the history
Previously, when handling "--help" (introduced in b8a13be), we returned
status code 0 but continued scheduling test tasks to the Seastar reactor.
This caused test applications to hang since the tasks expected the exchanger
'e' to be available after reactor exit.

Fix this by using the "_done" flag to track reactor state:
- Set "_done" when Seastar application exits
- Skip task scheduling and exchanger wait if "_done" is set
- Reuse existing "_done" member as it's safe in single-threaded context

This fixes the regression where "--help" would cause test applications to
hang indefinitely.

Fixes #2635
Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Feb 17, 2025
1 parent 3f8bdf5 commit c689479
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/testing/test_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ int test_runner::start_thread(int ac, char** av) {
return 0;
});
});
_done = true;
init_outcome->give(_exit_code);
});

Expand All @@ -130,6 +131,11 @@ test_runner::run_sync(std::function<future<>()> task) {
// it.
return;
}
if (_done) {
// if "--help" is passed to the seastar app in the command line, _done is
// set before the seastar worker thread takes any task.
return;
}

exchanger<std::exception_ptr> e;
_task.give([task = std::move(task), &e] {
Expand Down

0 comments on commit c689479

Please sign in to comment.