Skip to content

[SCRUM-134] CUnit Harness#15

Merged
LordHerdier merged 3 commits intomainfrom
feat/SCRUM-134-CUnit-harness
Apr 2, 2026
Merged

[SCRUM-134] CUnit Harness#15
LordHerdier merged 3 commits intomainfrom
feat/SCRUM-134-CUnit-harness

Conversation

@LordHerdier
Copy link
Copy Markdown
Owner

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.

LordHerdier and others added 3 commits April 2, 2026 07:33
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.
@LordHerdier LordHerdier self-assigned this Apr 2, 2026
Copy link
Copy Markdown
Collaborator

@amorrisCS amorrisCS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@LordHerdier
Copy link
Copy Markdown
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.

@LordHerdier LordHerdier merged commit aa58fee into main Apr 2, 2026
2 checks passed
@LordHerdier LordHerdier deleted the feat/SCRUM-134-CUnit-harness branch April 2, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants