Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f05e11e
feat(test-framework): Add a README.md in the tests directory
miguelafsilva5 May 31, 2024
3b9162f
feat(test-framework): Add a makefile for the test framework
miguelafsilva5 May 31, 2024
6ea4777
feat(submodules): Add the test-framework (bao-test) repository
miguelafsilva5 Jun 3, 2024
ecb5db4
feat(submodules): Add the nix packages (bao-nix) repository
miguelafsilva5 Jun 3, 2024
c81079b
feat(recipe): add support for single baremetal tests
miguelafsilva5 Jun 3, 2024
cd84448
feat(test-framework): Add a tests rule to bao Makefile
miguelafsilva5 Jun 4, 2024
36cb293
feat(irq_tests): add support to run IRQ tests (uart and timer)
Diogo21Costa Sep 4, 2024
7067878
feat(recipe): Add the main nix recipe file for a single baremetal
miguelafsilva5 Jun 3, 2024
b2d1874
add(uart_irq): include IRQ tests
Diogo21Costa Sep 24, 2024
7c478dd
fix(irq_test): update single baremetal tests
Diogo21Costa Apr 3, 2025
1ce96df
feat(test): add support to single freertos tests
Diogo21Costa Apr 3, 2025
8889871
update(single-baremetal): fix recipe and tests
Diogo21Costa Sep 13, 2025
0538335
fix(Makefile): add missing endif instruction
Diogo21Costa Sep 14, 2025
dbc2d69
update(README): include test framework instructions
Diogo21Costa Sep 14, 2025
699813a
update(recipes): use boot only tests on single baremetal test
Diogo21Costa Oct 23, 2025
a6239bf
feat(fvp): include support to fvp tests
Diogo21Costa Sep 13, 2025
cd65b3b
wip(github_actions): test workflows
Diogo21Costa Nov 10, 2025
83c894c
update(submodules): bump bao-tests and bao-nix submodules
Diogo21Costa Nov 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/test-framework.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test Franewrork

on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:


jobs:

run-tests:
runs-on: ubuntu-latest
container:
image: diogo21costa/bao-tests:latest
options: --user root
strategy:
matrix:
platform: [
"qemu-aarch64-virt",
]
recipe: [
"single-baremetal/default.nix"
]
gic: [
"GICV2",
]
cross_compile: [
"CROSS_COMPILE=clang"
]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Run tests inside nix shell
run: nix develop ./tests --command make tests PLATFORM=${{ matrix.platform }} RECIPE=${{ matrix.recipe }} ${{ matrix.cross_compile }} GIC_VERSION=${{ matrix.gic }}
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[submodule "ci"]
path = ci
url = [email protected]:bao-project/bao-ci.git
[submodule "tests/bao-tests"]
path = tests/bao-tests
url = https://github.com/bao-project/bao-tests.git
[submodule "tests/bao-nix"]
path = tests/bao-nix
url = https://github.com/bao-project/bao-nix.git
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ targets:=$(MAKECMDGOALS)
ifeq ($(targets),)
targets:=all
endif
non_build_targets+=ci clean
non_build_targets+=ci clean tests
build_targets:=$(strip $(foreach target, $(targets), \
$(if $(findstring $(target),$(non_build_targets)),,$(target))))

Expand Down Expand Up @@ -395,4 +395,10 @@ $(call ci, format, $(all_c_files))
.PHONY: ci
ci: license-check format-check

endif
tests_dir := $(cur_dir)/tests
-include $(tests_dir)/tests.mk

.PHONY: tests
tests: framework

endif
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,23 @@ In IEEE Access, 2024. https://ieeexplore.ieee.org/document/10781314

10. Hidemasa Kawasaki and Soramichi Akiyama. "**Running Bao Hypervisor on gem5**"
In gem5 blog, 2024. https://www.gem5.org/2024/11/12/bao-on-gem5.html


Testing Framework Usage
-----------------------

### Prerequisites
- Ensure [Nix package manager](https://nixos.org/download.html) is installed.
- Ensure that all dependencies (check [here](./tests/README.md)) are installed.

### Run the test framework locally
(Follow [this instructions](./tests/README.md) to use Docker)
```sh
make tests PLATFORM=<platform_name> RECIPE=<target_recipe>
```

Example using `qemu-aarch64-virt` with a single baremetal setup:

```sh
make tests PLATFORM=qemu-aarch64-virt RECIPE=single-baremetal/default.nix IRQC=gicv3
```
49 changes: 49 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Bao Test Framework

### Prerequesites
If you prefer not to use Docker or Nix, you can install the required dependencies manually:
```sh
sudo apt-get update && sudo apt-get install -y \
git curl wget tree vim nano sudo make net-tools socat xterm \
python3 python3-pip nodejs npm bison flex gawk device-tree-compiler \
ninja-build pkg-config enchant

pip install psutil pyserial
```


### Clone docker
To pull the Docker image, run the following command:

```sh
docker pull baoproject/bao-tests:latest
```

### Run the Test framework inside Docker

First, start Docker with the following command in the repo's root directory:
```sh
docker run --rm -it \
-v "$(pwd):$(pwd)" \
-w "$(pwd)" \
-u $(id -u):$(id -g) \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
baoproject/bao-tests:latest
```

Then, initialize the Nix environment:
```sh
nix develop ./tests/
```

Finally, run the test framework with:
```sh
make tests PLATFORM=<platform_name> RECIPE=<target_recipe>
```

Currently, the following platforms are available:
- QEMU RV64 virt (qemu-aarch64-virt)
- QEMU Aarch64 virt (qemu-aarch64-virt)
- FVP-A AArch64 (fvp-a)
- FVP-R AArch64 (fvp-r)
1 change: 1 addition & 0 deletions tests/bao-nix
Submodule bao-nix added at 1bd38a
1 change: 1 addition & 0 deletions tests/bao-tests
Submodule bao-tests added at bedcb5
30 changes: 30 additions & 0 deletions tests/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
description = "Bao dev environment with pinned toolchains, Python deps, and QEMU";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";

outputs = { self, nixpkgs }: let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };


in {
devShells.${system}.default = pkgs.mkShell {
name = "bao-dev";

buildInputs = with pkgs; [
git curl wget tree vim nano sudo gnumake

nettools socat xterm

python3 python3Packages.pip python3Packages.psutil
python3Packages.pyserial

nodejs nodePackages.cspell
bison flex gawk dtc ninja pkg-config
enchant

];
};
};
}
32 changes: 32 additions & 0 deletions tests/recipes/single-baremetal/baremetal.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/setup.mk b/setup.mk
index 3a230aa..2edf9ee 100644
--- a/setup.mk
+++ b/setup.mk
@@ -29,6 +29,14 @@ src_dirs+=$(src_dir) $(core_dir) $(platform_dir)
SRC_DIRS+=$(src_dirs)
INC_DIRS+=$(addsuffix /inc, $(src_dirs))

+# Test framework setup
+include $(TESTF_REPO_DIR)/src/bao-test.mk
+SRC_DIRS+=$(TESTF_SRC_DIR) $(TESTF_TESTS_DIR)
+C_SRC+=$(TESTF_SRCS)
+INC_DIRS+=$(TESTF_INC_DIR)
+CFLAGS+=$(TESTF_FLAGS)
+# End of test framework setup
+
ifeq ($(wildcard $(platform_dir)),)
$(error unsupported platform $(PLATFORM))
endif
diff --git a/src/main.c b/src/main.c
index 9a9e972..69cfa6f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,6 +54,8 @@ void main(void){
printf("Bao bare-metal test guest\n");
spin_unlock(&print_lock);

+ testf_entry();
+
irq_set_handler(UART_IRQ_ID, uart_rx_handler);
irq_set_handler(TIMER_IRQ_ID, timer_handler);
irq_set_handler(IPI_IRQ_ID, ipi_handler);
1 change: 1 addition & 0 deletions tests/recipes/single-baremetal/configs/fvp-a-aarch32.c
54 changes: 54 additions & 0 deletions tests/recipes/single-baremetal/configs/fvp-a.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <config.h>

VM_IMAGE(baremetal_image, XSTR(BAO_WRKDIR_IMGS/baremetal.bin))

struct config config = {

.vmlist_size = 1,
.vmlist = (struct vm_config[]) {
{
.image = {
.base_addr = 0x90000000,
.load_addr = VM_IMAGE_OFFSET(baremetal_image),
.size = VM_IMAGE_SIZE(baremetal_image)
},

.entry = 0x90000000,

.platform = {
.cpu_num = 4,

.region_num = 1,
.regions = (struct vm_mem_region[]) {
{
.base = 0x90000000,
.size = 0x4000000
}
},

.dev_num = 2,
.devs = (struct vm_dev_region[]) {
{
/* UART2, PL011 */
.pa = 0x1c090000,
.va = 0x1c090000,
.size = 0x10000,
.interrupt_num = 1,
.interrupts = (irqid_t[]) {37}
},
{
.interrupt_num = 1,
.interrupts = (irqid_t[]) {27}
}
},

.arch = {
.gic = {
.gicr_addr = (paddr_t) 0x2F100000,
.gicd_addr = (paddr_t) 0x2F000000
}
}
},
},
},
};
49 changes: 49 additions & 0 deletions tests/recipes/single-baremetal/configs/fvp-r.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <config.h>


struct config config = {

.vmlist_size = 1,
.vmlist = (struct vm_config[]) {
{
.image = VM_IMAGE_LOADED(0x10000000, 0x10000000, 100*1024),

.entry = 0x10000000,

.platform = {
.cpu_num = 4,

.region_num = 1,
.regions = (struct vm_mem_region[]) {
{
.base = 0x10000000,
.size = 0x4000000,
},
},

.dev_num = 2,
.devs = (struct vm_dev_region[]) {
{
/* UART2, PL011 */
.pa = 0x9c0A0000,
.va = 0x9c0A0000,
.size = 0x10000,
.interrupt_num = 1,
.interrupts = (irqid_t[]) {38}
},
{
.interrupt_num = 1,
.interrupts = (irqid_t[]) {27}
}
},

.arch = {
.gic = {
.gicd_addr = (paddr_t) 0xAF000000,
.gicr_addr = (paddr_t) 0xAF100000,
}
}
},
}
}
};
58 changes: 58 additions & 0 deletions tests/recipes/single-baremetal/configs/qemu-aarch64-virt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <config.h>

VM_IMAGE(baremetal_image, XSTR(BAO_WRKDIR_IMGS/baremetal.bin))

struct config config = {

CONFIG_HEADER

.vmlist_size = 1,
.vmlist = (struct vm_config[]) {
{
.image = {
.base_addr = 0x50000000,
.load_addr = VM_IMAGE_OFFSET(baremetal_image),
.size = VM_IMAGE_SIZE(baremetal_image)
},

.entry = 0x50000000,

.platform = {
.cpu_num = 4,

.region_num = 1,
.regions = (struct vm_mem_region[]) {
{
.base = 0x50000000,
.size = 0x4000000
}
},

.dev_num = 2,
.devs = (struct vm_dev_region[]) {
{
/* PL011 */
.pa = 0x9000000,
.va = 0x9000000,
.size = 0x10000,
.interrupt_num = 1,
.interrupts = (irqid_t[]) {33}
},
{
/* Arch timer interrupt */
.interrupt_num = 1,
.interrupts =
(irqid_t[]) {27}
}
},

.arch = {
.gic = {
.gicd_addr = (paddr_t) 0x08000000,
.gicr_addr = (paddr_t) 0x080A0000,
}
}
},
}
},
};
Loading
Loading