test_spiffs.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * test_spiffs.h
  3. *
  4. * Created on: Jun 19, 2013
  5. * Author: petera
  6. */
  7. #ifndef TEST_SPIFFS_H_
  8. #define TEST_SPIFFS_H_
  9. #include "spiffs.h"
  10. #define FS &__fs
  11. extern spiffs __fs;
  12. #define CHECK(r) if (!(r)) return -1;
  13. #define CHECK_RES(r) if (r < 0) return -1;
  14. #define FS_PURE_DATA_PAGES(fs) \
  15. ((fs)->cfg.phys_size / (fs)->cfg.log_page_size - (fs)->block_count * SPIFFS_OBJ_LOOKUP_PAGES(fs))
  16. #define FS_PURE_DATA_SIZE(fs) \
  17. FS_PURE_DATA_PAGES(fs) * SPIFFS_DATA_PAGE_SIZE(fs)
  18. typedef enum {
  19. EMPTY,
  20. SMALL,
  21. MEDIUM,
  22. LARGE,
  23. } tfile_size;
  24. typedef enum {
  25. UNTAMPERED,
  26. APPENDED,
  27. MODIFIED,
  28. REWRITTEN,
  29. } tfile_type;
  30. typedef enum {
  31. SHORT = 4,
  32. NORMAL = 20,
  33. LONG = 100,
  34. } tfile_life;
  35. typedef struct {
  36. tfile_size tsize;
  37. tfile_type ttype;
  38. tfile_life tlife;
  39. } tfile_conf;
  40. typedef struct {
  41. int state;
  42. spiffs_file fd;
  43. tfile_conf cfg;
  44. char name[32];
  45. } tfile;
  46. void fs_reset();
  47. void fs_reset_specific(u32_t phys_addr, u32_t phys_size,
  48. u32_t phys_sector_size,
  49. u32_t log_block_size, u32_t log_page_size);
  50. int read_and_verify(char *name);
  51. int read_and_verify_fd(spiffs_file fd, char *name);
  52. void dump_page(spiffs *fs, spiffs_page_ix p);
  53. void hexdump(u32_t addr, u32_t len);
  54. char *make_test_fname(const char *name);
  55. void clear_test_path();
  56. void area_write(u32_t addr, u8_t *buf, u32_t size);
  57. void area_read(u32_t addr, u8_t *buf, u32_t size);
  58. void dump_erase_counts(spiffs *fs);
  59. void dump_flash_access_stats();
  60. void set_flash_ops_log(int enable);
  61. void clear_flash_ops_log();
  62. u32_t get_flash_ops_log_read_bytes();
  63. u32_t get_flash_ops_log_write_bytes();
  64. void invoke_error_after_read_bytes(u32_t b, char once_only);
  65. void invoke_error_after_write_bytes(u32_t b, char once_only);
  66. void memrand(u8_t *b, int len);
  67. int test_create_file(char *name);
  68. int test_create_and_write_file(char *name, int size, int chunk_size);
  69. void _setup();
  70. void _setup_test_only();
  71. void _teardown();
  72. u32_t tfile_get_size(tfile_size s);
  73. int run_file_config(int cfg_count, tfile_conf* cfgs, int max_runs, int max_concurrent_files, int dbg);
  74. #endif /* TEST_SPIFFS_H_ */