tests/settings: Small cleanup of settings_basic_test.c
Fixed indentation and some ifdefs. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
parent
3dbc13c4ae
commit
f2a338c77b
|
@ -18,6 +18,12 @@ LOG_MODULE_REGISTER(settings_basic_test);
|
||||||
|
|
||||||
#if defined(CONFIG_SETTINGS_FCB) || defined(CONFIG_SETTINGS_NVS)
|
#if defined(CONFIG_SETTINGS_FCB) || defined(CONFIG_SETTINGS_NVS)
|
||||||
#include <zephyr/storage/flash_map.h>
|
#include <zephyr/storage/flash_map.h>
|
||||||
|
#if DT_HAS_CHOSEN(zephyr_settings_partition)
|
||||||
|
#define TEST_FLASH_AREA chosen_partition
|
||||||
|
#else
|
||||||
|
#define TEST_FLASH_AREA storage
|
||||||
|
#endif
|
||||||
|
#define TEST_FLASH_AREA_ID FLASH_AREA_ID(TEST_FLASH_AREA)
|
||||||
#endif
|
#endif
|
||||||
#if IS_ENABLED(CONFIG_SETTINGS_FS)
|
#if IS_ENABLED(CONFIG_SETTINGS_FS)
|
||||||
#include <zephyr/fs/fs.h>
|
#include <zephyr/fs/fs.h>
|
||||||
|
@ -29,32 +35,27 @@ LOG_MODULE_REGISTER(settings_basic_test);
|
||||||
*/
|
*/
|
||||||
static void test_clear_settings(void)
|
static void test_clear_settings(void)
|
||||||
{
|
{
|
||||||
#if IS_ENABLED(CONFIG_SETTINGS_FCB) || IS_ENABLED(CONFIG_SETTINGS_NVS)
|
#if defined(TEST_FLASH_AREA_ID)
|
||||||
const struct flash_area *fap;
|
const struct flash_area *fap;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
#if DT_HAS_CHOSEN(zephyr_settings_partition)
|
rc = flash_area_open(TEST_FLASH_AREA_ID, &fap);
|
||||||
rc = flash_area_open(FLASH_AREA_ID(chosen_partition), &fap);
|
|
||||||
#else
|
|
||||||
rc = flash_area_open(FLASH_AREA_ID(storage), &fap);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
rc = flash_area_erase(fap, 0, fap->fa_size);
|
rc = flash_area_erase(fap, 0, fap->fa_size);
|
||||||
flash_area_close(fap);
|
flash_area_close(fap);
|
||||||
}
|
}
|
||||||
zassert_true(rc == 0, "clear settings failed");
|
zassert_true(rc == 0, "clear settings failed");
|
||||||
#endif
|
#elif IS_ENABLED(CONFIG_SETTINGS_FS)
|
||||||
#if IS_ENABLED(CONFIG_SETTINGS_FS)
|
|
||||||
FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(cstorage);
|
FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(cstorage);
|
||||||
|
|
||||||
/* mounting info */
|
/* mounting info */
|
||||||
static struct fs_mount_t littlefs_mnt = {
|
static struct fs_mount_t littlefs_mnt = {
|
||||||
.type = FS_LITTLEFS,
|
.type = FS_LITTLEFS,
|
||||||
.fs_data = &cstorage,
|
.fs_data = &cstorage,
|
||||||
.storage_dev = (void *)FLASH_AREA_ID(storage),
|
.storage_dev = (void *)FLASH_AREA_ID(storage),
|
||||||
.mnt_point = "/ff"
|
.mnt_point = "/ff"
|
||||||
};
|
};
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -64,6 +65,8 @@ static void test_clear_settings(void)
|
||||||
rc = fs_unlink(CONFIG_SETTINGS_FS_FILE);
|
rc = fs_unlink(CONFIG_SETTINGS_FS_FILE);
|
||||||
zassert_true(rc == 0 || rc == -ENOENT,
|
zassert_true(rc == 0 || rc == -ENOENT,
|
||||||
"can't delete config file%d\n", rc);
|
"can't delete config file%d\n", rc);
|
||||||
|
#else
|
||||||
|
#error "Settings backend not selected"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue