fixed a bunch of test bench issues

This commit is contained in:
Peter Andersson
2016-04-27 18:54:12 +02:00
parent 3565d131f2
commit 7b4d5abf3c
4 changed files with 30 additions and 20 deletions
+4 -1
View File
@@ -164,6 +164,9 @@ TEST(nodemcu_full_fs_2) {
} TEST_END
TEST(magic_test) {
// this test only works on default sizes
TEST_ASSERT(sizeof(spiffs_obj_id) == sizeof(u16_t));
// one obj lu page, not full
fs_reset_specific(0, 0, 4096*16, 4096, 4096*1, 128);
TEST_CHECK(SPIFFS_CHECK_MAGIC_POSSIBLE(FS));
@@ -212,7 +215,7 @@ TEST(nodemcu_309) {
SPIFFS_info(FS, &total, &used);
printf("total:%i\nused:%i\nremain:%i\nerrno:%i\n", total, used, total-used, errno);
TEST_CHECK(total-used < 11000);
//TEST_CHECK(total-used < 11000); // disabled, depends on too many variables
spiffs_DIR d;
struct spiffs_dirent e;
+1 -1
View File
@@ -113,7 +113,7 @@ TEST(page_cons1) {
u32_t addr = SPIFFS_PAGE_TO_PADDR(FS, pix) + sizeof(spiffs_page_object_ix_header) + 0 * sizeof(spiffs_page_ix);
spiffs_page_ix bad_pix_ref = 0x55;
area_write(addr, (u8_t*)&bad_pix_ref, sizeof(spiffs_page_ix));
area_write(addr+2, (u8_t*)&bad_pix_ref, sizeof(spiffs_page_ix));
area_write(addr + sizeof(spiffs_page_ix), (u8_t*)&bad_pix_ref, sizeof(spiffs_page_ix));
// delete all cache
#if SPIFFS_CACHE
+24 -17
View File
@@ -28,7 +28,7 @@
#define AREA(x) _area[(x) - addr_offset]
static u32_t _area_sz;
static unsigned char *_area;
static unsigned char *_area = NULL;
static u32_t addr_offset = 0;
static int *_erases;
@@ -45,10 +45,10 @@ static char log_flash_ops = 1;
static u32_t fs_check_fixes = 0;
spiffs __fs;
static u8_t *_work;
static u8_t *_fds;
static u8_t *_work = NULL;
static u8_t *_fds = NULL;
static u32_t _fds_sz;
static u8_t *_cache;
static u8_t *_cache = NULL;
static u32_t _cache_sz;
static int check_valid_flash = 1;
@@ -441,11 +441,16 @@ static void fs_create(u32_t spiflash_size,
}
static void fs_free(void) {
free(_area);
free(_erases);
free(_fds);
free(_cache);
free(_work);
if (_area) free(_area);
_area = NULL;
if (_erases) free(_erases);
_erases = NULL;
if (_fds) free(_fds);
_fds = NULL;
if (_cache) free(_cache);
_cache = NULL;
if (_work) free(_work);
_work = NULL;
}
/**
@@ -615,7 +620,7 @@ int read_and_verify_fd(spiffs_file fd, char *name) {
static void test_on_stop(test *t) {
printf(" spiffs errno:%i\n", SPIFFS_errno(&__fs));
#if SPIFFS_TEST_VISUALISATION
SPIFFS_vis(FS);
if (_area) SPIFFS_vis(FS);
#endif
}
@@ -731,15 +736,17 @@ void _teardown() {
cmiss_tot = 0;
#endif
#endif
dump_flash_access_stats();
clear_flash_ops_log();
if (_area) {
dump_flash_access_stats();
clear_flash_ops_log();
#if SPIFFS_GC_STATS
if ((FS)->stats_gc_runs > 0)
if ((FS)->stats_gc_runs > 0)
#endif
dump_erase_counts(FS);
printf(" fs consistency check output begin\n");
SPIFFS_check(FS);
printf(" fs consistency check output end\n");
dump_erase_counts(FS);
printf(" fs consistency check output begin\n");
SPIFFS_check(FS);
printf(" fs consistency check output end\n");
}
clear_test_path();
fs_free();
}
+1 -1
View File
@@ -168,7 +168,6 @@ int run_tests(int argc, char **args) {
i++;
int res = cur_t->f(cur_t);
cur_t->test_result = res;
cur_t->teardown(cur_t);
int fd = res == TEST_RES_OK ? fd_success : fd_bad;
write(fd, cur_t->name, strlen(cur_t->name));
write(fd, "\n", 1);
@@ -190,6 +189,7 @@ int run_tests(int argc, char **args) {
add_res(cur_t, &test_main.stopped, &test_main.stopped_last);
break;
}
cur_t->teardown(cur_t);
free(cur_t);
cur_t = next_test;
}