Skip to content

Commit ba04fb2

Browse files
committed
test: add integration test for multiboot2 and multiboot2-header
1 parent c3a4e03 commit ba04fb2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1591
-1
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ indent_size = 4
1111
trim_trailing_whitespace = true
1212
max_line_length = 80
1313

14-
[*.yml]
14+
[{*.nix, *.yml}]
1515
indent_size = 2

.github/workflows/rust.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,15 @@ jobs:
127127
do-style-check: true
128128
do-test: false
129129
features: builder,unstable
130+
131+
integrationtest:
132+
name: multiboot2 integrationtest
133+
needs:
134+
- build_nightly
135+
- build_nostd_nightly
136+
runs-on: ubuntu-latest
137+
steps:
138+
- name: Check out
139+
uses: actions/checkout@v3
140+
- uses: cachix/install-nix-action@v20
141+
- run: integration-test/run.sh

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ members = [
44
"multiboot2",
55
"multiboot2-header",
66
]
7+
exclude = [
8+
"integration-test"
9+
]
710

811
[workspace.dependencies]
912
bitflags = "2"

integration-test/.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use nix

integration-test/.run.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
4+
set -euo pipefail
5+
IFS=$'\n\t'
6+
7+
DIR=$(dirname "$(realpath "$0")")
8+
cd "$DIR" || exit
9+
10+
function fn_main() {
11+
fn_build_rust_bins
12+
fn_multiboot2_integrationtest
13+
fn_multiboot2_header_integrationtest
14+
}
15+
16+
function fn_build_rust_bins() {
17+
cd "bins"
18+
cargo build --release
19+
cd "$DIR"
20+
}
21+
22+
function fn_multiboot2_integrationtest() {
23+
cd tests/multiboot2
24+
./build_img.sh
25+
./run_qemu.sh
26+
cd "$DIR"
27+
}
28+
29+
function fn_multiboot2_header_integrationtest() {
30+
cd tests/multiboot2-header
31+
./run_qemu.sh
32+
cd "$DIR"
33+
}
34+
35+
fn_main

integration-test/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Integrationtests
2+
3+
This directory contains integration tests for the `multiboot2` and the
4+
`multiboot2-header` crate. The integration tests start a QEMU VM and do certain
5+
checks at runtime. If something fails, they instruct QEMU to exit with an error
6+
code. All output of the VM is printed to the screen. If
7+
8+
The `bins` directory contains binaries that **are** the tests. The `tests`
9+
directory contains test definitions, run scripts, and other relevant files. The
10+
main entry to run all tests is `./run.sh` in this directory.
11+
12+
## TL;DR:
13+
- `$ ./run.sh` to execute the integration tests
14+
15+
## Prerequisites
16+
The tests rely on [`nix`](https://nixos.org/) being installed / `nix-shell`
17+
being available to get the relevant tools.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[unstable]
2+
build-std = ["core", "compiler_builtins", "alloc"]
3+
build-std-features = ["compiler-builtins-mem"]
4+
5+
[build]
6+
target = "x86-unknown-none.json"
7+
rustflags = [
8+
"-C", "code-model=kernel",
9+
# "-C", "link-arg=-Tlink.ld",
10+
"-C", "relocation-model=static",
11+
]

integration-test/bins/Cargo.lock

Lines changed: 285 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)