Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Writing Tests

Tests are Rust functions annotated with #[ktstr_test]. Each test boots a KVM VM, runs the scenario inside it, and evaluates results on the host.

use ktstr::prelude::*;

#[ktstr_test(llcs = 1, cores = 2, threads = 1)]
fn my_test(ctx: &Ctx) -> Result<AssertResult> {
    execute_defs(ctx, vec![
        CgroupDef::named("cg_0").workers(2),
        CgroupDef::named("cg_1").workers(2),
    ])
}

Run with cargo ktstr test --kernel ../linux. See Getting Started for setup and The #[ktstr_test] Macro for all available attributes. Each test also generates gauntlet variants across topology presets and flag profiles. See Gauntlet Tests. For scenarios that need logic beyond what the ops system can express, see Custom Scenarios.