-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support/testing: add gpsd runtime testing
Signed-off-by: Julien Olivain <[email protected]> Signed-off-by: Thomas Petazzoni <[email protected]>
- Loading branch information
1 parent
4649372
commit 9c8f6dc
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
import time | ||
|
||
import infra.basetest | ||
|
||
|
||
class TestGpsd(infra.basetest.BRTest): | ||
rootfs_overlay = \ | ||
infra.filepath("tests/package/test_gpsd/rootfs-overlay") | ||
# This test is using the gpsfake Python script. | ||
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ | ||
f""" | ||
BR2_PACKAGE_GPSD=y | ||
BR2_PACKAGE_PYTHON3=y | ||
BR2_ROOTFS_OVERLAY="{rootfs_overlay}" | ||
BR2_TARGET_ROOTFS_CPIO=y | ||
# BR2_TARGET_ROOTFS_TAR is not set | ||
""" | ||
|
||
def test_run(self): | ||
cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") | ||
self.emulator.boot(arch="armv5", | ||
kernel="builtin", | ||
options=["-initrd", cpio_file]) | ||
self.emulator.login() | ||
|
||
# We check the program can execute. | ||
self.assertRunOk("gpsd --version") | ||
|
||
# Since gpsd needs a real GPS device, we stop the service. | ||
self.assertRunOk("/etc/init.d/S50gpsd stop") | ||
|
||
# We start the "gpsfake" GPS emulator instead. | ||
cmd = "gpsfake" | ||
cmd += " --slow --cycle 0.1 --quiet" | ||
cmd += "/root/udp-nmea.log &> /dev/null &" | ||
self.assertRunOk(cmd) | ||
|
||
# Wait a bit, to let the gpsfake and gpsd to settle... | ||
time.sleep(3 * self.timeout_multiplier) | ||
|
||
# List the GPS devices. We should see our local UDP test GPS. | ||
out, ret = self.emulator.run("gpsctl") | ||
self.assertEqual(ret, 0) | ||
self.assertTrue(out[0].startswith("udp://127.0.0.1")) | ||
self.assertIn("NMEA0183", out[0]) | ||
|
||
# Collect some of our fake GPS data, and check we got the | ||
# coordinates from our test data file. | ||
# Our expected coordinates are: | ||
# https://www.openstreetmap.org/#map=19/43.60439/1.44336 | ||
out, ret = self.emulator.run("gpscsv --header 0 --count 3") | ||
self.assertEqual(ret, 0) | ||
_, gps_lat, gps_long, _ = out[0].split(",") | ||
self.assertAlmostEqual(float(gps_lat), 43.60439) | ||
self.assertAlmostEqual(float(gps_long), 1.44336) |
6 changes: 6 additions & 0 deletions
6
support/testing/tests/package/test_gpsd/rootfs-overlay/root/udp-nmea.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Name: NMEA 0183 messages for gpsd Buildroot test | ||
# Transport: UDP | ||
# For packet format, see: | ||
# https://gpsd.gitlab.io/gpsd/NMEA.html | ||
$GPGGA,123456.789,4336.2634,N,0126.6016,E,1,04,1.7,143.5,M,,,,*3A | ||
$GPZDA,123456.789,20,07,2024,2,00*64 |