linux/lib/kunit/try-catch-impl.h
Ujwal Jain 63d0a91231 kunit: Adjust kunit_test timeout based on test_{suite,case} speed
Currently, the in-kernel kunit test case timeout is 300 seconds. (There
is a separate timeout mechanism for the whole test execution in
kunit.py, but that's unrelated.) However, tests marked 'slow' or 'very
slow' may timeout, particularly on slower machines.

Implement a multiplier to the test-case timeout, so that slower tests
have longer to complete:
- DEFAULT -> 1x default timeout
- KUNIT_SPEED_SLOW -> 3x default timeout
- KUNIT_SPEED_VERY_SLOW -> 12x default timeout

A further change is planned to allow user configuration of the
default/base timeout to allow people with faster or slower machines to
adjust these to their use-cases.

Link: https://lore.kernel.org/r/20250614084711.2654593-2-davidgow@google.com
Signed-off-by: Ujwal Jain <ujwaljain@google.com>
Co-developed-by: David Gow <davidgow@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Reviewed-by: Rae Moar <rmoar@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2025-06-24 20:47:39 -06:00

29 lines
687 B
C++

/* SPDX-License-Identifier: GPL-2.0 */
/*
* Internal kunit try catch implementation to be shared with tests.
*
* Copyright (C) 2019, Google LLC.
* Author: Brendan Higgins <brendanhiggins@google.com>
*/
#ifndef _KUNIT_TRY_CATCH_IMPL_H
#define _KUNIT_TRY_CATCH_IMPL_H
#include <kunit/try-catch.h>
#include <linux/types.h>
struct kunit;
static inline void kunit_try_catch_init(struct kunit_try_catch *try_catch,
struct kunit *test,
kunit_try_catch_func_t try,
kunit_try_catch_func_t catch,
unsigned long timeout)
{
try_catch->test = test;
try_catch->try = try;
try_catch->catch = catch;
try_catch->timeout = timeout;
}
#endif /* _KUNIT_TRY_CATCH_IMPL_H */