blob: b7e1ae2decf997f83f6898b70d3d97b588e28ae2 [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 {
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 */