Skip to content
Browse files

tests/subsys/settings/functional: ensure settings area is cleared

The test assumes that the settings area is empty.  This happens
naturally when the area is in the SOC flash and the chip flash is
entirely erased when the test is programmed.  The test will fail if the
programmed board is reset and the test run again.

The test cannot pass by reprogramming when the storage area is in an
external flash device.

Make things repeatable for FCB by erasing the storage partition before
running the test.

Signed-off-by: Peter A. Bigot <>
  • Loading branch information...
pabigot authored and galak committed Jul 20, 2019
1 parent e3ba01e commit 33b10aa76a91715ab3e857b9ecfbbcb69f32ecca
Showing with 24 additions and 2 deletions.
  1. +24 −2 tests/subsys/settings/functional/src/settings_basic_test.c
@@ -16,6 +16,27 @@
#include <logging/log.h> #include <logging/log.h>
LOG_MODULE_REGISTER(settings_basic_test); LOG_MODULE_REGISTER(settings_basic_test);

#include <storage/flash_map.h>

/* The standard test expects a cleared flash area. Make sure it has
* one.
static void test_clear_settings(void)
const struct flash_area *fap;
int rc = flash_area_open(DT_FLASH_AREA_STORAGE_ID, &fap);

if (rc == 0) {
rc = flash_area_erase(fap, 0, fap->fa_size);
zassert_true(rc == 0, "clear settings failed");

/* /*
* Test the two support routines that settings provides: * Test the two support routines that settings provides:
* *
@@ -304,8 +325,9 @@ static void test_register_and_loading(void)
void test_main(void) void test_main(void)
{ {
ztest_test_suite(settings_test_suite, ztest_test_suite(settings_test_suite,
ztest_unit_test(test_support_rtn), ztest_unit_test(test_clear_settings),
ztest_unit_test(test_register_and_loading) ztest_unit_test(test_support_rtn),
); );

ztest_run_test_suite(settings_test_suite); ztest_run_test_suite(settings_test_suite);

0 comments on commit 33b10aa

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