Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions Documentation/kernel/test_framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ pub fn foo_test_suite() {
)],
// Name of the test suite
name: "Foo",
// Number of tests inside the suite
tests_nb: 1,
// Behavior of the test suite
// Default: run the suite normally
// Skipped: don't run the suite at all
Expand Down
3 changes: 1 addition & 2 deletions src/tests/arch/riscv32/task/task_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,10 @@ pub fn task_context_test_suite() {
TestCase::init(
"Task context switch no invariants violated",
test_task_context_switch,
TestBehavior::Default,
TestBehavior::Skipped,
),
],
name: "RISC-V32 bit task context layout",
tests_nb: 3,
behavior: TestSuiteBehavior::Default,
};
#[allow(static_mut_refs)]
Expand Down
1 change: 0 additions & 1 deletion src/tests/arch/riscv32/traps/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub fn trap_handler_test_suite() {
TestBehavior::Default,
)],
name: "Trap handler",
tests_nb: 1,
behavior: TestSuiteBehavior::Default,
};
#[allow(static_mut_refs)]
Expand Down
1 change: 0 additions & 1 deletion src/tests/arch/riscv32/traps/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ pub fn interrupt_enabling_test_suite() {
// },
],
name: "Interruptions enabling",
tests_nb: 6,
behavior: TestSuiteBehavior::Default,
};
#[allow(static_mut_refs)]
Expand Down
1 change: 0 additions & 1 deletion src/tests/arch/riscv32/traps/trap_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ pub fn trap_frame_test_suite() {
),
],
name: "Trap frame",
tests_nb: 2,
behavior: TestSuiteBehavior::Default,
};
#[allow(static_mut_refs)]
Expand Down
1 change: 0 additions & 1 deletion src/tests/drivers/cpu_intc/subsystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ pub fn cpu_intc_subsystem_test_suite() {
),
],
name: "CPU interrupt-controller",
tests_nb: 3,
behavior: TestSuiteBehavior::Default,
};
#[allow(static_mut_refs)]
Expand Down
1 change: 0 additions & 1 deletion src/tests/drivers/serials/ns16550a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub fn ns16550_test_suite() {
TestBehavior::Default,
)],
name: "Ns16550",
tests_nb: 1,
behavior: TestSuiteBehavior::Skipped,
};
#[allow(static_mut_refs)]
Expand Down
1 change: 0 additions & 1 deletion src/tests/drivers/serials/subsystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ pub fn serial_subsystem_test_suite() {
),
],
name: "Serial sub-system",
tests_nb: 3,
behavior: TestSuiteBehavior::Default,
};
#[allow(static_mut_refs)]
Expand Down
1 change: 0 additions & 1 deletion src/tests/drivers/timer/subsystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ pub fn timer_subsystem_test_suite() {
),
],
name: "Timer sub-system",
tests_nb: 4,
behavior: TestSuiteBehavior::Default,
};

Expand Down
1 change: 0 additions & 1 deletion src/tests/ktime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ pub fn ktime_test_suite() {
),
],
name: "Ktime",
tests_nb: 3,
behavior: TestSuiteBehavior::Default,
};
#[allow(static_mut_refs)]
Expand Down
1 change: 0 additions & 1 deletion src/tests/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ pub fn memory_test_suite() {
),
],
name: "Kernel memory",
tests_nb: 2,
behavior: TestSuiteBehavior::Default,
};
#[allow(static_mut_refs)]
Expand Down
18 changes: 5 additions & 13 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ impl<'a> TestManager<'a> {
pub struct TestSuite<'a> {
pub tests: &'a [TestCase<'a>],
pub name: &'a str,
pub tests_nb: u32,
pub behavior: TestSuiteBehavior,
}

Expand All @@ -103,21 +102,14 @@ impl<'a> TestSuite<'a> {
TestSuite {
tests: &[],
name: "",
tests_nb: 0,
behavior: TestSuiteBehavior::Skipped,
}
}

pub fn init(
tests: &'a [TestCase],
name: &'a str,
tests_nb: u32,
behavior: TestSuiteBehavior,
) -> Self {
pub fn init(tests: &'a [TestCase], name: &'a str, behavior: TestSuiteBehavior) -> Self {
TestSuite {
tests,
name,
tests_nb,
behavior,
}
}
Expand Down Expand Up @@ -155,7 +147,6 @@ impl<'a> TestCase<'a> {

pub static mut TEST_MANAGER: TestManager = TestManager::init();

#[unsafe(no_mangle)]
pub fn test_runner(core: usize, dtb_addr: usize) -> ! {
// Basic test before running all test suites
kprint!("Starting kernel in test mode.\n");
Expand All @@ -182,7 +173,8 @@ pub fn test_runner(core: usize, dtb_addr: usize) -> ! {
let mut test_suites_skipped: usize = 0;
// Iterate over all test suite and run all test inside
for test_suite in unsafe { TEST_MANAGER.test_pool } {
if test_suite.tests_nb == 0 {
let test_nb = test_suite.tests.len();
if test_nb == 0 {
continue;
}
if test_suite.behavior == TestSuiteBehavior::Skipped {
Expand All @@ -191,10 +183,10 @@ pub fn test_runner(core: usize, dtb_addr: usize) -> ! {
}
kprint_fmt!(
"\nRunning {} tests from test suite: {}\n",
test_suite.tests_nb,
test_nb,
test_suite.name
);
let test_to_pass = test_suite.tests_nb;
let test_to_pass = test_nb;
let mut test_passed: usize = 0;
let mut test_failed: usize = 0;
let mut test_skipped: usize = 0;
Expand Down
1 change: 0 additions & 1 deletion src/tests/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ pub fn platform_test_suite() {
),
],
name: "Platform",
tests_nb: 2,
behavior: TestSuiteBehavior::Default,
};
#[allow(static_mut_refs)]
Expand Down
1 change: 0 additions & 1 deletion src/tests/primitives/ring_buff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ pub fn ring_buff_primitive_test_suite() {
TestCase::init("RingBuffer pop", test_ringbuffer_pop, TestBehavior::Default),
],
name: "RingBuffer primitive type",
tests_nb: 3,
behavior: TestSuiteBehavior::Default,
};
#[allow(static_mut_refs)]
Expand Down
1 change: 0 additions & 1 deletion src/tests/task/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub fn task_list_test_suite() {
const TASK_LIST_TEST_SUITE: TestSuite = TestSuite {
tests: &[],
name: "Task list",
tests_nb: 0,
behavior: TestSuiteBehavior::Skipped,
};
#[allow(static_mut_refs)]
Expand Down
1 change: 0 additions & 1 deletion src/tests/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub fn task_test_suite() {
TestBehavior::Default,
)],
name: "Task",
tests_nb: 1,
behavior: TestSuiteBehavior::Default,
};
#[allow(static_mut_refs)]
Expand Down