Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Marie Zhussupova and committed by
Shuah Khan
5ac244b9 63d0a912

+21 -7
+13
lib/kunit/Kconfig
··· 93 93 In most cases this should be left as Y. Only if additional opt-in 94 94 behavior is needed should this be set to N. 95 95 96 + config KUNIT_DEFAULT_TIMEOUT 97 + int "Default value of the timeout module parameter" 98 + default 300 99 + help 100 + Sets the default timeout, in seconds, for Kunit test cases. This value 101 + is further multiplied by a factor determined by the assigned speed 102 + setting: 1x for `DEFAULT`, 3x for `KUNIT_SPEED_SLOW`, and 12x for 103 + `KUNIT_SPEED_VERY_SLOW`. This allows slower tests on slower machines 104 + sufficient time to complete. 105 + 106 + If unsure, the default timeout of 300 seconds is suitable for most 107 + cases. 108 + 96 109 endif # KUNIT
+8 -7
lib/kunit/test.c
··· 70 70 MODULE_PARM_DESC(enable, "Enable KUnit tests"); 71 71 72 72 /* 73 + * Configure the base timeout. 74 + */ 75 + static unsigned long kunit_base_timeout = CONFIG_KUNIT_DEFAULT_TIMEOUT; 76 + module_param_named(timeout, kunit_base_timeout, ulong, 0644); 77 + MODULE_PARM_DESC(timeout, "Set the base timeout for Kunit test cases"); 78 + 79 + /* 73 80 * KUnit statistic mode: 74 81 * 0 - disabled 75 82 * 1 - only when there is more than one subtest ··· 400 393 static unsigned long kunit_test_timeout(struct kunit_suite *suite, struct kunit_case *test_case) 401 394 { 402 395 int mult = 1; 403 - /* 404 - * TODO: Make the default (base) timeout configurable, so that users with 405 - * particularly slow or fast machines can successfully run tests, while 406 - * still taking advantage of the relative speed. 407 - */ 408 - unsigned long default_timeout = 300; 409 396 410 397 /* 411 398 * The default test timeout is 300 seconds and will be adjusted by mult ··· 410 409 mult = kunit_timeout_mult(suite->attr.speed); 411 410 if (test_case->attr.speed != KUNIT_SPEED_UNSET) 412 411 mult = kunit_timeout_mult(test_case->attr.speed); 413 - return mult * default_timeout * msecs_to_jiffies(MSEC_PER_SEC); 412 + return mult * kunit_base_timeout * msecs_to_jiffies(MSEC_PER_SEC); 414 413 } 415 414 416 415