test_runner.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. extern const struct test_suite *test_suites[];
  34. extern const size_t test_suite_count;
  35. // access generated test defines
  36. test_define_t test_predefine(size_t define);
  37. test_define_t test_define(size_t define);
  38. // a few preconfigured defines that control how tests run
  39. #define READ_SIZE test_predefine(0)
  40. #define PROG_SIZE test_predefine(1)
  41. #define BLOCK_SIZE test_predefine(2)
  42. #define BLOCK_COUNT test_predefine(3)
  43. #define CACHE_SIZE test_predefine(4)
  44. #define LOOKAHEAD_SIZE test_predefine(5)
  45. #define BLOCK_CYCLES test_predefine(6)
  46. #define ERASE_VALUE test_predefine(7)
  47. #define ERASE_CYCLES test_predefine(8)
  48. #define BADBLOCK_BEHAVIOR test_predefine(9)
  49. #define TEST_PREDEFINE_NAMES { \
  50. "READ_SIZE", \
  51. "PROG_SIZE", \
  52. "BLOCK_SIZE", \
  53. "BLOCK_COUNT", \
  54. "CACHE_SIZE", \
  55. "LOOKAHEAD_SIZE", \
  56. "BLOCK_CYCLES", \
  57. "ERASE_VALUE", \
  58. "ERASE_CYCLES", \
  59. "BADBLOCK_BEHAVIOR", \
  60. }
  61. #define TEST_PREDEFINE_COUNT 10
  62. // default predefines
  63. #define TEST_DEFAULTS { \
  64. /* LOOKAHEAD_SIZE */ 16, \
  65. /* BLOCK_CYCLES */ -1, \
  66. /* ERASE_VALUE */ 0xff, \
  67. /* ERASE_CYCLES */ 0, \
  68. /* BADBLOCK_BEHAVIOR */ LFS_TESTBD_BADBLOCK_PROGERROR, \
  69. }
  70. #define TEST_DEFAULT_COUNT 5
  71. #define TEST_DEFAULT_MAP { \
  72. 0xff, 0xff, 0xff, 0xff, 0xff, 0, 1, 2, 3, 4 \
  73. }
  74. // test geometries
  75. #define TEST_GEOMETRIES { \
  76. /*geometry, read, write, erase, count, cache */ \
  77. {"test", { 16, 16, 512, (1024*1024)/512, 64}}, \
  78. {"eeprom", { 1, 1, 512, (1024*1024)/512, 64}}, \
  79. {"emmc", { 512, 512, 512, (1024*1024)/512, 512}}, \
  80. {"nor", { 1, 1, 4096, (1024*1024)/4096, 64}}, \
  81. {"nand", {4096, 4096, 32*1024, (1024*1024)/(32*1024), 4096}}, \
  82. }
  83. #define TEST_GEOMETRY_COUNT 5
  84. #define TEST_GEOMETRY_DEFINE_COUNT 5
  85. #define TEST_GEOMETRY_DEFINE_MAP { \
  86. 0, 1, 2, 3, 4, 0xff, 0xff, 0xff, 0xff, 0xff \
  87. }
  88. #endif