Commit a5ce66ad authored by David Gow's avatar David Gow Committed by Shuah Khan

kunit: example: Provide example exit functions

Add an example .exit and .suite_exit function to the KUnit example
suite. Given exit functions are a bit more subtle than init functions
(due to running in a different kthread, and running even after tests or
test init functions fail), providing an easy place to experiment with
them is useful.
Reviewed-by: default avatarRae Moar <rmoar@google.com>
Signed-off-by: default avatarDavid Gow <davidgow@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent cdc87bda
...@@ -41,6 +41,16 @@ static int example_test_init(struct kunit *test) ...@@ -41,6 +41,16 @@ static int example_test_init(struct kunit *test)
return 0; return 0;
} }
/*
* This is run once after each test case, see the comment on
* example_test_suite for more information.
*/
static void example_test_exit(struct kunit *test)
{
kunit_info(test, "cleaning up\n");
}
/* /*
* This is run once before all test cases in the suite. * This is run once before all test cases in the suite.
* See the comment on example_test_suite for more information. * See the comment on example_test_suite for more information.
...@@ -52,6 +62,16 @@ static int example_test_init_suite(struct kunit_suite *suite) ...@@ -52,6 +62,16 @@ static int example_test_init_suite(struct kunit_suite *suite)
return 0; return 0;
} }
/*
* This is run once after all test cases in the suite.
* See the comment on example_test_suite for more information.
*/
static void example_test_exit_suite(struct kunit_suite *suite)
{
kunit_info(suite, "exiting suite\n");
}
/* /*
* This test should always be skipped. * This test should always be skipped.
*/ */
...@@ -211,7 +231,9 @@ static struct kunit_case example_test_cases[] = { ...@@ -211,7 +231,9 @@ static struct kunit_case example_test_cases[] = {
static struct kunit_suite example_test_suite = { static struct kunit_suite example_test_suite = {
.name = "example", .name = "example",
.init = example_test_init, .init = example_test_init,
.exit = example_test_exit,
.suite_init = example_test_init_suite, .suite_init = example_test_init_suite,
.suite_exit = example_test_exit_suite,
.test_cases = example_test_cases, .test_cases = example_test_cases,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment