Files
micropython/tests/serial_test.py
Damien George 9939eae599 tests/serial_test.py: Add a serial echo test.
The existing `serial_test.py` script tests data in/out throughput and
reliability.  But it only tests data sizes that are a power of two, which
may not catch certain errors with USB transmission (because FS packet size
is 64 bytes).

This commit adds a new echo sub-test to the `serial_test.py` script.  It
sends out data to the target and gets the target to echo it back, and then
compares the result (the echo'd data should be equal to the sent data).  It
does this for data packets between 1 and 520 (inclusive) bytes, which
covers USB FS and HS packet sizes (64 and 512 respectively).

It uses random data for the test, but seeded by a constant seed so that
it's deterministic.  If there's an error then it prints out all the sent
and echo'd data to make it easier to see where it went wrong (eg if the
previous packet was repeated).

Signed-off-by: Damien George <damien@micropython.org>
2025-12-07 15:29:28 +11:00

9.4 KiB
Executable File