Commit 00e63f8a authored by David Gow's avatar David Gow Committed by Shuah Khan
Browse files

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: default avatarBenjamin Berg <benjamin.berg@intel.com>
Reviewed-by: default avatarMaxime Ripard <maxime@cerno.tech>
Tested-by: default avatarMaxime Ripard <maxime@cerno.tech>
Signed-off-by: default avatarDavid Gow <davidgow@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent b9dce8a1
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -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,7 +133,9 @@ 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,

	kunit_add_action(test,
			(kunit_action_t *)kfree,
			(void *)to_free);
}