test_runner.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. intmax_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 *cases;
  28. size_t case_count;
  29. };
  30. // access generated test defines
  31. intmax_t test_predefine(size_t define);
  32. intmax_t test_define(size_t define);
  33. // a few preconfigured defines that control how tests run
  34. #define READ_SIZE test_predefine(0)
  35. #define PROG_SIZE test_predefine(1)
  36. #define BLOCK_SIZE test_predefine(2)
  37. #define BLOCK_COUNT test_predefine(3)
  38. #define CACHE_SIZE test_predefine(4)
  39. #define LOOKAHEAD_SIZE test_predefine(5)
  40. #define BLOCK_CYCLES test_predefine(6)
  41. #define ERASE_VALUE test_predefine(7)
  42. #define ERASE_CYCLES test_predefine(8)
  43. #define BADBLOCK_BEHAVIOR test_predefine(9)
  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. }
  56. #define TEST_PREDEFINE_COUNT 10
  57. // default predefines
  58. #define TEST_DEFAULTS { \
  59. /* LOOKAHEAD_SIZE */ 16, \
  60. /* BLOCK_CYCLES */ -1, \
  61. /* ERASE_VALUE */ 0xff, \
  62. /* ERASE_CYCLES */ 0, \
  63. /* BADBLOCK_BEHAVIOR */ LFS_TESTBD_BADBLOCK_PROGERROR, \
  64. }
  65. #define TEST_DEFAULT_DEFINE_COUNT 5
  66. // test geometries
  67. #define TEST_GEOMETRIES { \
  68. /*geometry, read, write, erase, count, cache */ \
  69. {"test", { 16, 16, 512, (1024*1024)/512, 64}}, \
  70. {"eeprom", { 1, 1, 512, (1024*1024)/512, 64}}, \
  71. {"emmc", { 512, 512, 512, (1024*1024)/512, 512}}, \
  72. {"nor", { 1, 1, 4096, (1024*1024)/4096, 64}}, \
  73. {"nand", {4096, 4096, 32*1024, (1024*1024)/(32*1024), 4096}}, \
  74. }
  75. #define TEST_GEOMETRY_COUNT 5
  76. #define TEST_GEOMETRY_DEFINE_COUNT 5
  77. #endif