test_runner.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. };
  9. typedef uint8_t test_types_t;
  10. struct test_case {
  11. const char *id;
  12. const char *name;
  13. const char *path;
  14. test_types_t types;
  15. size_t permutations;
  16. uintmax_t (*const *const *defines)(void);
  17. bool (*filter)(void);
  18. void (*run)(struct lfs_config *cfg);
  19. };
  20. struct test_suite {
  21. const char *id;
  22. const char *name;
  23. const char *path;
  24. test_types_t types;
  25. const char *const *define_names;
  26. size_t define_count;
  27. const struct test_case *const *cases;
  28. size_t case_count;
  29. };
  30. extern const struct test_suite *test_suites[];
  31. extern const size_t test_suite_count;
  32. // access generated test defines
  33. uintmax_t test_predefine(size_t define);
  34. uintmax_t test_define(size_t define);
  35. // a few preconfigured defines that control how tests run
  36. #define READ_SIZE test_predefine(0)
  37. #define PROG_SIZE test_predefine(1)
  38. #define BLOCK_SIZE test_predefine(2)
  39. #define BLOCK_COUNT test_predefine(3)
  40. #define CACHE_SIZE test_predefine(4)
  41. #define LOOKAHEAD_SIZE test_predefine(5)
  42. #define BLOCK_CYCLES test_predefine(6)
  43. #define ERASE_VALUE test_predefine(7)
  44. #define ERASE_CYCLES test_predefine(8)
  45. #define BADBLOCK_BEHAVIOR test_predefine(9)
  46. #define TEST_PREDEFINE_NAMES { \
  47. "READ_SIZE", \
  48. "PROG_SIZE", \
  49. "BLOCK_SIZE", \
  50. "BLOCK_COUNT", \
  51. "CACHE_SIZE", \
  52. "LOOKAHEAD_SIZE", \
  53. "BLOCK_CYCLES", \
  54. "ERASE_VALUE", \
  55. "ERASE_CYCLES", \
  56. "BADBLOCK_BEHAVIOR", \
  57. }
  58. #define TEST_PREDEFINE_COUNT 10
  59. // default predefines
  60. #define TEST_DEFAULTS { \
  61. /* LOOKAHEAD_SIZE */ 16, \
  62. /* BLOCK_CYCLES */ -1, \
  63. /* ERASE_VALUE */ 0xff, \
  64. /* ERASE_CYCLES */ 0, \
  65. /* BADBLOCK_BEHAVIOR */ LFS_TESTBD_BADBLOCK_PROGERROR, \
  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