On Fri, 27 Jun 2025 at 01:17, Marie Zhussupova marievic@google.com wrote:
To accommodate varying hardware performance and use cases, the default kunit test case timeout (currently 300 seconds) is now configurable. Users can adjust the timeout by either setting the 'timeout' module parameter or the KUNIT_DEFAULT_TIMEOUT Kconfig option to their desired timeout in seconds.
Signed-off-by: Marie Zhussupova marievic@google.com
Thanks very much. This works well here!
Reviewed-by: David Gow davidgow@google.com
Cheers, -- David
lib/kunit/Kconfig | 13 +++++++++++++ lib/kunit/test.c | 15 ++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/lib/kunit/Kconfig b/lib/kunit/Kconfig index a97897edd964..c10ede4b1d22 100644 --- a/lib/kunit/Kconfig +++ b/lib/kunit/Kconfig @@ -93,4 +93,17 @@ config KUNIT_AUTORUN_ENABLED In most cases this should be left as Y. Only if additional opt-in behavior is needed should this be set to N.
+config KUNIT_DEFAULT_TIMEOUT
int "Default value of the timeout module parameter"
default 300
help
Sets the default timeout, in seconds, for Kunit test cases. This value
is further multiplied by a factor determined by the assigned speed
setting: 1x for `DEFAULT`, 3x for `KUNIT_SPEED_SLOW`, and 12x for
`KUNIT_SPEED_VERY_SLOW`. This allows slower tests on slower machines
sufficient time to complete.
If unsure, the default timeout of 300 seconds is suitable for most
cases.
endif # KUNIT diff --git a/lib/kunit/test.c b/lib/kunit/test.c index 002121675605..f3c6b11f12b8 100644 --- a/lib/kunit/test.c +++ b/lib/kunit/test.c @@ -69,6 +69,13 @@ static bool enable_param; module_param_named(enable, enable_param, bool, 0); MODULE_PARM_DESC(enable, "Enable KUnit tests");
+/*
- Configure the base timeout.
- */
+static unsigned long kunit_base_timeout = CONFIG_KUNIT_DEFAULT_TIMEOUT; +module_param_named(timeout, kunit_base_timeout, ulong, 0644); +MODULE_PARM_DESC(timeout, "Set the base timeout for Kunit test cases");
/*
- KUnit statistic mode:
- 0 - disabled
@@ -393,12 +400,6 @@ static int kunit_timeout_mult(enum kunit_speed speed) static unsigned long kunit_test_timeout(struct kunit_suite *suite, struct kunit_case *test_case) { int mult = 1;
/*
* TODO: Make the default (base) timeout configurable, so that users with
* particularly slow or fast machines can successfully run tests, while
* still taking advantage of the relative speed.
*/
unsigned long default_timeout = 300; /* * The default test timeout is 300 seconds and will be adjusted by mult
@@ -409,7 +410,7 @@ static unsigned long kunit_test_timeout(struct kunit_suite *suite, struct kunit_ mult = kunit_timeout_mult(suite->attr.speed); if (test_case->attr.speed != KUNIT_SPEED_UNSET) mult = kunit_timeout_mult(test_case->attr.speed);
return mult * default_timeout * msecs_to_jiffies(MSEC_PER_SEC);
return mult * kunit_base_timeout * msecs_to_jiffies(MSEC_PER_SEC);
}
-- 2.50.0.rc2.761.g2dc52ea45b-goog