blob: 646dbfd486459bd5558407ed74e21305bbe842a9 [file] [log] [blame]
Joe Hershberger3a77be52015-05-20 14:27:27 -05001/*
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
Simon Glass017886b2017-05-18 20:09:17 -060018 * @of_root: Record of the livetree root node (used for setting up tests)
Joe Hershberger3a77be52015-05-20 14:27:27 -050019 */
20struct unit_test_state {
21 int fail_count;
22 struct mallinfo start;
23 void *priv;
Simon Glass017886b2017-05-18 20:09:17 -060024 struct device_node *of_root;
Joe Hershberger3a77be52015-05-20 14:27:27 -050025};
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 */
34struct unit_test {
Simon Glassbe408ee2017-05-18 20:09:15 -060035 const char *file;
Joe Hershberger3a77be52015-05-20 14:27:27 -050036 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) = { \
Simon Glassbe408ee2017-05-18 20:09:15 -060044 .file = __FILE__, \
Joe Hershberger3a77be52015-05-20 14:27:27 -050045 .name = #_name, \
46 .flags = _flags, \
47 .func = _name, \
48 }
49
50
51#endif /* __TEST_TEST_H */