test.h 986 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2013 Google, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __TEST_TEST_H
  7. #define __TEST_TEST_H
  8. #include <malloc.h>
  9. /*
  10. * struct unit_test_state - Entire state of test system
  11. *
  12. * @fail_count: Number of tests that failed
  13. * @start: Store the starting mallinfo when doing leak test
  14. * @priv: A pointer to some other info some suites want to track
  15. */
  16. struct unit_test_state {
  17. int fail_count;
  18. struct mallinfo start;
  19. void *priv;
  20. };
  21. /**
  22. * struct unit_test - Information about a unit test
  23. *
  24. * @name: Name of test
  25. * @func: Function to call to perform test
  26. * @flags: Flags indicated pre-conditions for test
  27. */
  28. struct unit_test {
  29. const char *name;
  30. int (*func)(struct unit_test_state *state);
  31. int flags;
  32. };
  33. /* Declare a new unit test */
  34. #define UNIT_TEST(_name, _flags, _suite) \
  35. ll_entry_declare(struct unit_test, _name, _suite) = { \
  36. .name = #_name, \
  37. .flags = _flags, \
  38. .func = _name, \
  39. }
  40. #endif /* __TEST_TEST_H */