feat(kao): add support for bao kao testing framework - #363
Conversation
6f43b3a to
2ef3a2a
Compare
010c9b8 to
fe6b4ea
Compare
|
|
||
| tests: | ||
| @echo "Running bao-kao tests for $(PLATFORM)..." | ||
| @python3 $(kao_dir)/kao.py -t -p $(PLATFORM) |
There was a problem hiding this comment.
We're not passing --hyp-srcs, so kao clones bao-hypervisor at tag v2.0.0 and tests that instead of the branch. You can see it in the last CI run: [INFO] Fetching hypervisor sources..., which only prints when it actually clones. So the green ticks here are on the release, not on this PR.
The flag already exists and is wired up, so I think it's just:
| @python3 $(kao_dir)/kao.py -t -p $(PLATFORM) | |
| @python3 $(kao_dir)/kao.py -t -p $(PLATFORM) --hyp-srcs $(cur_dir) |
I'd also make the no-arg case not silently clone, otherwise anyone calling kao.py directly hits the same thing.
Note this has to go together with removing the make clean kao does on the hypervisor sources, otherwise every make tests will wipe your build/ and bin/.
There was a problem hiding this comment.
Fixed in ff5c6e2.
Aditionally, this required changes in bao-kao (bao-project/bao-kao@322e337)
|
|
||
| .PHONY: tests | ||
|
|
||
| tests: |
There was a problem hiding this comment.
There's no way to pass anything else to kao from here (test ids, -l, --no-firmware-build). Can we forward these?
The old tests.mk did this already:
LOG_LEVEL?=2
ECHO?=tf
SETUP?=baremetal
TEST?=bootand passed them all through, so you could do make ... TEST=irq LOG_LEVEL=1. I'd keep that, either the same way or with a single KAO_ARGS.
Also if tests/kao isn't initialized this fails with a bare python3: can't open file.
|
|
||
| endif | ||
|
|
||
| -include $(tests_dir)/tests.mk |
There was a problem hiding this comment.
This includes a file that isn't in the tree and then we define the targets inline anyway. It's a leftover: tests/tests.mk existed on feat/test-framework (67b6c7f) and was dropped in the rewrite, but the include stayed.
Either remove the include, or put the targets back in tests/tests.mk where they were. I'd lean to the second. This is bao's build system and these are orchestrating an external runner, and -include also degrades nicely when the submodule isn't initialized. If you do that the include has to move up near line 73, because non_build_targets is consumed at line 82.
As it is now there's also a trap: if someone re-adds tests/tests.mk with a tests: recipe, make will warn about overriding and the inline one silently wins.
|
|
||
| benchs: | ||
| @echo "Running bao-kao benchmarks for $(PLATFORM)..." | ||
| @python3 $(kao_dir)/kao.py -b -p $(PLATFORM) |
There was a problem hiding this comment.
If the benchmarks submodule goes away from this repo (see my comment in .gitmodules), this target should probably go with it.
Right now with no benchs checked out kao finds no benchmarks and exits 0 without doing anything, so make benchs looks like it worked.
|
|
||
| run-tests: | ||
| runs-on: ubuntu-latest | ||
| container: |
There was a problem hiding this comment.
Every other workflow goes through ./.github/actions/bao-container-run now. It was added in a97c302 because the image is too big to pull under container: on the free runners (bao-ci#94). This one predates it, so it just needs to move over. The branch is 35 commits behind main anyway, so it needs a rebase first.
After that --user root and the safe.directory step below aren't needed, the action does both.
| } \ | ||
| } while (0) | ||
|
|
||
| #define TESTF_PASS(message) printf(" Message: %s\n", message); |
There was a problem hiding this comment.
This one isn't guarded by TESTF_LOG_LEVEL like the rest of the pass-side output, so it prints even at level 0. I ran with level 1 and everything went quiet except this line.
| # Bao Hypervisor VM Configuration | ||
| # This YAML describes the fields needed to generate a C config file (config.c) | ||
|
|
||
| vms: |
There was a problem hiding this comment.
Question, not a change request: what do we get from the yaml + jinja over just writing config.c?
One yaml per (setup, platform) is one config.c per (setup, platform), so it's not fewer files, and nothing in the output is actually dynamic. Every value comes from the yaml, and BAO_WRKDIR_IMGS is resolved by the preprocessor, not the template. It's also missing things we'd want to test: cpu_affinity, colors, ipcs, remio_devs, mmu. And s32z270 already ships a hand-written plat.c next to its yaml.
Is the idea (a) to describe VMs separately and compose them for multi-guest setups, or (b) to be able to generate configs for another hypervisor? args[2].split("+") already builds a guest list so (a) looks intended, but the config lookup is still per-combination. If it is (a), does it also do the allocation (non-overlapping regions, cpu partitioning)? Just concatenating two VM configs doesn't really save anything.
Either way it should be in the README, because from outside it isn't obvious what it's for.
There was a problem hiding this comment.
This was a design choice; its main purpose is to make a test scenario a single, declarative unit: the Bao configuration together with the guest/build parameters needed to reproduce that scenario. In that sense, a YAML file describes more than the contents of config.c. It is intended to be the input consumed by the test/build tooling, while the generated config.c is one target-specific artifact of that description. This also gives us a path to emit equivalent scenario configurations for other hypervisors, rather than making the benchmark/test definitions inherently Bao-specific.
That said, the current implementation does not yet fully realize the compositional model you describe:
args[2].split("+")was introduced with multi-guest scenarios in mind, but configuration selection is still effectively per (setup, platform) combination.- It does not currently compose independently defined VM descriptions and perform resource allocation or validation (for example, CPU partitioning, non-overlapping memory regions, cache colors, IPCs, remote-I/O devices, or MMU settings).
So the intended answer is closer to (a) as a longer-term scenario-description direction, plus (b) as an eventual portability benefit, rather than a claim that the current YAML files already provide full VM composition or allocation. Today, they mainly centralize the scenario metadata/configuration used by the test infrastructure and generate a Bao-specific configuration from it.
|
|
||
| vms: | ||
| - vm1: | ||
| name: "baremetal" |
There was a problem hiding this comment.
This is a byte-for-byte copy of the baremetal one, including name: "baremetal", so the freertos config declares a baremetal VM. Same for the linux one. Nothing can select them either, build_guests only knows baremetal.
Can we drop both directories from this PR and bring them back with the guest builders behind them?
|
|
||
| vms: | ||
| - vm1: | ||
| name: "baremetal" |
| @@ -0,0 +1,1241 @@ | |||
| /* | |||
| * Copyright 2021-2024 NXP | |||
There was a problem hiding this comment.
This BSP is 79 files and 33.5k lines, which is around 63% of the PR, for a board that isn't in the CI matrix and needs a T32 probe anyway. It's also a different license from ours and tests/ is outside license-check's scope, so nothing verifies it.
Can we leave s32z270 for a follow-up, or move the BSP to its own repo as a submodule like benchs? It would make this PR much easier to review.
| irq_set_prio(UART_IRQ_ID, UART_IRQ_PRIO); | ||
| COMMAND_SEND_CHAR("a"); | ||
|
|
||
| timer_wait(TEST_TIME_WAIT); |
There was a problem hiding this comment.
The TIMER test above spins on the flag with the watchdog as backstop, but this one sleeps 200ms and asserts. The injected char goes through the logger thread and a pty, so on a loaded runner 200ms can be missed and the test goes red on timing alone. Can we make it spin on irq_en_uart like TIMER does? The watchdog already bounds it.
Signed-off-by: Daniel Oliveira <drawnpoetry@gmail.com> Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com> Signed-off-by: Miguel Silva <miguelafsilva5@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Daniel Oliveira <drawnpoetry@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
8922c08 to
fce6be8
Compare
|
@Diogo21Costa can you go comment by comment and say which points of the review are addressed by the latest push, and if relevant, provide futher information. For those not addressed and we which you don't plan to address, please explain we don't think they should be. |
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
@josecm Matched each of the comments with the specific fixes. While validating the review changes, make tests PLATFORM=qemu-riscv64-virt exposed additional integration problems. These were addressed by: with corresponding Bao Kao commits: |
Overview
This PR integrates Bao Kao (abbreviated as bkao, "to put to the test"), an end-to-end testing (and benchmarking) framework for the Bao Hypervisor. Bao Kao automates the full pipeline from source build to on-target execution: it fetches toolchains, builds guest workloads, generates Bao configuration files based on targeted setup from YAML descriptors, assembles a bootable image (with optional firmware), launches it on the target platform (emulated or physical), and captures serial output to determine pass/fail.
Two new submodules are introduced:
Platforms supported:
Note
This PR supersedes #154. We have refactored completely the framework, removing nix support and leveraging only python to implement bao kao.
Source Tree Structure
Tests Available
Tests are defined using the
BAO_TEST(suite, test, setup, description)macro and discovered automatically at runtime by scanningtests/tests/src/*.c. Each test is tagged with a suite, a setup (which selects the VM configuration to use), and an ID used for selective execution.IDs are computed as
(file_index × 100) + test_index_within_file, where:tests/tests/src/
So with the current files (boot.c, irq.c):
Guest types supported in test configs: baremetal, freertos, linux. For now, we only target a baremetal setup.
How to Run (TLDR)
Via bao Makefile targets:
Run all tests for a platform:
make tests PLATFORM=<platform>Run all benchmarks for a platform:
make benchs PLATFORM=<platform>Other options only via calling bkao-py directly:
Run specific tests or benchmarks by ID:
python3 tests/bkao/src/bkao.py -t 100 101 -p <platform>python3 tests/bkao/src/bkao.py -b 100 -p <platform>Run all tests except some:
python3 bkao.py -t -x 200,201 -p <platform>Skip firmware and toolchain rebuild (faster iteration):
python3 bkao.py -t -p <platform> --no-firmware-build --no-toolchain-buildUse custom hypervisor sources:
python3 bkao.py -t -p <platform> --hyp-srcs /path/to/baoSet verbosity (0=final report only, 1=failures, 2=all):
python3 bkao.py -t -p <platform> -l 2Pass platform-specific args - only virtual platforms (e.g. GIC version):
python3 bkao.py -t -p qemu-aarch64-virt --plat-virt-args "GICV3"Bao Kao Process Pipeline
For each test or benchmark, bkao executes the following pipeline:
tests/tests/src/*.cforBAO_TESTmacros,benchs/src/benchmarks/for benchmark dirs, andplatforms/*.pyfor platform builders.[TESTF-C]tokens for pass/fail.