libnmea-esp32
libnmea-esp32 copied to clipboard
WIP: adding test with pytest-embedded
To test:
-
with
pytest
:-
echo CONFIG_EXAMPLE_UART_NUM=0
> sdkconfig -
idf.py build
-
pytest
Result is that the message sent via dut.write gets logged on console, but the app doesn't receive it:2022-01-07 11:56:16 INFO Example ready, receiving on UART0, GPIO21 at 9600 baud 2022-01-07 11:56:16 INFO $GPRMC,170058.89,V,3554.928,N,08002.496,W,9.4,1.57,050521,,E*41
-
-
launch qemu manually:
-
echo CONFIG_EXAMPLE_UART_NUM=0
> sdkconfig -
idf.py build
- generate build/flash_image.bin
-
qemu-system-xtensa -nographic -machine esp32 -drive file=build/flash_image.bin,if=mtd,format=raw
When the program starts up, type something on the console and press enter:Example ready, receiving on UART0, GPIO21 at 9600 baud Read 15 bytes (15 total) $ not found yet Read 1 bytes (1 total) $ not found yet
-
ah, I forgot to add the dut.write
function... fixed here: https://github.com/espressif/pytest-embedded/pull/41
also need to modify the test script a bit. the dut.expect
would turn the string into a regex. so if you want to compare string directly, should use expect_exact
instead.
dut.expect_exact("""
GPRMC sentence
Longitude:
Degrees: 80
Minutes: 2.496000
Cardinal: W
Latitude:
Degrees: 35
Minutes: 54.928000
Cardinal: N
Date & Time: 05 May 17:00:58 2021
Speed, in Knots: 9.400000
Track, in degrees: 1.570000
Magnetic Variation:
Degrees: 0.000000
Cardinal: E
Adjusted Track (heading): 1.570000
""".strip())
Now this should work, tested locally.