test_runner.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef TEST_RUNNER_H
  2. #define TEST_RUNNER_H
  3. #include "lfs.h"
  4. // generated test configurations
  5. enum test_types {
  6. TEST_NORMAL = 0x1,
  7. TEST_REENTRANT = 0x2,
  8. TEST_VALGRIND = 0x4,
  9. };
  10. typedef uint8_t test_types_t;
  11. typedef uintmax_t test_define_t;
  12. struct test_case {
  13. const char *id;
  14. const char *name;
  15. const char *path;
  16. test_types_t types;
  17. size_t permutations;
  18. const test_define_t *const *defines;
  19. const uint8_t *define_map;
  20. bool (*filter)(uint32_t perm);
  21. void (*run)(struct lfs_config *cfg, uint32_t perm);
  22. };
  23. struct test_suite {
  24. const char *id;
  25. const char *name;
  26. const char *path;
  27. test_types_t types;
  28. const char *const *define_names;
  29. size_t define_count;
  30. const struct test_case *const *cases;
  31. size_t case_count;
  32. };
  33. // TODO remove this indirection
  34. extern const struct test_suite *test_suites[];
  35. extern const size_t test_suite_count;
  36. // access generated test defines
  37. test_define_t test_define(size_t define);
  38. // a few preconfigured defines that control how tests run
  39. #define READ_SIZE test_define(0)
  40. #define PROG_SIZE test_define(1)
  41. #define BLOCK_SIZE test_define(2)
  42. #define BLOCK_COUNT test_define(3)
  43. #define BLOCK_CYCLES test_define(4)
  44. #define CACHE_SIZE test_define(5)
  45. #define LOOKAHEAD_SIZE test_define(6)
  46. #define ERASE_VALUE test_define(7)
  47. #define ERASE_CYCLES test_define(8)
  48. #define BADBLOCK_BEHAVIOR test_define(9)
  49. #define TEST_PREDEFINE_COUNT 10
  50. #endif