
Test Rust Kernel Code With KUnit and Rust Doctests
Run the Rust doctests of the kernel crate and write your own kunit_tests suite on Linux 6.18, with kunit.py, KTAP output and the limits of each test kind.
Tag
7 posts

Run the Rust doctests of the kernel crate and write your own kunit_tests suite on Linux 6.18, with kunit.py, KTAP output and the limits of each test kind.

Compare one Linux 6.18 module in C and Rust for safety, error handling, build cost and API coverage, then pick the language for your next kernel module.

Write, build and load a first Rust kernel module in a Linux 6.18 tree: the module! macro, init and Drop, KVec, Kconfig and Makefile entries and dmesg output.

Install the Rust toolchain, bindgen and libclang, check them with make rustavailable, enable CONFIG_RUST in a Linux 6.18 tree and build the Rust samples.

What changes when you write Rust for the Linux 6.18 kernel: no std, fallible allocation, errno Results, panics that act like BUG, and no main function.

What Rust for Linux is, what the 6.18 kernel actually contains, why the project adopted it as an experiment, and how abstractions keep unsafe code in one place.

Write Linux 6.18 drivers in Rust: toolchain, module anatomy, pinned initialization, device lifetimes, misc, platform, PCI and PHY drivers, testing and style.