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 <errno.h>
10
ZTEST(settings_config,test_config_getset_unknown)11 ZTEST(settings_config, test_config_getset_unknown)
12 {
13 char name[80];
14 char tmp[64];
15 int rc;
16
17 strcpy(name, "foo/bar");
18 rc = settings_runtime_set(name, "tmp", 4);
19 zassert_true(rc != 0, "set value should fail");
20 zassert_true(ctest_get_call_state() == 0,
21 "a handler was called unexpectedly");
22
23 strcpy(name, "foo/bar");
24 rc = settings_runtime_get(name, tmp, sizeof(tmp));
25 zassert_true(rc == -EINVAL, "value should been unreachable");
26 zassert_true(ctest_get_call_state() == 0,
27 "a handler was called unexpectedly");
28
29 strcpy(name, "myfoo/bar");
30 rc = settings_runtime_set(name, "tmp", 4);
31 zassert_true(rc == -ENOENT, "unexpected failure retval\n");
32 zassert_true(test_set_called == 1,
33 "the GET handler wasn't called");
34 ctest_clear_call_state();
35
36 strcpy(name, "myfoo/bar");
37 rc = settings_runtime_get(name, tmp, sizeof(tmp));
38 zassert_true(rc == -ENOENT, "value should been unreachable\n");
39 zassert_true(test_get_called == 1,
40 "the SET handler wasn't called");
41 ctest_clear_call_state();
42 }
43