Commit 06f049a
committed
test: gps_simple: wait for full position data before verify_position()
has_fix() only checks that fix-mode is set (2d/3d), but altitude and
other fields may not yet be populated in the operational datastore when
gpsd is still processing its first NMEA cycles after boot. Calling
verify_position() immediately after has_fix() passes can therefore race
and fail with:
KeyError: 'altitude'
This manifests reliably on the second GPS receiver (gps1) after reboot,
because it is initialized slightly later than gps0 and hits the window
where fix-mode is set but altitude has not yet appeared.
not ok 11 - Verify gps1 position is near the coordinates
# Traceback (most recent call last):
# File "test/case/hardware/gps_simple/test.py", line 29, in verify_position
# alt = float(state["altitude"])
# ~~~~~^^^^^^^^^^^^
# KeyError: 'altitude'
Add has_position() to infamy/gps.py, which gates on fix-mode AND all
position fields (latitude, longitude, altitude, satellites-used) being
present. Replace the has_fix() polls in both the pre- and post-reboot
verify steps with has_position().
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>1 parent 1c6c772 commit 06f049a
2 files changed
Lines changed: 14 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
89 | | - | |
| 88 | + | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
| 110 | + | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
0 commit comments