uci: fix a potential use-after-free in uci_set()
[project/uci.git] / test / tests.d / 020_get
1 test_get_parsing()
2 {
3         cp ${REF_DIR}/get_parsing.data ${CONFIG_DIR}/test
4
5         assertFailWithNoReturn "${UCI_Q} get test."
6         assertFailWithNoReturn "${UCI_Q} get test.section."
7         assertFailWithNoReturn "${UCI_Q} get test.section.opt."
8         assertFailWithNoReturn "${UCI_Q} get test.section.opt.val."
9         assertFailWithNoReturn "${UCI_Q} get test.section.opt.val.qsdf.qsd"
10         assertFailWithNoReturn "${UCI_Q} get test.section.opt.valqsqsd"
11 }
12
13 test_get_section_index_parsing()
14 {
15         cp ${REF_DIR}/get_parsing.data ${CONFIG_DIR}/test
16
17         assertFailWithNoReturn "${UCI_Q} get test.@"
18         assertFailWithNoReturn "${UCI_Q} get test.@zer."
19         assertFailWithNoReturn "${UCI_Q} get test.@."
20         assertFailWithNoReturn "${UCI_Q} get test.@zer[1]"
21         assertFailWithNoReturn "${UCI_Q} get test.@.opt"
22         assertFailWithNoReturn "${UCI_Q} get test.@[28]"
23         assertFailWithNoReturn "${UCI_Q} get test.@[1]."
24         assertFailWithNoReturn "${UCI_Q} get test.@[1].val."
25 }
26
27 test_get_option()
28 {
29         cp ${REF_DIR}/get.data ${CONFIG_DIR}/test
30         value=$($UCI get test.section.opt)
31         assertEquals 'val' "$value"
32 }
33
34 test_get_option_multiline()
35 {
36         cp ${REF_DIR}/get_multiline.data ${CONFIG_DIR}/test
37         value="$($UCI get test.section.opt)"
38         assertEquals '"Hello, World.
39 '\''' "$value"
40 }
41
42 test_get_section()
43 {
44         cp ${REF_DIR}/get.data ${CONFIG_DIR}/test
45         type=$($UCI get test.section)
46         assertEquals 'type' "$type"
47 }