[PATCH] kunit: make FAULT_TEST default to n when PANIC_ON_OOPS

Brendan Jackman posted 1 patch 1 week, 5 days ago
lib/kunit/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] kunit: make FAULT_TEST default to n when PANIC_ON_OOPS
Posted by Brendan Jackman 1 week, 5 days ago
As describe in the help string, the user might want to disable these
tests if they don't like to see stacktraces/BUG etc in their kernel log.

However, if they enable PANIC_ON_OOPS, these tests also crash the
machine, which it's safe to assume _almost_ nobody wants.

One might argue that _absolutely_ nobody ever wants their kernel to
crash so this should just be a hard dependency instead of a default.
However, since this is rather special code that's anyway concerned with
deliberately doing "bad" things, the normal rules don't seem to apply,
hence prefer flexibility and allow users to set up a crashing Kconfig if
they so choose.

Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
 lib/kunit/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/kunit/Kconfig b/lib/kunit/Kconfig
index 50ecf55d2b9c8a82f2aff7a0b4156bd6179b0a2f..498cc51e493dc9a819e012b8082fb765f25512b9 100644
--- a/lib/kunit/Kconfig
+++ b/lib/kunit/Kconfig
@@ -28,7 +28,7 @@ config KUNIT_FAULT_TEST
 	bool "Enable KUnit tests which print BUG stacktraces"
 	depends on KUNIT_TEST
 	depends on !UML
-	default y
+	default !PANIC_ON_OOPS
 	help
 	  Enables fault handling tests for the KUnit framework. These tests may
 	  trigger a kernel BUG(), and the associated stack trace, even when they

---
base-commit: 7bc16e72ddb993d706f698c2f6cee694e485f557
change-id: 20251207-kunit-fault-no-panic-e9bdce848031

Best regards,
-- 
Brendan Jackman <jackmanb@google.com>
Re: [PATCH] kunit: make FAULT_TEST default to n when PANIC_ON_OOPS
Posted by David Gow 1 week, 2 days ago
On Sun, 7 Dec 2025 at 10:17, Brendan Jackman <jackmanb@google.com> wrote:
>
> As describe in the help string, the user might want to disable these
> tests if they don't like to see stacktraces/BUG etc in their kernel log.
>
> However, if they enable PANIC_ON_OOPS, these tests also crash the
> machine, which it's safe to assume _almost_ nobody wants.
>
> One might argue that _absolutely_ nobody ever wants their kernel to
> crash so this should just be a hard dependency instead of a default.
> However, since this is rather special code that's anyway concerned with
> deliberately doing "bad" things, the normal rules don't seem to apply,
> hence prefer flexibility and allow users to set up a crashing Kconfig if
> they so choose.
>
> Signed-off-by: Brendan Jackman <jackmanb@google.com>
> ---

I like this compromise: I think there are still some cases where we
would want PANIC_ON_OOPS + faulting tests, particularly if you're
splitting the test execution over several boots (e.g. --run_isolated),
but it's got to be vanishingly rare.

So this is an excellent default.

Reviewed-by: David Gow <davidgow@google.com>

Cheers,
-- David

>  lib/kunit/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/kunit/Kconfig b/lib/kunit/Kconfig
> index 50ecf55d2b9c8a82f2aff7a0b4156bd6179b0a2f..498cc51e493dc9a819e012b8082fb765f25512b9 100644
> --- a/lib/kunit/Kconfig
> +++ b/lib/kunit/Kconfig
> @@ -28,7 +28,7 @@ config KUNIT_FAULT_TEST
>         bool "Enable KUnit tests which print BUG stacktraces"
>         depends on KUNIT_TEST
>         depends on !UML
> -       default y
> +       default !PANIC_ON_OOPS
>         help
>           Enables fault handling tests for the KUnit framework. These tests may
>           trigger a kernel BUG(), and the associated stack trace, even when they
>
> ---
> base-commit: 7bc16e72ddb993d706f698c2f6cee694e485f557
> change-id: 20251207-kunit-fault-no-panic-e9bdce848031
>
> Best regards,
> --
> Brendan Jackman <jackmanb@google.com>
>