Skip to content

Commit 0b1dc8b

Browse files
committed
Split test command, make it work
1 parent 7a89e65 commit 0b1dc8b

54 files changed

Lines changed: 1268 additions & 1220 deletions

File tree

Some content is hidden

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

Cargo.lock

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

Justfile

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ rpi4_dtb := justfile_directory() / 'targets/bcm2711-rpi-4-b.dtb'
1212

1313
nucleus_link := 'libs/platform/src/raspberrypi/linker/nucleus.ld'
1414
init_link := 'libs/platform/src/raspberrypi/linker/init_thread.ld'
15+
test_link := 'libs/platform/src/raspberrypi/linker/test.ld'
1516
chainboot_link := 'bin/chainboot/src/link.ld'
1617

1718
fixed_rustflags := '-D warnings -Z macro-backtrace'
@@ -213,12 +214,28 @@ alias ocd := openocd
213214

214215
# === Testing ===
215216

216-
# Run tests in QEMU (rpi3)
217+
# Run all device tests in QEMU (rpi3) with all device features, plus host tool tests natively
217218
[group("emu")]
218-
test:
219-
RUSTFLAGS="{{ fixed_rustflags }} {{ board_rpi3_flags }}" \
220-
cargo test --verbose {{ target_json }} --features=qemu {{ rust_std }}
221-
# ^ coc tests should be with std...
219+
test: test-device test-chainboot test-host
220+
221+
# Run device crate tests in QEMU (rpi3) --verbose
222+
[group("emu")]
223+
test-device:
224+
RUSTFLAGS="{{ fixed_rustflags }} {{ board_rpi3_flags }} -C link-arg=--script={{ test_link }}" \
225+
cargo test {{ target_json }} --features=qemu {{ rust_std }} \
226+
--workspace --exclude=chainofcommand --exclude=chainboot
227+
228+
# Run chainboot tests in QEMU (rpi3) with its own linker script
229+
[group("emu")]
230+
test-chainboot:
231+
RUSTFLAGS="{{ fixed_rustflags }} {{ board_rpi3_flags }} -C link-arg=--script={{ chainboot_link }}" \
232+
cargo test {{ target_json }} --features=qemu {{ rust_std }} \
233+
-p chainboot
234+
235+
# Run host tool tests natively
236+
[group("emu")]
237+
test-host:
238+
cargo test -p chainofcommand
222239

223240
# Test runner invoked by .cargo/config.toml runner
224241
[private]
@@ -228,7 +245,7 @@ _test-runner binary_path:
228245
name=$(basename "{{ binary_path }}")
229246
bin="{{ justfile_directory() }}/target/${name}.bin"
230247
{{ objcopy }} --strip-all -O binary "{{ binary_path }}" "${bin}"
231-
@echo "🚨 Running test: ${name}"
248+
echo "🚨 Running test: ${name}"
232249
{{ qemu }} {{ qemu_base_opts }} {{ qemu_test_opts }} -dtb "{{ rpi3_dtb }}" -kernel "${bin}"
233250

234251
# === Clippy ===

bin/chainboot/Cargo.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,11 @@ noserial = []
2222

2323
[dependencies]
2424
aarch64-cpu = { workspace = true }
25-
# bit_field = { workspace = true }
26-
# bitflags = { workspace = true }
27-
# cfg-if = { workspace = true }
2825
libconsole = { workspace = true }
2926
liblog = { workspace = true }
3027
libmachine = { workspace = true }
3128
libplatform = { workspace = true }
3229
seahash = { workspace = true }
33-
# snafu = { workspace = true }
34-
# tock-registers = { workspace = true }
35-
# usize_conversions = { workspace = true }
36-
# ux = { workspace = true }
3730

3831
[dev-dependencies]
3932
libqemu = { workspace = true }

bin/chainboot/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use {
99
core::hash::Hasher,
1010
libconsole::console::console,
1111
liblog::{print, println},
12-
libplatform::platform::raspberrypi::BcmHost,
12+
libplatform::raspberrypi::BcmHost,
1313
seahash::SeaHasher,
1414
};
1515

@@ -25,14 +25,14 @@ unsafe extern "C" fn kernel_init(dtb: u32, max_kernel_size: u64) -> ! {
2525
libmachine::debug::jtag::wait_debugger();
2626

2727
// SAFETY: VERY SAFE
28-
if let Err(x) = unsafe { libplatform::platform::drivers::init() } {
28+
if let Err(x) = unsafe { libplatform::drivers::init() } {
2929
panic!("Error initializing platform drivers: {}", x);
3030
}
3131

3232
// Initialize all device drivers.
3333
// SAFETY: Relatively safe.
3434
unsafe {
35-
libplatform::platform::drivers::driver_manager().init_drivers_and_irqs();
35+
libplatform::drivers::driver_manager().init_drivers_and_irqs();
3636
}
3737

3838
// println! is usable from here on.

bin/chainboot/tests/chainboot.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
mod common;
88

99
// This test essentially validates that a relocated chainboot executable runs correctly
10-
#[test_case]
11-
fn relocated_binary_works() {
12-
assert_eq!(2 + 2, 4);
13-
}
10+
// #[test_case]
11+
// fn relocated_binary_works() {
12+
// assert_eq!(2 + 2, 4);
13+
// }

kernel/Plan.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ What's needed: quick-n-dirty higher-half mappings setup and kernel physical memo
55
- `__init_thread_start` till `__init_thread_end` identity-map (no code/data split yet?)
66

77
Steps:
8+
- [ ] Move tests from kernel/tests to individual libs?
9+
10+
- [ ] Make some caps work - Untypeds, Domains, Buffers, what else?
11+
- [ ] Test out syscalls from EL0
12+
13+
- START FILLING IN CAPS
14+
- [ ] untypeds
15+
- [ ] init_thread context and domain
16+
17+
---
18+
19+
# Completed
20+
821
- [x] Buildable
922
- [x] build all shit together into a binary
1023
- [x] make separate init_thread section and start booting from init_thread
@@ -21,18 +34,13 @@ Steps:
2134

2235
- [x] Generate complete memory map from DTB, print it out
2336

24-
- [ ] Make some caps work - Untypeds, Domains, Buffers, what else?
25-
- [ ] Test out syscalls from EL0
26-
2737
- [x] Print kernel covered area
2838
- [x] Print KERNEL_HIGH_BASE
2939
- [x] Print kernel mappings size and attribs
3040
- [x] Print init_thread covered area
3141
- [x] Print init_thread mappings size
3242

33-
- START FILLING IN CAPS
34-
- [ ] untypeds
35-
- [ ] init_thread context and domain
43+
3644

3745
Whatever kernel links must also be located in high-mem mapping, so we cannot share this code with init_thread at all!
3846
This means it's probably sensible to build kernel as a separate ELF file linked entirely high, then merge it with the init_thread binary through specially-named sections; there should be no symbol resolution across two binaries, so the nucleus image is solely pulled via it's PHDRS (but we need to place the BSS which will be erased by the init_thread before turning the MMU on)

0 commit comments

Comments
 (0)