Browse Source

added reading beyond file length testcase

pull/24/head
Peter Andersson 10 years ago
parent
commit
be290fd329
  1. 42
      src/test/test_hydrogen.c

42
src/test/test_hydrogen.c

@ -738,6 +738,48 @@ TEST(read_chunk_huge)
TEST_END(read_chunk_huge)
TEST(read_beyond)
{
char *name = "file";
spiffs_file fd;
s32_t res;
u32_t size = SPIFFS_DATA_PAGE_SIZE(FS)*2;
u8_t *buf = malloc(size);
memrand(buf, size);
res = test_create_file(name);
CHECK(res >= 0);
fd = SPIFFS_open(FS, name, SPIFFS_APPEND | SPIFFS_RDWR, 0);
CHECK(fd >= 0);
res = SPIFFS_write(FS, fd, buf, size);
CHECK(res >= 0);
spiffs_stat stat;
res = SPIFFS_fstat(FS, fd, &stat);
CHECK(res >= 0);
CHECK(stat.size == size);
SPIFFS_close(FS, fd);
fd = SPIFFS_open(FS, name, SPIFFS_RDONLY, 0);
CHECK(fd >= 0);
u8_t *rbuf = malloc(size+10);
res = SPIFFS_read(FS, fd, rbuf, size+10);
SPIFFS_close(FS, fd);
free(rbuf);
free(buf);
TEST_CHECK(res == size);
return TEST_RES_OK;
}
TEST_END(read_beyond)
TEST(bad_index_1) {
int size = SPIFFS_DATA_PAGE_SIZE(FS)*3;
int res = test_create_and_write_file("file", size, size);

Loading…
Cancel
Save