Files
infix/test/case/hardware/gps_simple
Joachim Wiberg cf08b577ed test: gps_simple: wait for full position data before has_fix()
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>
2026-03-20 17:05:36 +01:00
..
2026-03-05 08:21:34 +01:00
2026-03-05 08:21:34 +01:00
2026-03-05 08:21:34 +01:00

=== GPS receiver basic test

ifdef::topdoc[:imagesdir: {topdoc}../../test/case/hardware/gps_simple]

==== Description

Verify that two simulated GPS receivers are detected and report valid
fixes via the ietf-hardware operational datastore.

The test injects NMEA sentences through QEMU pipe chardev FIFOs,
which appear as virtio serial ports inside the guest.

==== Topology

image::topology.svg[GPS receiver basic test topology, align=center, scaledwidth=75%]

==== Sequence

. Set up topology and attach to target DUT
. Configure GPS hardware components
. Verify both GPS receivers are activated
. Verify both GPS receivers report full position data
. Verify both GPS receivers have a satellite fix
. Verify gps0 position is near the coordinates
. Verify gps1 position is near the coordinates
. Save the configuration to startup configuration and reboot
. Verify both GPS receivers are activated
. Verify both GPS receivers report full position data
. Verify both GPS receivers have a satellite fix
. Verify gps0 position is near the coordinates
. Verify gps1 position is near the coordinates