tests/storage/stream_flash: Add erase range check test
The commit adds test for stream_flash_erase_page range check. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
parent
8714c172ed
commit
23805301b0
|
@ -465,6 +465,25 @@ ZTEST(lib_stream_flash, test_stream_flash_erase_page)
|
|||
zassert_equal(memcmp(&bad_ctx, &cmp_ctx, sizeof(bad_ctx)), 0,
|
||||
"Ctx should not get altered");
|
||||
zassert_equal(rc, -EINVAL, "Expected failure");
|
||||
|
||||
/* False dev with erase set to NULL to avoid actual erase */
|
||||
fake_api.erase = NULL;
|
||||
struct stream_flash_ctx range_test_ctx = {
|
||||
.offset = 1024,
|
||||
.available = 2048,
|
||||
.fdev = &fake_dev,
|
||||
.last_erased_page_start_offset = -1,
|
||||
};
|
||||
|
||||
rc = stream_flash_erase_page(&range_test_ctx, 1024);
|
||||
zassert_equal(rc, -ENOSYS, "%d No device attached - expected failure", rc);
|
||||
|
||||
rc = stream_flash_erase_page(&range_test_ctx, 1023);
|
||||
zassert_equal(rc, -ERANGE, "Expected failure - offset before designated area");
|
||||
|
||||
rc = stream_flash_erase_page(&range_test_ctx,
|
||||
range_test_ctx.offset + range_test_ctx.available + 1);
|
||||
zassert_equal(rc, -ERANGE, "Expected failure - offset after designated area");
|
||||
}
|
||||
#else
|
||||
ZTEST(lib_stream_flash, test_stream_flash_erase_page)
|
||||
|
|
Loading…
Reference in New Issue