Skip to content

zephyr: Add CI to run tests against zephyr with qemu. #15678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 28, 2024

Conversation

dpgeorge
Copy link
Member

Summary

Prior to this PR, the zephyr port was only compiled under CI, but no tests were run. There was some provision to run tests on zephyr using make-bin-testsuite, but this hasn't been working since the zephyr port moved fully to cmake (and it was never run under CI, only manually).

With this change, the zephyr port is tested against the standard test suite via the following scheme:

  • the zephyr port is built with the qemu_cortex_m3 board and the prj_minimal.conf configuration
  • qemu-system-arm runs zephyr.elf
  • the zephyr console is redirected to a pts/pty
  • tests/run-tests.py is run in bare-metal mode against the pts/pty device

This allows testing the zephyr port as though it were a physical board attached over a serial port.

Testing

CI has been added and should run and pass.

Trade-offs and Alternatives

The existing tinytest framework for the zephyr port has been removed in favour of this new approach of running qemu-system-arm and redirecting console to a pts/pty device, then running run-tests.py against that serial device. This makes running the tests just like any other bare-metal or unix port.

I don't think it's worth continuing to maintain the tinytest framwork on the zephyr port because it's currently broken and needs effort to fix, it's different to everything else, puts an extra burden on the maintainers, and one day won't fit the test suite because it will overflow flash.

Copy link

codecov bot commented Aug 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.43%. Comparing base (a8d1c25) to head (c8838b5).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #15678   +/-   ##
=======================================
  Coverage   98.43%   98.43%           
=======================================
  Files         163      163           
  Lines       21295    21295           
=======================================
  Hits        20961    20961           
  Misses        334      334           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS

@dpgeorge dpgeorge force-pushed the zephyr-add-ci-testing branch 5 times, most recently from 4504e6d to 22bd182 Compare August 19, 2024 03:59
@dpgeorge dpgeorge requested a review from jimmo August 19, 2024 04:16
@projectgus projectgus self-requested a review August 27, 2024 03:44
Copy link
Contributor

@projectgus projectgus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less code, more test coverage! 🚀

@dpgeorge dpgeorge force-pushed the zephyr-add-ci-testing branch from 22bd182 to 36a5d67 Compare August 27, 2024 04:35
The pts line printed by qemu-system-arm goes to stdout, not stderr.

Redirect stderr to stdout in case other tools do print to stderr.

Signed-off-by: Damien George <damien@micropython.org>
Both of these tests require slice to be enabled.

Signed-off-by: Damien George <damien@micropython.org>
Commit f573e73 rewored the zephyr port to
build MicroPython as a cmake target, and since that commit the
`make-bin-testsuite` helper script no longer works (it requires a Makefile)
and hence the tinytest test framework can no longer be run.

Instead of fixing this, remove the option to use tinytest.  Boards running
zephyr can use the standard `tests/run-tests.py` script to run tests in the
usual way.

Signed-off-by: Damien George <damien@micropython.org>
It needs to be at least this big for `tools/pyboard.py` to work, which is
used (among other things) by `tests/run-tests.py`.

Signed-off-by: Damien George <damien@micropython.org>
With this change, the zephyr port is tested against the standard test suite
via the following scheme:
- the zephyr port is built with the `qemu_cortex_m3` board and the
  `prj_minimal.conf` configuration
- `qemu-system-arm` runs `zephyr.elf`
- the zephyr console is redirected to a pts/pty
- `tests/run-tests.py` is run in bare-metal mode against the pts/pty device

This allows testing the zephyr port as though it were a physical board
attached over a serial port.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge force-pushed the zephyr-add-ci-testing branch from 36a5d67 to c8838b5 Compare August 28, 2024 01:24
@dpgeorge dpgeorge merged commit c8838b5 into micropython:master Aug 28, 2024
66 checks passed
@dpgeorge dpgeorge deleted the zephyr-add-ci-testing branch August 28, 2024 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants