blob: e3e821c6ea8a9a2183ba9f100aae643af9d8ed65 [file] [log] [blame]
Joe Hershbergere721b882015-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
18 */
19struct 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 */
32struct unit_test {
Simon Glass801587b2017-05-18 20:09:15 -060033 const char *file;
Joe Hershbergere721b882015-05-20 14:27:27 -050034 const char *name;
35 int (*func)(struct unit_test_state *state);
36 int flags;
37};
38
39/* Declare a new unit test */
40#define UNIT_TEST(_name, _flags, _suite) \
41 ll_entry_declare(struct unit_test, _name, _suite) = { \
Simon Glass801587b2017-05-18 20:09:15 -060042 .file = __FILE__, \
Joe Hershbergere721b882015-05-20 14:27:27 -050043 .name = #_name, \
44 .flags = _flags, \
45 .func = _name, \
46 }
47
48
49#endif /* __TEST_TEST_H */