Wire up orphaned GPS NMEA service into build and test suite - #83
Wire up orphaned GPS NMEA service into build and test suite#83Jayakrishnan9539 wants to merge 1 commit into
Conversation
Verified — orphaned code with a ported test is exactly the right trade
Spotting Confirmed the test is not a trivial pass: Four of the five are rejections, which is the right balance for a parser fed off-device input. Gating behind Merge orderThis conflicts with #82, which repairs Resolved that way locally: configure OK, 0 build errors, ctest 29/29, VerificationMerged onto |
srpatcha
left a comment
There was a problem hiding this comment.
Approving. Wiring up orphaned code and giving it a test is exactly the right
shape, and I verified it works rather than taking the diff's word for it.
GitHub reports this DIRTY, but the conflict is not in your change. Your branch
predates test_devicetree and the fuzz-target block being added to
tests/CMakeLists.txt, so the merge sees them as removed. Nothing in the GPS
work is involved.
Verified
Applied onto a base where master's duplicate crypto targets are repaired —
necessary, because on master today CMake fails at configure and no test target
generates at all, so CI here cannot run anything (#92 / #93):
0 build errors
100% tests passed, 0 tests failed out of 29 (28 before, +test_gps)
$ ctest -R gps
100% tests passed, 0 tests failed out of 1
[PASS] gps gprmc void fix
[PASS] gps gprmc rejects non-GPRMC sentence
[PASS] gps gprmc rejects null args
[PASS] gps gprmc rejects short sentence
All GPS NMEA tests passed.
The four negative cases are the valuable part. A parser test that only feeds it
well-formed sentences tells you the happy path works and nothing about what
happens when a real receiver emits a truncated line — which is the case that
actually occurs in the field.
if(UNIX AND NOT APPLE) target_link_libraries(test_gps PRIVATE m) is the correct
guard; Darwin folds libm into libSystem and linking m explicitly is at best
redundant there.
To resolve the conflict
Rebase onto current master and keep both sides — the test_devicetree block
and the add_subdirectory(fuzz) line from master, plus your test_gps block.
There is no semantic disagreement to settle; they are separate additions to the
same file.
One thing to watch when you do: applying your patch with --3way already inserts
the GPS block, so re-adding it by hand produces
add_executable cannot create target "test_gps" because another target with
the same name already exists.
I did exactly that while verifying, which is worth mentioning because it is the
same duplicate-target error that currently stops master configuring — an easy
one to reintroduce during a manual resolution.
6f42801 to
6f5048e
Compare
Problem
services/gps/src/gps_nmea.c implements NMEA $GPRMC sentence parsing
but was never wired into the build: services/CMakeLists.txt didn't
add_subdirectory the gps folder, there was no CMakeLists.txt for the
module itself, and no public header existed for eos_gps_parse_gprmc.
A leftover tests_backup/test_gps_nmea.py (a Python mock of the same
logic) suggests a real test for this module was planned but never
finished — the module was completely untested and unreachable.
Approach
API, following the header conventions used by sibling services.
EOS_ENABLE_GPS, matching how every other service module in this
repo is structured (e.g. services/sensor).
and wired it into services/CMakeLists.txt.
(tests/test_gps.c), registered in tests/CMakeLists.txt, with
additional coverage for invalid/void fixes and malformed input.
Math-library linkage is gated with if(UNIX AND NOT APPLE),
matching the existing pattern used by test_sensor/test_motor_ctrl.
Testing
Verified on two toolchains:
suite via ctest — 25/25 pass, including the new test_gps.
test_gps directly — all 5 assertions pass. (Note: the full suite
doesn't build under MSVC due to an unrelated pre-existing GCC-style
inline-asm usage in kernel/src/task.c — not touched by this PR.)
Limitations
This wires up and tests GPRMC parsing only. The driver-layer GPGGA
parser (drivers/src/gps_nmea.c) has a separate, similar gap and
could be a follow-up.