Skip to content

Commit 87cd735

Browse files
committed
[wip] enable doctests (without running)
1 parent 0b1dc8b commit 87cd735

33 files changed

Lines changed: 93 additions & 55 deletions

File tree

Cargo.lock

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

Justfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,13 @@ test: test-device test-chainboot test-host
222222
[group("emu")]
223223
test-device:
224224
RUSTFLAGS="{{ fixed_rustflags }} {{ board_rpi3_flags }} -C link-arg=--script={{ test_link }}" \
225-
cargo test {{ target_json }} --features=qemu {{ rust_std }} \
225+
cargo test --tests {{ target_json }} --features=qemu {{ rust_std }} \
226226
--workspace --exclude=chainofcommand --exclude=chainboot
227227

228+
RUSTFLAGS="{{ fixed_rustflags }} {{ board_rpi3_flags }} -C link-arg=--script={{ test_link }}" \
229+
cargo test --doc {{ target_json }} --features=qemu {{ rust_std }} \
230+
--workspace --exclude=chainofcommand --exclude=chainboot
231+
228232
# Run chainboot tests in QEMU (rpi3) with its own linker script
229233
[group("emu")]
230234
test-chainboot:

kernel/nucleus/Cargo.toml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,18 @@ qemu = [
3232

3333
[dependencies]
3434
aarch64-cpu = { workspace = true }
35-
# bit_field = { workspace = true }
3635
bitflags = { workspace = true }
3736
cfg-if = { workspace = true }
3837
libaddress = { workspace = true }
39-
# libconsole = { workspace = true }
4038
libcpu = { workspace = true }
4139
libexception = { workspace = true }
42-
# libkernel-state = { workspace = true }
4340
liblocking = { workspace = true }
4441
liblog = { workspace = true }
4542
libmachine = { workspace = true }
4643
libmapping = { workspace = true }
4744
libobject = { workspace = true }
48-
# libplatform = { workspace = true }
4945
libprint = { workspace = true }
5046
libqemu = { workspace = true, optional = true }
51-
# libsyscall = { workspace = true }
52-
# libtime = { workspace = true }
53-
# snafu = { workspace = true }
54-
# static_assertions = { workspace = true }
55-
# tock-registers = { workspace = true }
56-
# usize_conversions = { workspace = true }
57-
# ux = { workspace = true }
5847

5948
[dev-dependencies]
6049
libexception = { workspace = true, features = ["test_build"] }

kernel/nucleus/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,11 @@ extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) {
120120
#[unsafe(no_mangle)]
121121
extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) {
122122
{
123+
use aarch64_cpu::registers::{ESR_EL1, Readable};
124+
123125
const TEST_SVC_ID: u64 = 0x1337;
124126

125-
let esr_el1 = esr_el1::EsrEL1(LocalRegisterCopy::new(ESR_EL1.get()));
127+
let esr_el1 = libexception::arch::esr_el1::EsrEL1(LocalRegisterCopy::new(ESR_EL1.get()));
126128

127129
if let Some(ESR_EL1::EC::Value::SVC64) = esr_el1.exception_class()
128130
&& esr_el1.iss() == TEST_SVC_ID
@@ -132,7 +134,7 @@ extern "C" fn current_elx_synchronous(e: &mut ExceptionContext) {
132134
}
133135
}
134136

135-
if debug::exception_dump(e) {
137+
if libdebug::exception_dump(e) {
136138
return;
137139
}
138140

libs/address/src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ impl const PageSize for u64 {
7575
*self
7676
}
7777
fn mask(&self) -> u64 {
78-
!(self - 1)
78+
assert!(
79+
self.is_power_of_two(),
80+
"PageSize must be a power of two to use as mask"
81+
);
82+
self - 1
7983
}
8084
}
8185

@@ -84,7 +88,11 @@ impl const PageSize for usize {
8488
*self as u64
8589
}
8690
fn mask(&self) -> u64 {
87-
!(self - 1) as u64
91+
assert!(
92+
self.is_power_of_two(),
93+
"PageSize must be a power of two to use as mask"
94+
);
95+
(self - 1) as u64
8896
}
8997
}
9098

libs/address/tests/address.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ fn address_type_method_sanity() {
2828

2929
let addr = Address::<Virtual>::new(SIZE + 100);
3030

31+
assert_eq!(addr.as_u64(), SIZE + 100);
32+
3133
assert_eq!(addr.align_down_page(&SIZE), SIZE.into());
3234

3335
assert_eq!(addr.align_up_page(&SIZE), (SIZE * 2).into());

libs/alloc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ liblog = { workspace = true }
2525
# Tests are offloaded to kernel integration tests binary.
2626
[lib]
2727
test = false
28+
harness = false
2829

2930
[lints]
3031
workspace = true

libs/boot/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ tock-registers = { workspace = true }
2727
# Tests are offloaded to kernel integration tests binary.
2828
[lib]
2929
test = false
30+
harness = false
3031

3132
[lints]
3233
workspace = true

libs/console/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ libqemu = { workspace = true }
3535
# Tests are offloaded to kernel integration tests binary.
3636
[lib]
3737
test = false
38+
harness = false
3839

3940
[lints]
4041
workspace = true

libs/cpu/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ aarch64-cpu = { workspace = true }
2828
# Tests are offloaded to kernel integration tests binary.
2929
[lib]
3030
test = false
31+
harness = false
3132

3233
# For proper testing in libcpu, we build it as a test_runner binary!
3334

0 commit comments

Comments
 (0)