Currently there is inconsistency in repository file names, APIs, Kconfig options and documentation around file / file-system backend for settings storage, as both "file" and "FS (file system)" are used. As an example, there is `CONFIG_SETTINGS_FS` Kconfig option, but the file that implements this settings backend is called `settings_file.c`. Another example are names of static functions that implement settings storage API: `settings_file_load()`, `settings_file_save()` and `settings_fs_storage_get()`. This backend is actually storing all settings in a single file, so it makes sense to use "File" as the name of backend, instead of a more general "FS" (which would make sense if several files would be used to store settings). Fix inconsistency in used wording in the tree and unify it to "settings file backend". This naming is more precise to how the implementation looks. It will also make it easier to grep through the codebase and analyze existing code. Deprecate settings_mount_fs_backend() function and all Kconfig options starting with `CONFIG_SETTINGS_FS`. Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
54 lines
1.5 KiB
C
54 lines
1.5 KiB
C
/*
|
|
* Copyright (c) 2018 Nordic Semiconductor ASA
|
|
* Copyright (c) 2015 Runtime Inc
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include "settings_test.h"
|
|
#include "settings/settings_file.h"
|
|
|
|
#define CF_MFG_TEST_STR "\x0D\x00myfoo/mybar=\x01"
|
|
#define CF_RUNNING_TEST_STR "\x0D\x00myfoo/mybar=\x08"
|
|
|
|
ZTEST(settings_config_fs, test_config_small_file)
|
|
{
|
|
int rc;
|
|
struct settings_file cf_mfg;
|
|
struct settings_file cf_running;
|
|
const char cf_mfg_test[] = CF_MFG_TEST_STR;
|
|
const char cf_running_test[] = CF_RUNNING_TEST_STR;
|
|
|
|
config_wipe_srcs();
|
|
|
|
cf_mfg.cf_name = TEST_CONFIG_DIR "/mfg";
|
|
cf_running.cf_name = TEST_CONFIG_DIR "/running";
|
|
|
|
rc = settings_file_src(&cf_mfg);
|
|
zassert_true(rc == 0, "can't register FS as configuration source");
|
|
rc = settings_file_src(&cf_running);
|
|
zassert_true(rc == 0, "can't register FS as configuration source");
|
|
|
|
rc = fsutil_write_file(TEST_CONFIG_DIR "/mfg", cf_mfg_test,
|
|
sizeof(cf_mfg_test));
|
|
zassert_true(rc == 0, "can't write to file");
|
|
|
|
settings_load();
|
|
zassert_true(test_set_called, "the SET handler wasn't called");
|
|
zassert_true(val8 == 1U,
|
|
"SET handler: was called with wrong parameters");
|
|
|
|
ctest_clear_call_state();
|
|
|
|
rc = fsutil_write_file(TEST_CONFIG_DIR "/running", cf_running_test,
|
|
sizeof(cf_running_test));
|
|
zassert_true(rc == 0, "can't write to file");
|
|
|
|
settings_load();
|
|
zassert_true(test_set_called, "the SET handler wasn't called");
|
|
zassert_true(val8 == 8U,
|
|
"SET handler: was called with wrong parameters");
|
|
|
|
ctest_clear_call_state();
|
|
}
|