Automated test suite for ThunderOS v0.10.0+
tests/
├── unit/ # Built-in kernel tests (C)
│ ├── test_memory_mgmt.c # Memory, DMA, paging tests
│ ├── test_elf.c # ELF loader tests
│ ├── test_memory_isolation.c # Memory isolation tests
│ └── test_vterm.c # Virtual terminal tests
├── scripts/ # Automated test scripts
│ ├── test_kernel.sh # Comprehensive kernel test
│ ├── test_boot.sh # Quick boot test
│ ├── test_integration.sh # Integration test
│ └── run_all_tests.sh # Master test runner
├── framework/ # Test framework
│ ├── kunit.c # Test assertions
│ └── kunit.h # Test macros
└── outputs/ # Test output files (generated)
# Full test suite
make test
# Quick boot test only
make test-quick# Comprehensive kernel functionality test
./tests/scripts/test_kernel.sh
# Quick boot test
./tests/scripts/test_boot.sh
# Integration test
./tests/scripts/test_integration.sh
# All tests
./tests/scripts/run_all_tests.shUnit tests compiled into the kernel that run automatically during boot:
-
Memory Management (
test_memory_mgmt.c)- DMA allocation and alignment
- kmalloc/kfree operations
- Paging and virtual memory
-
ELF Loader (
test_elf.c)- ELF header validation
- Program header parsing
-
Memory Isolation (
test_memory_isolation.c)- User/kernel address space separation
These tests output results to the console and are verified by test_kernel.sh.
Shell scripts that run QEMU non-interactively and verify output:
-
test_kernel.sh- Comprehensive test (17 checks)- Kernel boot and initialization
- All subsystem initialization
- Built-in test results
- VirtIO and ext2 mounting
- User-mode shell launch
-
test_boot.sh- Quick sanity test (6 checks)- Kernel banner
- UART initialization
- Memory management
- Trap handler
-
test_integration.sh- Integration test (7 checks)- VirtIO block device
- ext2 filesystem
- Shell startup
All tests are non-interactive. They:
- Build the kernel and userland
- Create an ext2 filesystem image
- Run QEMU with a timeout (no stdin)
- Capture and analyze output
- Pattern-match for expected strings
This allows all tests to run in CI without user input.
Test output is saved in tests/outputs/:
kernel_test_output.txt- Output fromtest_kernel.shboot_test_output.txt- Output fromtest_boot.shintegration_test_output.txt- Output fromtest_integration.sh
- Create a new file in
tests/unit/ - Include
tests/framework/kunit.h - Write test functions using
KUNIT_ASSERT_*macros - Call your tests from
kernel_main()inkernel/main.c
- Edit
tests/scripts/test_kernel.sh - Add a new
greppattern to check for expected output - Update the test count and summary
- QEMU 10.1.2+ with riscv64 support
- RISC-V GCC toolchain
- e2fsprogs (
mkfs.ext2)
For CI/CD pipelines:
# Run full test suite (exit code 0 = success)
make test
# Or for faster CI:
make test-quickTests are designed to complete within 30 seconds and require no user interaction.