Debian Codegraph @

ctdb/tests/UNIT/cunit/conf_test_001.sh

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 . "${TEST_SCRIPTS_DIR}/unit.sh"
4
5 conffile="${CTDB_TEST_TMP_DIR}/config.$$"
6
7 remove_filesscip-shell shell samba 2:4.24.3+dfsg-1 remove_files(). ()
8 {
9 rmscip-shell system . . rm. -f "$conffile"
10 }
11
12 test_cleanup remove_files
13
14 ok_null
15 unit_test conf_test 1
16
17 ok <<EOF
18 conf: unknown section [section1]
19 EOF
20 unit_test conf_test 2
21
22 ok <<EOF
23 conf: option "key1" already exists
24 EOF
25 unit_test conf_test 3
26
27 ok <<EOF
28 conf: option "key1" already exists
29 EOF
30 unit_test conf_test 4
31
32 ok_null
33 unit_test conf_test 5
34
35 ok <<EOF
36 [section1]
37 key1 = foobar # temporary
38 key2 = 20 # temporary
39 key3 = false # temporary
40 EOF
41 unit_test conf_test 6
42
43 ok <<EOF
44 conf: validation for option "key1" failed
45 conf: validation for option "key2" failed
46 conf: validation for option "key3" failed
47 EOF
48 unit_test conf_test 7
49
50 catscip-shell system . . cat. > "$conffile" <<EOF
51 [section1]
52 EOF
53
54 required_error EINVAL <<EOF
55 conf: validation for section [section1] failed
56 [section1]
57 # key1 = default
58 EOF
59 unit_test conf_test 8 "$conffile"
60
61 catscip-shell system . . cat. > "$conffile" <<EOF
62 [section1]
63 key1 = unknown
64 EOF
65
66 required_error EINVAL <<EOF
67 conf: validation for section [section1] failed
68 [section1]
69 # key1 = default
70 EOF
71 unit_test conf_test 8 "$conffile"
72
73 catscip-shell system . . cat. > "$conffile" <<EOF
74 [section1]
75 key1 =
76 EOF
77
78 required_error EINVAL <<EOF
79 conf: empty value [section1] -> "key1"
80 [section1]
81 # key1 = value1
82 # key2 = 10
83 key3 = false # temporary
84 EOF
85 unit_test conf_test 9 "$conffile"
86
87 catscip-shell system . . cat. > "$conffile" <<EOF
88 [section1]
89 key3 =
90 EOF
91
92 required_error EINVAL <<EOF
93 conf: empty value [section1] -> "key3"
94 [section1]
95 # key1 = value1
96 # key2 = 10
97 key3 = false # temporary
98 EOF
99 unit_test conf_test 9 "$conffile"
100
101 catscip-shell system . . cat. > "$conffile" <<EOF
102
103 [section1]
104 key1 = value2
105 key2 = 20 # comment
106 key3 = false
107 EOF
108
109 ok <<EOF
110 [section1]
111 key1 = value2
112 key2 = 20
113 # key3 = true
114 EOF
115 unit_test conf_test 9 "$conffile"
116
117 catscip-shell system . . cat. > "$conffile" <<EOF
118 [section1]
119 key1 = value2
120 EOF
121
122 ok <<EOF
123 [section1]
124 key1 = value2
125 # key2 = 10
126 # key3 = true
127 EOF
128 unit_test conf_test 9 "$conffile"
129
130 catscip-shell system . . cat. > "$conffile" <<EOF
131 [section2]
132 foo = bar
133 EOF
134
135 required_error EINVAL <<EOF
136 conf: unknown section [section2]
137 conf: unknown section for option "foo"
138 [section1]
139 # key1 = value1
140 # key2 = 10
141 key3 = false # temporary
142 EOF
143 unit_test conf_test 10 "$conffile"
144
145 catscip-shell system . . cat. > "$conffile" <<EOF
146 [section1]
147 key1 = value2
148 foo = bar
149 key2 = 20
150 EOF
151
152 required_error EINVAL <<EOF
153 conf: unknown option [section1] -> "foo"
154 [section1]
155 # key1 = value1
156 # key2 = 10
157 key3 = false # temporary
158 EOF
159 unit_test conf_test 10 "$conffile"
160
161 catscip-shell system . . cat. > "$conffile" <<EOF
162 [section1]
163 key1 = value2
164 key2 = 20
165 key3 = false
166 EOF
167
168 touchscip-shell system . . touch. "${conffile}.reload"
169
170 ok <<EOF
171 [section1]
172 # key1 = value1
173 # key2 = 10
174 # key3 = true
175 EOF
176 unit_test conf_test 11 "$conffile"
177
178 catscip-shell system . . cat. > "$conffile" <<EOF
179 [section1]
180 key1 = value2
181 key2 = 20
182 key3 = false
183 EOF
184
185 catscip-shell system . . cat. > "${conffile}.reload" <<EOF
186 [section1]
187 key1 = value3
188 EOF
189
190 ok <<EOF
191 [section1]
192 key1 = value3
193 # key2 = 10
194 # key3 = true
195 EOF
196 unit_test conf_test 11 "$conffile"