test_runner.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef TEST_RUNNER_H
  2. #define TEST_RUNNER_H
  3. #include "lfs.h"
  4. // generated test configurations
  5. enum test_flags {
  6. TEST_REENTRANT = 0x1,
  7. };
  8. typedef uint8_t test_flags_t;
  9. struct test_case {
  10. const char *id;
  11. const char *name;
  12. const char *path;
  13. test_flags_t flags;
  14. size_t permutations;
  15. intmax_t (*const *const *defines)(void);
  16. bool (*filter)(void);
  17. void (*run)(struct lfs_config *cfg);
  18. };
  19. struct test_suite {
  20. const char *id;
  21. const char *name;
  22. const char *path;
  23. test_flags_t flags;
  24. const char *const *define_names;
  25. size_t define_count;
  26. const struct test_case *cases;
  27. size_t case_count;
  28. };
  29. // access generated test defines
  30. intmax_t test_predefine(size_t define);
  31. intmax_t test_define(size_t define);
  32. // a few preconfigured defines that control how tests run
  33. #define READ_SIZE test_predefine(0)
  34. #define PROG_SIZE test_predefine(1)
  35. #define BLOCK_SIZE test_predefine(2)
  36. #define BLOCK_COUNT test_predefine(3)
  37. #define CACHE_SIZE test_predefine(4)
  38. #define LOOKAHEAD_SIZE test_predefine(5)
  39. #define BLOCK_CYCLES test_predefine(6)
  40. #define ERASE_VALUE test_predefine(7)
  41. #define ERASE_CYCLES test_predefine(8)
  42. #define BADBLOCK_BEHAVIOR test_predefine(9)
  43. #define POWERLOSS_BEHAVIOR test_predefine(10)
  44. #define TEST_PREDEFINE_NAMES { \
  45. "READ_SIZE", \
  46. "PROG_SIZE", \
  47. "BLOCK_SIZE", \
  48. "BLOCK_COUNT", \
  49. "CACHE_SIZE", \
  50. "LOOKAHEAD_SIZE", \
  51. "BLOCK_CYCLES", \
  52. "ERASE_VALUE", \
  53. "ERASE_CYCLES", \
  54. "BADBLOCK_BEHAVIOR", \
  55. "POWERLOSS_BEHAVIOR", \
  56. }
  57. #define TEST_PREDEFINE_COUNT 11
  58. // default predefines
  59. #define TEST_DEFAULTS { \
  60. /* LOOKAHEAD_SIZE */ 16, \
  61. /* BLOCK_CYCLES */ -1, \
  62. /* ERASE_VALUE */ 0xff, \
  63. /* ERASE_CYCLES */ 0, \
  64. /* BADBLOCK_BEHAVIOR */ LFS_TESTBD_BADBLOCK_PROGERROR, \
  65. /* POWERLOSS_BEHAVIOR */ LFS_TESTBD_POWERLOSS_NOOP, \
  66. }
  67. #define TEST_DEFAULT_DEFINE_COUNT 5
  68. // test geometries
  69. #define TEST_GEOMETRIES { \
  70. /*geometry, read, write, erase, count, cache */ \
  71. {"test", { 16, 16, 512, (1024*1024)/512, 64}}, \
  72. {"eeprom", { 1, 1, 512, (1024*1024)/512, 64}}, \
  73. {"emmc", { 512, 512, 512, (1024*1024)/512, 512}}, \
  74. {"nor", { 1, 1, 4096, (1024*1024)/4096, 64}}, \
  75. {"nand", {4096, 4096, 32*1024, (1024*1024)/(32*1024), 4096}}, \
  76. }
  77. #define TEST_GEOMETRY_COUNT 5
  78. #define TEST_GEOMETRY_DEFINE_COUNT 5
  79. #endif