-
Notifications
You must be signed in to change notification settings - Fork 189
feat(kao): add support for bao kao testing framework #363
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
base: main
Are you sure you want to change the base?
Changes from all commits
224b439
5931c67
7d5849b
ce57353
ff5c6e2
d47ac0f
f69f2ce
1a690a5
664d043
707e9e4
3ec913a
3769011
902ebe4
54bfa12
10aeae7
ab070b9
f2f822f
cbcf574
0f69f50
0fcda4b
e17c3ab
80c2f98
dea359b
fce6be8
3b5464f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| name: Bao Kao Testing Framework | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
|
|
||
| jobs: | ||
|
|
||
| run-tests: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| platform: [ | ||
| "qemu-aarch64-virt", | ||
| "qemu-riscv64-virt", | ||
| "fvp-a", | ||
| "fvp-r" | ||
| ] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - name: Cache FVP model | ||
| if: startsWith(matrix.platform, 'fvp-') | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| tests/wrkdir/platforms/fvp_a/FVP_Model_A | ||
| tests/wrkdir/platforms/fvp_r/FVP_Model_R | ||
| key: ${{ runner.os }}-${{ matrix.platform }}-fvp-11.28_23 | ||
|
|
||
| - name: Run Bao Kao tests | ||
| uses: ./.github/actions/bao-container-run | ||
| with: | ||
| run: > | ||
| git config --global url.https://github.com/.insteadOf git@github.com: | ||
| && make tests PLATFORM=${{ matrix.platform }} | ||
| KAO_ARGS=--no-toolchain-build | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| bin/* | ||
| build/* | ||
| tests/wrkdir/ | ||
| *.o | ||
| *.elf | ||
| *.bin | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| [submodule "ci"] | ||
| path = ci | ||
| url = git@github.com:bao-project/bao-ci.git | ||
| [submodule "tests/kao"] | ||
| path = tests/kao | ||
| url = git@github.com:bao-project/bao-kao.git |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # Copyright (c) Bao Project and Contributors. All rights reserved | ||
|
|
||
| kao_dir:=$(tests_dir)/kao/src | ||
| kao_script:=$(kao_dir)/kao.py | ||
|
|
||
| KAO_TESTS?=all | ||
| KAO_ARGS?= | ||
|
|
||
| non_build_targets+=tests check-kao | ||
|
|
||
| .PHONY: check-kao | ||
| check-kao: | ||
| @if [ ! -f $(kao_script) ]; then \ | ||
| echo "Bao Kao is not initialized; run 'git submodule update --init --recursive tests/kao'."; \ | ||
| exit 1; \ | ||
| fi | ||
|
|
||
| .PHONY: tests | ||
| tests: check-kao | ||
| @echo "Running bao-kao tests for $(PLATFORM)..." | ||
| @python3 $(kao_script) -t $(KAO_TESTS) -p $(PLATFORM) \ | ||
| --hyp-srcs $(cur_dir) --wrkdir $(tests_dir)/wrkdir $(KAO_ARGS) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Bao Hypervisor VM Configuration | ||
| # This YAML describes the fields needed to generate a C config file (config.c) | ||
|
|
||
| vms: | ||
| - vm1: | ||
| name: "baremetal" | ||
| build_options: "" | ||
| config: | ||
| image: | ||
| base_addr: 0x90000000 | ||
| entry: 0x90000000 | ||
| platform: | ||
| cpu_num: 4 | ||
| regions: | ||
| - base: 0x90000000 | ||
| size: 0x4000000 | ||
| devs: | ||
| - pa: 0x1c090000 | ||
| va: 0x1c090000 | ||
| size: 0x10000 | ||
| interrupts: | ||
| - 37 | ||
| - interrupts: | ||
| - 27 | ||
| arch: | ||
| gic: | ||
| gicd_addr: 0x2F000000 | ||
| gicr_addr: 0x2F100000 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Bao Hypervisor VM Configuration | ||
| # This YAML describes the fields needed to generate a C config file (config.c) | ||
|
|
||
| vms: | ||
| - vm1: | ||
| name: "baremetal" | ||
| build_options: "MEM_BASE=0x10000000" | ||
| config: | ||
| image: | ||
| load_addr: 0x10000000 | ||
| phys_addr: 0x10000000 | ||
| size: 102400 | ||
| entry: 0x10000000 | ||
| platform: | ||
| cpu_num: 4 | ||
| regions: | ||
| - base: 0x10000000 | ||
| size: 0x4000000 | ||
| devs: | ||
| - pa: 0x9c0A0000 | ||
| va: 0x9c0A0000 | ||
| size: 0x10000 | ||
| interrupts: | ||
| - 38 | ||
| - interrupts: | ||
| - 27 | ||
| arch: | ||
| gic: | ||
| gicd_addr: 0xAF000000 | ||
| gicr_addr: 0xAF100000 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
|
|
||
|
|
||
| # Bao Hypervisor VM Configuration | ||
| # This YAML describes the fields needed to generate a C config file (config.c) | ||
|
|
||
| vms: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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 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? Either way it should be in the README, because from outside it isn't obvious what it's for.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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:
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. |
||
| - vm1: | ||
| name: "baremetal" | ||
| build_options: | ||
| config: | ||
| image: | ||
| base_addr: 0x50000000 | ||
| entry: 0x50000000 | ||
| platform: | ||
| cpu_num: 4 | ||
| regions: | ||
| - base: 0x50000000 | ||
| size: 0x4000000 | ||
| devs: | ||
| - pa: 0x9000000 | ||
| va: 0x9000000 | ||
| size: 0x10000 | ||
| interrupts: | ||
| - 33 | ||
| - interrupts: | ||
| - 27 | ||
| arch: | ||
| gic: | ||
| gicd_addr: 0x08000000 | ||
| gicr_addr: 0x080A0000 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Bao Hypervisor VM Configuration | ||
| # This YAML describes the fields needed to generate a C config file (config.c) | ||
|
|
||
| vms: | ||
| - vm1: | ||
| name: "baremetal" | ||
| build_options: "IRQC=AIA" | ||
| config: | ||
| image: | ||
| base_addr: 0x80200000 | ||
| entry: 0x80200000 | ||
| platform: | ||
| cpu_num: 4 | ||
| regions: | ||
| - base: 0x80200000 | ||
| size: 0x4000000 | ||
| devs: | ||
| - pa: 0x10000000 | ||
| va: 0x10000000 | ||
| size: 0x1000 | ||
| interrupts: | ||
| - 10 | ||
| arch: | ||
| irqc: | ||
| aia: | ||
| aplic: | ||
| base: 0xd000000 | ||
| imsic: | ||
| base: 0x28000000 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Bao Hypervisor VM Configuration | ||
| # This YAML describes the fields needed to generate a C config file (config.c) | ||
|
|
||
| vms: | ||
| - vm1: | ||
| name: "baremetal" | ||
| build_options: | ||
| config: | ||
| image: | ||
| base_addr: 0x90100000 | ||
| entry: 0x90100000 | ||
| platform: | ||
| cpu_num: 6 | ||
| regions: | ||
| - base: 0x90100000 | ||
| size: 0x80000 | ||
| devs: | ||
| - pa: 0xF8800000 | ||
| va: 0xF8800000 | ||
| size: 0x1000 | ||
| interrupts: | ||
| - 10 | ||
| - pa: 0xF003D400 | ||
| va: 0xF003D400 | ||
| size: 0x400 | ||
| - pa: 0xF003D800 | ||
| va: 0xF003D800 | ||
| size: 0x400 | ||
| - pa: 0xF46C0000 | ||
| va: 0xF46C0000 | ||
| size: 0x200 | ||
| interrupts: | ||
| - 173 | ||
| arch: | ||
| gpsr_num: 1 | ||
| gspr_groups: | ||
|
miguelafsilva5 marked this conversation as resolved.
|
||
| - 1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Bao Hypervisor VM Configuration | ||
| # This YAML describes the fields needed to generate a C config file (config.c) | ||
|
|
||
| vms: | ||
| - vm1: | ||
| name: "baremetal" | ||
| build_options: | ||
| config: | ||
| image: | ||
| base_addr: 0x20000000 | ||
| entry: 0x20000000 | ||
| platform: | ||
| cpu_num: 4 | ||
| regions: | ||
| - base: 0x20000000 | ||
| size: 0x8000000 | ||
| devs: | ||
| - pa: 0xFF000000 | ||
| va: 0xFF000000 | ||
| size: 0x10000 | ||
| interrupts: | ||
| - 53 | ||
| - interrupts: | ||
| - 27 | ||
| arch: | ||
| gic: | ||
| gicd_addr: 0xF9010000 | ||
| gicc_addr: 0xF9020000 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Copyright (c) Bao Project and Contributors. All rights reserved | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| ifndef TESTF_TESTS_DIR | ||
| $(error User must define the variable(s) TESTF_TESTS_DIR with the path to the \ | ||
| directory containing the test sources) | ||
| endif | ||
|
|
||
| ifdef BAO_TEST | ||
|
|
||
| TESTF_SRC_DIR:=$(TESTF_TESTS_DIR)/src | ||
| ifneq ($(wildcard $(TESTF_TESTS_DIR)/src/tests/*.c),) | ||
| TESTF_SRC_DIR:=$(TESTF_TESTS_DIR)/src/tests | ||
| endif | ||
| TESTF_INC_DIR:=$(TESTF_TESTS_DIR)/src/inc | ||
|
|
||
|
|
||
| TESTF_SRCS += $(TESTF_TESTS_DIR)/src/testf_entry.c | ||
| TESTF_SRCS += $(filter-out $(TESTF_TESTS_DIR)/src/testf_entry.c, $(wildcard $(TESTF_SRC_DIR)/*.c)) | ||
|
|
||
| ifndef SUITES | ||
| ifndef TESTS | ||
| $(error User must define the variable(s) SUITES and/or TESTS) | ||
| endif | ||
| endif | ||
|
|
||
| ifdef SUITES | ||
| TESTF_FLAGS+=$(addprefix -D, $(SUITES)) | ||
| endif | ||
|
|
||
| ifdef TESTS | ||
| TESTF_FLAGS+=$(addprefix -D, $(TESTS)) | ||
| endif | ||
|
|
||
| ifdef TESTF_LOG_LEVEL | ||
| TESTF_FLAGS+=-DTESTF_LOG_LEVEL=$(TESTF_LOG_LEVEL) | ||
| endif | ||
|
|
||
| ifdef TESTF_NO_RTE | ||
| TESTF_FLAGS+=-Dno_rte | ||
| endif | ||
|
|
||
| else | ||
| TESTF_SRCS += $(TESTF_SRC_DIR)/testf_weak.c | ||
|
|
||
| endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #include <cpu.h> | ||
| #include <timer.h> | ||
| #include <spinlock.h> | ||
| #include "testf.h" | ||
|
|
||
| #define CPU_BOOT_WAIT_TIME TIME_MS(1000) | ||
|
|
||
| volatile bool cpu_boot_status[NUM_CPUS] = {false}; | ||
| spinlock_t boot_status_lock = SPINLOCK_INITVAL; | ||
|
|
||
| BAO_TEST(BOOT_CHECK, VM_BOOT, BAREMETAL, "Check that baremetal guest boots successfully") | ||
| { | ||
| if(cpu_is_master()) { | ||
| TESTF_PASS("System booted successfully!\n"); | ||
| } | ||
| } | ||
|
|
||
| BAO_TEST(BOOT_CHECK, CPU_BOOT, BAREMETAL, "Check that all CPUs on the baremetal boot successfully") | ||
| { | ||
| int cpu_id = get_cpuid(); | ||
| spin_lock(&boot_status_lock); | ||
| cpu_boot_status[cpu_id] = true; | ||
| spin_unlock(&boot_status_lock); | ||
|
|
||
| if(cpu_is_master()) { | ||
| timer_wait(CPU_BOOT_WAIT_TIME); | ||
| for(int i = 0; i < NUM_CPUS; i++) { | ||
| if(!cpu_boot_status[i]) { | ||
| TESTF_FAIL("CPUs did not boot successfully!\n"); | ||
| return; | ||
| } | ||
| } | ||
| TESTF_PASS("All CPUs booted successfully!\n"); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two download the FVP model (~101MB) on every run. Can we cache it with actions/cache keyed on the version?
Just so it's on record, we can't put it in the CI image. I read the EULA inside the tarball and it only grants use, there's no redistribution right (§1.1, §2.5). Downloading it like we do here is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3769011.