Skip to content
Permalink
Browse files

tests: fs: nvs: test cases clean up flash on completion

Modified tests for the NVS to clean up the flash memory at the end of
their execution.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
  • Loading branch information...
kapi-no authored and carlescufi committed May 20, 2019
1 parent cfa32af commit 35a9299a7618a92da0e36b32404665565d67cf94
Showing with 11 additions and 1 deletion.
  1. +11 −1 tests/subsys/fs/nvs/src/main.c
@@ -66,6 +66,9 @@ void test_nvs_write(void)
char pattern[] = {0xDE, 0xAD, 0xBE, 0xEF};
size_t len;

err = nvs_init(&fs, DT_FLASH_DEV_NAME);
zassert_true(err == 0, "nvs_init call failure: %d", err);

err = nvs_read(&fs, TEST_DATA_ID, rd_buf, sizeof(rd_buf));
zassert_true(err == -ENOENT, "nvs_read unexpected failure: %d", err);

@@ -83,7 +86,8 @@ void test_nvs_write(void)
zassert_mem_equal(wr_buf, rd_buf, sizeof(rd_buf),
"RD buff should be equal to the WR buff");

nvs_delete(&fs, TEST_DATA_ID);
err = nvs_clear(&fs);
zassert_true(err == 0, "nvs_clear call failure: %d", err);
}

static int flash_sim_write_calls_find(struct stats_hdr *hdr, void *arg,
@@ -120,6 +124,9 @@ void test_nvs_corrupted_write(void)
u32_t *flash_write_stat;
u32_t *flash_max_write_calls;

err = nvs_init(&fs, DT_FLASH_DEV_NAME);
zassert_true(err == 0, "nvs_init call failure: %d", err);

err = nvs_read(&fs, TEST_DATA_ID, rd_buf, sizeof(rd_buf));
zassert_true(err == -ENOENT, "nvs_read unexpected failure: %d", err);

@@ -172,6 +179,9 @@ void test_nvs_corrupted_write(void)
zassert_mem_equal(wr_buf_1, rd_buf, sizeof(rd_buf),
"RD buff should be equal to the first WR buff because subsequent "
"write operation has failed");

err = nvs_clear(&fs);
zassert_true(err == 0, "nvs_clear call failure: %d", err);
}

void test_main(void)

0 comments on commit 35a9299

Please sign in to comment.
You can’t perform that action at this time.