Merged
Conversation
Add a CUnit-compatible test framework (KUnit) that compiles into the kernel and runs suites on boot, reporting results over COM1 serial. - src/kunit.h: public CUnit API (CU_add_suite/test, CU_ASSERT_* macros) - tests/kernel/kunit.c: static-registry implementation, no libc needed - tests/kernel/test_runner.c: run_tests() entry point registered in kernel_main - tests/kernel/test_smoke.c: harness self-check smoke suite - tests/kernel/test_string_k.c: 13 kernel-side string.c tests - tests/kernel/test_ctype_k.c: 5 kernel-side ctype.c tests - build.sh: TESTING=1 compiles tests/kernel/*.c with -DTESTING -I src/ - kernel.c: #ifdef TESTING calls run_tests() and exits with its return code - docker-ci / docker-test targets build with TESTING=1 - CI now greps serial output for ALL TESTS PASSED instead of Kernel Booted - docs/testing.md: full documentation
Delete tests/test_string.c and tests/test_ctype.c (legacy host-only tests), drop the `make test` target, and update docs/testing.md to remove references to them. KUnit via `make docker-test` is now the only test path.
amorrisCS
approved these changes
Apr 2, 2026
Collaborator
amorrisCS
left a comment
There was a problem hiding this comment.
Reviewed all files. Everything looks to be good, the only thing I wonder about is if having a longer timeout could introduce discrepancies elsewhere in implementation - though that's more of a then thing instead of a now thing. Even if it does happen, I doubt it would be that hard to correct in the places that need it.
Overall, everything looks great!
Owner
Author
|
thanks for the feedback! the CI timeout was upped to give the tests some headroom to execute without github killing it before they finish up. shouldn't effect the build itself afaik. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sets up KUnit, a bare-metal CUnit-compatible test harness, so Sprint 1 tests (and future tests) have a consistent structure.
Since the kernel can't link against libc, src/kunit.h + tests/kernel/kunit.c implement the CUnit 2.x public API from scratch, routing all output to COM1 serial. Tests are compiled in when TESTING=1 and run on boot before any other kernel work, then exit via qemu_exit() with a pass/fail code.
CI (make docker-ci) now builds with TESTING=1 and greps serial output for ALL TESTS PASSED / TESTS FAILED rather than just Kernel Booted.
22 tests ship with the harness: 4 smoke tests exercising the assert macro families, 13 string tests, and 5 ctype tests.
A make docker-test target is also added for interactive local runs with visible serial output.