1 /*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 * Copyright (c) 2015 Runtime Inc
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8 #include "settings_test.h"
9 #include "settings/settings_file.h"
10
11 #define CF_MFG_TEST1 "\x0d\x00myfoo/mybar=\x01"\
12 "\x0d\x00myfoo/mybar=\x0e"
13 #define CF_MFG_TEST2 "\x0d\x00myfoo/mybar=\x01"\
14 "\x0d\x00myfoo/mybar=\x0f"
15
ZTEST(settings_config_fs,test_config_multiple_in_file)16 ZTEST(settings_config_fs, test_config_multiple_in_file)
17 {
18 int rc;
19 struct settings_file cf_mfg;
20 const char cf_mfg_test1[] = CF_MFG_TEST1;
21 const char cf_mfg_test2[] = CF_MFG_TEST2;
22
23 config_wipe_srcs();
24
25 cf_mfg.cf_name = TEST_CONFIG_DIR "/mfg";
26 rc = settings_file_src(&cf_mfg);
27 zassert_true(rc == 0, "can't register FS as configuration source");
28
29 rc = fsutil_write_file(TEST_CONFIG_DIR "/mfg", cf_mfg_test1,
30 sizeof(cf_mfg_test1));
31 zassert_true(rc == 0, "can't write to file");
32
33 settings_load();
34 zassert_true(test_set_called, "the SET handler wasn't called");
35 zassert_true(val8 == 14U,
36 "SET handler: was called with wrong parameters");
37
38 rc = fsutil_write_file(TEST_CONFIG_DIR "/mfg", cf_mfg_test2,
39 sizeof(cf_mfg_test2));
40 zassert_true(rc == 0, "can't write to file");
41
42 settings_load();
43 zassert_true(test_set_called, "the SET handler wasn't called");
44 zassert_true(val8 == 15U,
45 "SET handler: was called with wrong parameters");
46 }
47