xref: /openbmc/u-boot/include/test/test.h (revision fea7f3aa)
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  */
19 struct unit_test_state {
20 	int fail_count;
21 	struct mallinfo start;
22 	void *priv;
23 };
24 
25 /**
26  * struct unit_test - Information about a unit test
27  *
28  * @name: Name of test
29  * @func: Function to call to perform test
30  * @flags: Flags indicated pre-conditions for test
31  */
32 struct unit_test {
33 	const char *name;
34 	int (*func)(struct unit_test_state *state);
35 	int flags;
36 };
37 
38 /* Declare a new unit test */
39 #define UNIT_TEST(_name, _flags, _suite)				\
40 	ll_entry_declare(struct unit_test, _name, _suite) = {		\
41 		.name = #_name,						\
42 		.flags = _flags,					\
43 		.func = _name,						\
44 	}
45 
46 
47 #endif /* __TEST_TEST_H */
48