mavsdk tests: use tester sleep_for function #24266
Open
+36
−42
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Solved Problem
Some mavsdk tests currently have hardcoded sleep statements using
std::this_thread::sleep_for
. This leads to test behaviour depending heavily on the speed with which the simulation runs -- if we run at a large speed factor, a (real-time) sleep of only a few seconds may already trigger all kinds of timeouts in PX4.Solution
We instead use the function
AutopilotTester::sleep_for
which sleeps w.r.t. PX4 simulation time, not host system time. This should lead to more reliable test behaviour across different speed factors.Alternatives
Open to all suggestions & reasons why this might not be such a great idea.
Context
Should we set up some CI warning that reminds anyone putting real-time sleeps in tests of this footgun?