diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-04-21 23:23:49 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-04-21 23:23:49 +0800 |
| commit | 51899557c770b3dc9bd02579abf491745e607d92 (patch) | |
| tree | 9681432a6db30a29f47aa1b21bbad777dfadd6c9 /na/test/selftest.cc | |
| parent | ab2c0a8ea472679c846e74ca40823091becc5bf0 (diff) | |
| download | lume-51899557c770b3dc9bd02579abf491745e607d92.tar.gz lume-51899557c770b3dc9bd02579abf491745e607d92.tar.xz | |
feat: add boot self-tests for various kernel components
- Implemented a self-test runner in `selftest.cc` to invoke all test suites.
- Added tests for atomic operations in `test_atomic.cc`, covering construction, store/load, exchange, arithmetic, and compare-and-swap.
- Created tests for the Flattened Device Tree (FDT) in `test_fdt.cc`, verifying node access and compatibility queries.
- Developed a comprehensive Physical Memory Manager (PMM) test suite in `test_pmm.cc`, including allocation, deallocation, reference counting, and boundary conditions.
- Implemented Red-Black Tree tests in `test_rbtree.cc`, validating insertion, deletion, and iteration.
- Added Slab Allocator tests in `test_slab.cc`, covering various allocation sizes, edge cases, and operator overloads.
- Created Spinlock tests in `test_spinlock.cc`, ensuring proper locking behavior and interrupt state preservation.
- Developed Virtual Memory Area (VMA) tests in `test_vma.cc`, validating region mapping, unmapping, and fault handling.
- Added tests for Virtual Memory Management (VMM) in `test_vmm.cc`, verifying address translation and page alignment.
Diffstat (limited to 'na/test/selftest.cc')
| -rw-r--r-- | na/test/selftest.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/na/test/selftest.cc b/na/test/selftest.cc new file mode 100644 index 0000000..a992ae2 --- /dev/null +++ b/na/test/selftest.cc @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright (C) 2026 Richard Qin */ + +/* + * Boot Self-Test Runner + * + * Entry point that invokes all registered self-test suites. + * Called from kernel_main() after all subsystem initialization. + */ + +#include <lume/selftest.h> + +/* Individual test suite entry points */ +void selftest_pmm(); +void selftest_slab(); +void selftest_spinlock(); +void selftest_rbtree(); +void selftest_vmm(); +void selftest_fdt(); +void selftest_vma(); +void selftest_atomic(); + +void selftest_run_all() +{ + early_puts("\n========================================\n"); + early_puts(" Boot Self-Test Suite\n"); + early_puts("========================================\n"); + + selftest_spinlock(); + selftest_pmm(); + selftest_slab(); + selftest_rbtree(); + selftest_vmm(); + selftest_vma(); + selftest_atomic(); + selftest_fdt(); + + early_puts("========================================\n"); + early_puts(" All self-tests PASSED\n"); + early_puts("========================================\n\n"); +} |
