Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Joe Hershberger | 3a77be5 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2013 Google, Inc. |
Joe Hershberger | 3a77be5 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef __TEST_TEST_H |
| 7 | #define __TEST_TEST_H |
| 8 | |
| 9 | #include <malloc.h> |
| 10 | |
| 11 | /* |
| 12 | * struct unit_test_state - Entire state of test system |
| 13 | * |
| 14 | * @fail_count: Number of tests that failed |
| 15 | * @start: Store the starting mallinfo when doing leak test |
| 16 | * @priv: A pointer to some other info some suites want to track |
Simon Glass | 017886b | 2017-05-18 20:09:17 -0600 | [diff] [blame] | 17 | * @of_root: Record of the livetree root node (used for setting up tests) |
Joe Hershberger | 3a77be5 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 18 | */ |
| 19 | struct unit_test_state { |
| 20 | int fail_count; |
| 21 | struct mallinfo start; |
| 22 | void *priv; |
Simon Glass | 017886b | 2017-05-18 20:09:17 -0600 | [diff] [blame] | 23 | struct device_node *of_root; |
Joe Hershberger | 3a77be5 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 24 | }; |
| 25 | |
| 26 | /** |
| 27 | * struct unit_test - Information about a unit test |
| 28 | * |
| 29 | * @name: Name of test |
| 30 | * @func: Function to call to perform test |
| 31 | * @flags: Flags indicated pre-conditions for test |
| 32 | */ |
| 33 | struct unit_test { |
Simon Glass | be408ee | 2017-05-18 20:09:15 -0600 | [diff] [blame] | 34 | const char *file; |
Joe Hershberger | 3a77be5 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 35 | const char *name; |
| 36 | int (*func)(struct unit_test_state *state); |
| 37 | int flags; |
| 38 | }; |
| 39 | |
| 40 | /* Declare a new unit test */ |
| 41 | #define UNIT_TEST(_name, _flags, _suite) \ |
| 42 | ll_entry_declare(struct unit_test, _name, _suite) = { \ |
Simon Glass | be408ee | 2017-05-18 20:09:15 -0600 | [diff] [blame] | 43 | .file = __FILE__, \ |
Joe Hershberger | 3a77be5 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 44 | .name = #_name, \ |
| 45 | .flags = _flags, \ |
| 46 | .func = _name, \ |
| 47 | } |
| 48 | |
Simon Glass | 204675c | 2019-12-29 21:19:25 -0700 | [diff] [blame] | 49 | /* Sizes for devres tests */ |
| 50 | enum { |
| 51 | TEST_DEVRES_SIZE = 100, |
| 52 | TEST_DEVRES_COUNT = 10, |
| 53 | TEST_DEVRES_TOTAL = TEST_DEVRES_SIZE * TEST_DEVRES_COUNT, |
| 54 | |
Simon Glass | 0fe1537 | 2019-12-29 21:19:28 -0700 | [diff] [blame] | 55 | /* A few different sizes */ |
Simon Glass | 204675c | 2019-12-29 21:19:25 -0700 | [diff] [blame] | 56 | TEST_DEVRES_SIZE2 = 15, |
Simon Glass | 0fe1537 | 2019-12-29 21:19:28 -0700 | [diff] [blame] | 57 | TEST_DEVRES_SIZE3 = 37, |
Simon Glass | 204675c | 2019-12-29 21:19:25 -0700 | [diff] [blame] | 58 | }; |
Joe Hershberger | 3a77be5 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 59 | |
| 60 | #endif /* __TEST_TEST_H */ |