Closed alfreb closed 1 month ago
It seems useful to have this for verifying that everything works correctly after changes to early boot stages of the kernel, in particular when we update our dependencies to make sure that everything works as intended (e.g. for nixpkgs / musl / compiler / c++ version upgrades). Great that you added a test as well!
The kernel itself builds and integration tests seem to work fine, but the unittests are failing to build for me. Here's the error from nix-build ./unittests
:
/build/test/../api/kprint:43:13: error: conflicting types for 'kprint'
43 | extern void kprint(const char*);
| ^
/build/test/lest_util/os_mock.cpp:80:6: note: previous definition is here
80 | void kprint(char* str)
Oups, good catch, thank you! Fixed.
Everything compiles and tests are green. I noticed a call to std::string that I missed on first review - I'm not sure how early FILLLINE is called, but you may want to replace that with std::pmr::string
to avoid any calls to malloc before libc is initialised.
The intention is to create a reusable pattern for kernel self tests and diagnostics that costs nothing default. We have quite a few defensive validation steps in the kernel added organically as issues have been found. Ideally a fast booting kernel should always do the correct thing without having to validate. In practice, validation is crucial.
With this proposed setup we can optionally add a validation plugin (fieldmedic) that performs more extensive self tests after key checkpoints in the unikernel lifetime has been reached, with negligible cost in the default case (the cost of an empty function call per hook) and with zero cost when toggled off at compile time.
See commit messages for details.
To try it out: