Lines Matching full:test

3  * Example KUnit test to show how to use KUnit.
9 #include <kunit/test.h>
12 * This is the most fundamental element of KUnit, the test case. A test case
14 * any expectations or assertions are not met, the test fails; otherwise, the
15 * test passes.
17 * In KUnit, a test case is just a function with the signature
19 * information about the current test.
21 static void example_simple_test(struct kunit *test) in example_simple_test() argument
25 * to test a piece of code, you set some expectations about what the in example_simple_test()
26 * code should do. KUnit then runs the test and verifies that the code's in example_simple_test()
29 KUNIT_EXPECT_EQ(test, 1 + 1, 2); in example_simple_test()
33 * This is run once before each test case, see the comment on
36 static int example_test_init(struct kunit *test) in example_test_init() argument
38 kunit_info(test, "initializing\n"); in example_test_init()
44 * This test should always be skipped.
46 static void example_skip_test(struct kunit *test) in example_skip_test() argument
49 kunit_info(test, "You should not see a line below."); in example_skip_test()
51 /* Skip (and abort) the test */ in example_skip_test()
52 kunit_skip(test, "this test should be skipped"); in example_skip_test()
55 KUNIT_FAIL(test, "You should not see this line."); in example_skip_test()
59 * This test should always be marked skipped.
61 static void example_mark_skipped_test(struct kunit *test) in example_mark_skipped_test() argument
64 kunit_info(test, "You should see a line below."); in example_mark_skipped_test()
66 /* Skip (but do not abort) the test */ in example_mark_skipped_test()
67 kunit_mark_skipped(test, "this test should be skipped"); in example_mark_skipped_test()
70 kunit_info(test, "You should see this line."); in example_mark_skipped_test()
73 * Here we make a list of all the test cases we want to add to the test suite
78 * This is a helper to create a test case object from a test case
80 * use KUnit, just know that this is how you associate test cases with a
81 * test suite.
92 * Test cases are defined as belonging to the suite by adding them to
96 * will be used by every test; this is accomplished with an `init` function
97 * which runs before each test case is invoked. Similarly, an `exit` function
98 * may be specified which runs after every test case and can be used to for
99 * cleanup. For clarity, running tests in a test suite would behave as follows:
101 * suite.init(test);
102 * suite.test_case[0](test);
103 * suite.exit(test);
104 * suite.init(test);
105 * suite.test_case[1](test);
106 * suite.exit(test);
116 * This registers the above test suite telling KUnit that this is a suite of