aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kunit
diff options
context:
space:
mode:
authorDavid Gow <davidgow@google.com>2023-05-25 12:21:29 +0800
committerShuah Khan <skhan@linuxfoundation.org>2023-05-25 08:53:01 -0600
commit00e63f8afcfc6bf93d75141c51d35e8a40e86363 (patch)
tree2e2107623525c6b11c00a99e075c3398214d2882 /lib/kunit
parentb9dce8a1ed3efe0f5c0957f4605140f204226a0f (diff)
downloadlinux-00e63f8afcfc6bf93d75141c51d35e8a40e86363.tar.gz
kunit: executor_test: Use kunit_add_action()
Now we have the kunit_add_action() function, we can use it to implement kfree_at_end() and free_subsuite_at_end() without the need for extra helper functions. Reviewed-by: Benjamin Berg <benjamin.berg@intel.com> Reviewed-by: Maxime Ripard <maxime@cerno.tech> Tested-by: Maxime Ripard <maxime@cerno.tech> Signed-off-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'lib/kunit')
-rw-r--r--lib/kunit/executor_test.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/kunit/executor_test.c b/lib/kunit/executor_test.c
index 0cea31c27b230..ce6749af374de 100644
--- a/lib/kunit/executor_test.c
+++ b/lib/kunit/executor_test.c
@@ -125,11 +125,6 @@ kunit_test_suites(&executor_test_suite);
/* Test helpers */
-static void kfree_res_free(struct kunit_resource *res)
-{
- kfree(res->data);
-}
-
/* Use the resource API to register a call to kfree(to_free).
* Since we never actually use the resource, it's safe to use on const data.
*/
@@ -138,8 +133,10 @@ static void kfree_at_end(struct kunit *test, const void *to_free)
/* kfree() handles NULL already, but avoid allocating a no-op cleanup. */
if (IS_ERR_OR_NULL(to_free))
return;
- kunit_alloc_resource(test, NULL, kfree_res_free, GFP_KERNEL,
- (void *)to_free);
+
+ kunit_add_action(test,
+ (kunit_action_t *)kfree,
+ (void *)to_free);
}
static struct kunit_suite *alloc_fake_suite(struct kunit *test,