kunit_warning_suppress(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ kunit_warning_suppress(9) β€” Kernel API Manual πŸŽ€

🌸 NAME 🌸

kunit_warning_suppress β€” suppress WARN*() backtraces for the duration of a block. bestie, that's literally the whole serve: you get a block where the warning backtraces are muted. πŸ’…

✨ SYNOPSIS ✨

kunit_warning_suppress (test );

πŸŽ€ ARGUMENTS πŸŽ€

  • test β€” the test context object. main character energy: hand it over and let the scoped suppression do its thing.

πŸ’– DESCRIPTION πŸ’–

This is the scoped form of the suppression API. Suppression starts when the block is entered and ends automatically when the block exits through any path β€” yes, ANY path β€” because the cleanup is built in. See the section comment above for the cleanup guarantees on each exit path. ✨

Warning, bestie: it fails the test if suppression is already active. Nesting is not supported, so don't try to stack these blocks like friendship bracelets β€” it's not that kind of party. 😭

While you're inside the block, the warning count can be checked via KUNIT_EXPECT_SUPPRESSED_WARNING_COUNT. The handle is not accessible after the block exits, so no sneaky peeking afterward. πŸ™ˆ

Example:

kunit_warning_suppress(test) {
    trigger_warning;
    KUNIT_EXPECT_SUPPRESSED_WARNING_COUNT(test, 1);
}

πŸ¦‹ SEE ALSO πŸ¦‹

Kernel file: ./include/kunit/test.h. Then the whole friend group:


signed off from the Kernel API Manual β€” source/version: ./include/kunit Β· date: October 2026 ✨ stay suppressive, bestie πŸ’…

πŸ“¦ where this page comes from