1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2013 Google, Inc.
10 #include <linux/bitops.h>
13 * struct unit_test_state - Entire state of test system
15 * @fail_count: Number of tests that failed
16 * @start: Store the starting mallinfo when doing leak test
17 * @priv: A pointer to some other info some suites want to track
18 * @of_root: Record of the livetree root node (used for setting up tests)
19 * @expect_str: Temporary string used to hold expected string value
20 * @actual_str: Temporary string used to hold actual string value
22 struct unit_test_state {
24 struct mallinfo start;
26 struct device_node *of_root;
31 /* Test flags for each test */
33 UT_TESTF_SCAN_PDATA = BIT(0), /* test needs platform data */
34 UT_TESTF_PROBE_TEST = BIT(1), /* probe test uclass */
35 UT_TESTF_SCAN_FDT = BIT(2), /* scan device tree */
36 UT_TESTF_FLAT_TREE = BIT(3), /* test needs flat DT */
37 UT_TESTF_LIVE_TREE = BIT(4), /* needs live device tree */
38 UT_TESTF_CONSOLE_REC = BIT(5), /* needs console recording */
42 * struct unit_test - Information about a unit test
45 * @func: Function to call to perform test
46 * @flags: Flags indicated pre-conditions for test
51 int (*func)(struct unit_test_state *state);
56 * UNIT_TEST() - create linker generated list entry for unit a unit test
58 * The macro UNIT_TEST() is used to create a linker generated list entry. These
59 * list entries are enumerate tests that can be execute using the ut command.
60 * The list entries are used both by the implementation of the ut command as
61 * well as in a related Python test.
63 * For Python testing the subtests are collected in Python function
64 * generate_ut_subtest() by applying a regular expression to the lines of file
65 * u-boot.sym. The list entries have to follow strict naming conventions to be
66 * matched by the expression.
68 * Use UNIT_TEST(foo_test_bar, _flags, foo_test) for a test bar in test suite
69 * foo that can be executed via command 'ut foo bar' and is implemented in
70 * function foo_test_bar().
72 * @_name: concatenation of name of the test suite, "_test_", and the name
74 * @_flags: an integer field that can be evaluated by the test suite
76 * @_suite: name of the test suite concatenated with "_test"
78 #define UNIT_TEST(_name, _flags, _suite) \
79 ll_entry_declare(struct unit_test, _name, _suite) = { \
86 /* Sizes for devres tests */
88 TEST_DEVRES_SIZE = 100,
89 TEST_DEVRES_COUNT = 10,
90 TEST_DEVRES_TOTAL = TEST_DEVRES_SIZE * TEST_DEVRES_COUNT,
92 /* A few different sizes */
93 TEST_DEVRES_SIZE2 = 15,
94 TEST_DEVRES_SIZE3 = 37,
97 #endif /* __TEST_TEST_H */