mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-10-06 09:02:52 +08:00
refactor(navigator): add test to confirm that new data invalidates old data
This commit is contained in:
@@ -94,6 +94,10 @@ public:
|
||||
/** True after queuing, reading, or validating the current mission land item failed. */
|
||||
bool missionLandItemAttemptFailed() const { return _mission_land.retry.retry_count > 0; }
|
||||
|
||||
/**
|
||||
* Returns the item count of the complete, validated safe-point generation.
|
||||
* Returns zero while a replacement is pending (check safePointsReady()) and for a ready empty set.
|
||||
*/
|
||||
int safePointCount() const override;
|
||||
bool loadSafePointItem(int index, mission_item_s &safe_point_item) const override;
|
||||
|
||||
|
||||
@@ -325,8 +325,17 @@ TEST_F(MissionRouteCacheTest, SafePointIdChangeReloadsReplacementSet)
|
||||
mission.safe_points_id = 101;
|
||||
mission.timestamp = hrt_absolute_time();
|
||||
|
||||
// A source change immediately hides the old generation instead of blocking or exposing stale data.
|
||||
_cache.update(mission);
|
||||
EXPECT_EQ(_cache.safePointsId(), mission.safe_points_id);
|
||||
EXPECT_FALSE(_cache.safePointsReady());
|
||||
EXPECT_TRUE(_cache.safePointUpdatePending());
|
||||
EXPECT_EQ(_cache.safePointCount(), 0);
|
||||
EXPECT_FALSE(_cache.loadSafePointItem(0, safe_point));
|
||||
|
||||
ASSERT_TRUE(MissionRouteCacheTestPeer::runCacheUntil(_cache, mission, [&] { return _cache.safePointsReady(); }))
|
||||
<< "safe-point cache did not become ready";
|
||||
EXPECT_FALSE(_cache.safePointUpdatePending());
|
||||
|
||||
// The stale set is replaced.
|
||||
ASSERT_TRUE(_cache.loadSafePointItem(0, safe_point));
|
||||
|
||||
Reference in New Issue
Block a user