diff options
author | Marie Zhussupova <marievic@google.com> | 2025-08-26 17:13:32 +0800 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2025-08-26 23:36:03 -0600 |
commit | 241423580e5e8d8b10b14b382379f4928b87be17 (patch) | |
tree | 08d11182bd40fa40483938a7e30d6dc89930db94 /rust/kernel | |
parent | 4b59300ba4d2362b02c2a9077047bbabceea67d7 (diff) |
kunit: Introduce param_init/exit for parameterized test context management
Add (*param_init) and (*param_exit) function pointers to
`struct kunit_case`. Users will be able to set them via the new
KUNIT_CASE_PARAM_WITH_INIT() macro.
param_init/exit will be invoked by kunit_run_tests() once before and once
after the parameterized test, respectively. They will receive the
`struct kunit` that holds the parameterized test context; facilitating
init and exit for shared state.
This patch also sets param_init/exit to None in rust/kernel/kunit.rs.
Link: https://lore.kernel.org/r/20250826091341.1427123-3-davidgow@google.com
Reviewed-by: Rae Moar <rmoar@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Marie Zhussupova <marievic@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'rust/kernel')
-rw-r--r-- | rust/kernel/kunit.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/rust/kernel/kunit.rs b/rust/kernel/kunit.rs index 41efd87595d6..b1c97f8029c7 100644 --- a/rust/kernel/kunit.rs +++ b/rust/kernel/kunit.rs @@ -210,6 +210,8 @@ pub const fn kunit_case( status: kernel::bindings::kunit_status_KUNIT_SUCCESS, module_name: core::ptr::null_mut(), log: core::ptr::null_mut(), + param_init: None, + param_exit: None, } } @@ -229,6 +231,8 @@ pub const fn kunit_case_null() -> kernel::bindings::kunit_case { status: kernel::bindings::kunit_status_KUNIT_SUCCESS, module_name: core::ptr::null_mut(), log: core::ptr::null_mut(), + param_init: None, + param_exit: None, } } |