Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kunit: add example suite to test init suites

Add example_init_test_suite to allow for testing the feature of running
test suites marked as init to indicate they use init data and/or
functions.

This suite should always pass and uses a simple init function.

This suite can also be used to test the is_init attribute introduced in
the next patch.

Signed-off-by: Rae Moar <rmoar@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Rae Moar and committed by
Shuah Khan
2cf45281 d81f0d7b

+37
+37
lib/kunit/kunit-example-test.c
··· 287 287 */ 288 288 kunit_test_suites(&example_test_suite); 289 289 290 + static int __init init_add(int x, int y) 291 + { 292 + return (x + y); 293 + } 294 + 295 + /* 296 + * This test should always pass. Can be used to test init suites. 297 + */ 298 + static void __init example_init_test(struct kunit *test) 299 + { 300 + KUNIT_EXPECT_EQ(test, init_add(1, 1), 2); 301 + } 302 + 303 + /* 304 + * The kunit_case struct cannot be marked as __initdata as this will be 305 + * used in debugfs to retrieve results after test has run 306 + */ 307 + static struct kunit_case __refdata example_init_test_cases[] = { 308 + KUNIT_CASE(example_init_test), 309 + {} 310 + }; 311 + 312 + /* 313 + * The kunit_suite struct cannot be marked as __initdata as this will be 314 + * used in debugfs to retrieve results after test has run 315 + */ 316 + static struct kunit_suite example_init_test_suite = { 317 + .name = "example_init", 318 + .test_cases = example_init_test_cases, 319 + }; 320 + 321 + /* 322 + * This registers the test suite and marks the suite as using init data 323 + * and/or functions. 324 + */ 325 + kunit_test_init_section_suites(&example_init_test_suite); 326 + 290 327 MODULE_LICENSE("GPL v2");