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 *file; 34 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) = { \ 42 .file = __FILE__, \ 43 .name = #_name, \ 44 .flags = _flags, \ 45 .func = _name, \ 46 } 47 48 49 #endif /* __TEST_TEST_H */ 50