test(ekf2): init the hrt in EKF2SelectorTest

The test starts the hrt worker without hrt_init(), so the callout lock
stays a default non-recursive mutex and the worker deadlocks on its own
nested lock in hrt_tim_isr() -> hrt_call_invoke() the first time a tick
fires. The selector's 10 ms backup reschedule normally keeps pushing the
tick out, so it only fires when Run() pauses under load or in the slower
Coverage build, where it hangs the test until the ctest timeout.
VehicleAirDataTest and VehicleMagnetometerTest already do this.

Refs #28862

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
(cherry picked from commit 2ce73120bd)
This commit is contained in:
Ramon Roche committed 2026-11-16 07:26:09 -08:00
1 parent fac92f5be3
commit 7bc8abd8be
1 file changed
+6 -1
+6 -1
View File
@@ -42,6 +42,7 @@
#include "EKF2Selector.hpp"
#include <drivers/drv_hrt.h>
#include <hrt_work.h>
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/px4_work_queue/WorkQueueManager.hpp>
@@ -90,7 +91,11 @@ public:
if (!wq_manager_started) {
// the gtest harness starts no platform threads: the hrt callout
// worker must exist before the selector's delayed self-scheduling
// runs, or the work queue blocks on an uninitialized semaphore
// runs, or the work queue blocks on an uninitialized semaphore.
// Without hrt_init() the callout lock is not recursive, so the
// worker deadlocks on its own nested lock the first time a
// callout is due
hrt_init();
hrt_work_queue_init();
ASSERT_EQ(px4::WorkQueueManagerStart(), 0);
wq_manager_started = true;