test_runner.h 2.5 KB

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