diff options
| author | Marie Zhussupova <marievic@google.com> | 2025-06-26 17:17:29 +0000 |
|---|---|---|
| committer | Shuah Khan <skhan@linuxfoundation.org> | 2025-06-27 15:00:05 -0600 |
| commit | 5ac244b9cc8f49c945c5be67ed7d6f8ac6ed9321 (patch) | |
| tree | 191af2732158b1635f45e4f9ad28c80192a05ebb /lib/kunit/test.c | |
| parent | 63d0a9123120a2e10861ac7f6dc474bee653d3b2 (diff) | |
| download | linux-5ac244b9cc8f49c945c5be67ed7d6f8ac6ed9321.tar.gz linux-5ac244b9cc8f49c945c5be67ed7d6f8ac6ed9321.tar.bz2 linux-5ac244b9cc8f49c945c5be67ed7d6f8ac6ed9321.zip | |
kunit: Make default kunit_test timeout configurable via both a module parameter and a Kconfig option
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.
Link: https://lore.kernel.org/r/20250626171730.1765004-1-marievic@google.com
Signed-off-by: Marie Zhussupova <marievic@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'lib/kunit/test.c')
| -rw-r--r-- | lib/kunit/test.c | 15 |
1 files changed, 8 insertions, 7 deletions
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 @@ -70,6 +70,13 @@ 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 * 1 - only when there is more than one subtest @@ -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); } |
