1 /* 2 * Copyright (c) 2013 Google, Inc. 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 5 */ 6 7 #ifndef __TEST_TEST_H 8 #define __TEST_TEST_H 9 10 #include <malloc.h> 11 12 /* 13 * struct unit_test_state - Entire state of test system 14 * 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 */ 20 struct unit_test_state { 21 int fail_count; 22 struct mallinfo start; 23 void *priv; 24 struct device_node *of_root; 25 }; 26 27 /** 28 * struct unit_test - Information about a unit test 29 * 30 * @name: Name of test 31 * @func: Function to call to perform test 32 * @flags: Flags indicated pre-conditions for test 33 */ 34 struct unit_test { 35 const char *file; 36 const char *name; 37 int (*func)(struct unit_test_state *state); 38 int flags; 39 }; 40 41 /* Declare a new unit test */ 42 #define UNIT_TEST(_name, _flags, _suite) \ 43 ll_entry_declare(struct unit_test, _name, _suite) = { \ 44 .file = __FILE__, \ 45 .name = #_name, \ 46 .flags = _flags, \ 47 .func = _name, \ 48 } 49 50 51 #endif /* __TEST_TEST_H */ 52