1 /*
2 * Copyright (c) 2019 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include "settings_test.h"
8 #include "settings/settings_fcb.h"
9
ZTEST(settings_config_fcb,test_config_delete_fcb)10 ZTEST(settings_config_fcb, test_config_delete_fcb)
11 {
12 int rc;
13 struct settings_fcb cf;
14
15 rc = settings_register(&c_test_handlers[0]);
16 zassert_true(rc == 0 || rc == -EEXIST, "settings_register fail");
17 config_wipe_srcs();
18 config_wipe_fcb(fcb_sectors, ARRAY_SIZE(fcb_sectors));
19
20 cf.cf_fcb.f_magic = CONFIG_SETTINGS_FCB_MAGIC;
21 cf.cf_fcb.f_sectors = fcb_sectors;
22 cf.cf_fcb.f_sector_cnt = ARRAY_SIZE(fcb_sectors);
23
24 rc = settings_fcb_src(&cf);
25 zassert_true(rc == 0, "can't register FCB as configuration source");
26
27 settings_mount_fcb_backend(&cf);
28
29 rc = settings_fcb_dst(&cf);
30 zassert_true(rc == 0,
31 "can't register FCB as configuration destination");
32
33 val8 = 153U;
34 rc = settings_save();
35 zassert_true(rc == 0, "fcb write error");
36
37 val8 = 0U;
38
39 rc = settings_load();
40 zassert_true(rc == 0, "fcb redout error");
41 zassert_true(val8 == 153U, "bad value read");
42
43 val8 = 0x55;
44
45 settings_delete("myfoo/mybar");
46 rc = settings_load();
47 zassert_true(rc == 0, "fcb redout error");
48 zassert_true(val8 == 0x55, "bad value read");
49 settings_unregister(&c_test_handlers[0]);
50 }
51