Skip to content

Commit 5094319

Browse files
committed
test: add integration test for multiboot2-lib
1 parent d48ba09 commit 5094319

39 files changed

+1468
-2
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+
multiboot2_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@v19
141+
- run: integration-test/run_multiboot2_integrationtest.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/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Integrationtests
2+
3+
The `multiboot2`-directory contains an integration test that boots GRUB via legacy
4+
boot in a QEMU VM, which chainloads a multiboot2 integration test binary written
5+
in Rust.
6+
7+
The `multiboot2-header`-directory contains an integration test that boots a
8+
bootloader using the `multiboot2-header` crate via multiboot1 which generates a
9+
multiboot information structure and chainloads the integrationtest from the
10+
`multiboot2`-directory.
11+
12+
Both tests write output to the QEMU debugcon device and the output is matched
13+
against an expected test file.
14+
15+
The easiest way to set up the necessary toolchain is to install Nix and
16+
execute:
17+
- `$ nix-shell --pure --run "./run.sh""`
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.

integration-test/bins/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[workspace]
2+
resolver = "2"
3+
members = [
4+
"multiboot2_chainloader",
5+
"multiboot2_payload",
6+
"util"
7+
]
8+
9+
[profile.release]
10+
codegen-units = 1
11+
lto = true
12+
13+
[patch.crates-io]
14+
multiboot2 = { path = "../../multiboot2" }
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "multiboot2_chainloader"
3+
description = "Multiboot chainloader that loads a Multiboot2 payload"
4+
version = "0.1.0"
5+
edition = "2021"
6+
publish = false
7+
8+
[dependencies]
9+
anyhow = { version = "1.0.69", default-features = false }
10+
elf_rs = "0.3.0"
11+
log = { version = "0.4.17", default-features = false }
12+
good_memory_allocator = "0.1.7"
13+
multiboot = "0.8.0"
14+
util = { path = "../util" }
15+
multiboot2 = { path = "../../../multiboot2" }
16+
multiboot2-header = { path = "../../../multiboot2-header" }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() {
2+
let linker_script = "multiboot2_chainloader/link.ld";
3+
println!("cargo:rerun-if-changed={linker_script}");
4+
println!("cargo:rustc-link-arg=-T{linker_script}");
5+
}

0 commit comments

Comments
 (0)