tests/dfu: Replace flash_area_erase with flash_area_flatten

Use flash_area_flatten instead of flash_area_erase; this allows
to run tests on devices that do not require explicit erase
before write or do not provide the callback.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
Dominik Ermel 2024-03-09 22:46:00 +00:00 committed by Henrik Brix Andersen
commit 7b36d34504

View file

@ -73,7 +73,7 @@ ZTEST(img_util, test_collecting)
sizeof(erase_buf));
zassert_true(ret == 0, "Flash write failure (%d)", ret);
#else
ret = flash_area_erase(ctx.flash_area, 0, ctx.flash_area->fa_size);
ret = flash_area_flatten(ctx.flash_area, 0, ctx.flash_area->fa_size);
zassert_true(ret == 0, "Flash erase failure (%d)", ret);
#endif
@ -137,7 +137,7 @@ ZTEST(img_util, test_check_flash)
ret = flash_img_init_id(&ctx, SLOT1_PARTITION_ID);
zassert_true(ret == 0, "Flash img init 1");
ret = flash_area_erase(ctx.flash_area, 0, ctx.flash_area->fa_size);
ret = flash_area_flatten(ctx.flash_area, 0, ctx.flash_area->fa_size);
zassert_true(ret == 0, "Flash erase failure (%d)\n", ret);
ret = flash_img_buffered_write(&ctx, tst_vec, sizeof(tst_vec), true);
zassert_true(ret == 0, "Flash img buffered write\n");