| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash | 
|  | 2 |  | 
|  | 3 | # Tests for DevStack meta-config functions | 
|  | 4 |  | 
|  | 5 | TOP=$(cd $(dirname "$0")/.. && pwd) | 
|  | 6 |  | 
| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 7 | # Import config functions | 
| Dean Troyer | bf2ad70 | 2015-03-09 15:16:10 -0500 | [diff] [blame] | 8 | source $TOP/inc/ini-config | 
|  | 9 | source $TOP/inc/meta-config | 
| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 10 |  | 
| Ian Wienand | fa3e841 | 2015-04-17 11:53:40 +1000 | [diff] [blame] | 11 | set -e | 
|  | 12 |  | 
| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 13 | # check_result() tests and reports the result values | 
|  | 14 | # check_result "actual" "expected" | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 15 | function check_result { | 
| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 16 | local actual=$1 | 
|  | 17 | local expected=$2 | 
|  | 18 | if [[ "$actual" == "$expected" ]]; then | 
|  | 19 | echo "OK" | 
|  | 20 | else | 
|  | 21 | echo -e "failed: $actual != $expected\n" | 
| Ian Wienand | fcdca05 | 2015-04-17 13:02:49 +1000 | [diff] [blame] | 22 | exit 1 | 
| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 23 | fi | 
|  | 24 | } | 
|  | 25 |  | 
| Thomas Morin | 85f42f6 | 2015-09-01 10:33:10 +0200 | [diff] [blame] | 26 | # mock function-common:die so that it does not | 
| Swapnil Kulkarni (coolsvap) | 7f0be4f | 2015-11-20 10:52:59 +0530 | [diff] [blame] | 27 | # interrupt our test script | 
| Thomas Morin | 85f42f6 | 2015-09-01 10:33:10 +0200 | [diff] [blame] | 28 | function die { | 
|  | 29 | exit -1 | 
|  | 30 | } | 
|  | 31 |  | 
| Sean Dague | 22b6366 | 2016-12-09 07:33:01 -0500 | [diff] [blame] | 32 | function warn { | 
|  | 33 | return 0 | 
|  | 34 | } | 
|  | 35 |  | 
| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 36 | TEST_1C_ADD="[eee] | 
|  | 37 | type=new | 
|  | 38 | multi = foo2" | 
|  | 39 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 40 | function create_test1c { | 
| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 41 | cat >test1c.conf <<EOF | 
|  | 42 | [eee] | 
|  | 43 | # original comment | 
|  | 44 | type=original | 
|  | 45 | EOF | 
|  | 46 | } | 
|  | 47 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 48 | function create_test2a { | 
| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 49 | cat >test2a.conf <<EOF | 
|  | 50 | [ddd] | 
|  | 51 | # original comment | 
|  | 52 | type=original | 
|  | 53 | EOF | 
|  | 54 | } | 
|  | 55 |  | 
| Ryota MIBU | 410f5c0 | 2014-04-04 02:00:31 +0900 | [diff] [blame] | 56 | function setup_test4 { | 
|  | 57 | mkdir -p test-etc | 
|  | 58 | cat >test-etc/test4.conf <<EOF | 
|  | 59 | [fff] | 
|  | 60 | # original comment | 
|  | 61 | type=original | 
|  | 62 | EOF | 
|  | 63 | TEST4_DIR="test-etc" | 
|  | 64 | TEST4_FILE="test4.conf" | 
|  | 65 | } | 
|  | 66 |  | 
| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 67 | cat >test.conf <<EOF | 
|  | 68 | [[test1|test1a.conf]] | 
|  | 69 | [default] | 
|  | 70 | # comment an option | 
|  | 71 | #log_file=./log.conf | 
|  | 72 | log_file=/etc/log.conf | 
|  | 73 | handlers=do not disturb | 
|  | 74 |  | 
|  | 75 | [aaa] | 
|  | 76 | # the commented option should not change | 
|  | 77 | #handlers=cc,dd | 
|  | 78 | handlers = aa, bb | 
|  | 79 |  | 
|  | 80 | [[test1|test1b.conf]] | 
|  | 81 | [bbb] | 
|  | 82 | handlers=ee,ff | 
|  | 83 |  | 
|  | 84 | [ ccc ] | 
|  | 85 | spaces  =  yes | 
|  | 86 |  | 
|  | 87 | [[test2|test2a.conf]] | 
|  | 88 | [ddd] | 
|  | 89 | # new comment | 
|  | 90 | type=new | 
|  | 91 | additional=true | 
|  | 92 |  | 
|  | 93 | [[test1|test1c.conf]] | 
|  | 94 | $TEST_1C_ADD | 
| Dean Troyer | 2ac8b3f | 2013-12-04 17:20:28 -0600 | [diff] [blame] | 95 |  | 
|  | 96 | [[test3|test-space.conf]] | 
|  | 97 | [DEFAULT] | 
|  | 98 | attribute=value | 
| Sean Dague | 22b6366 | 2016-12-09 07:33:01 -0500 | [diff] [blame] | 99 |  | 
| Dean Troyer | 2ac8b3f | 2013-12-04 17:20:28 -0600 | [diff] [blame] | 100 | # the above line has a single space | 
| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 101 |  | 
| Ryota MIBU | 410f5c0 | 2014-04-04 02:00:31 +0900 | [diff] [blame] | 102 | [[test4|\$TEST4_DIR/\$TEST4_FILE]] | 
|  | 103 | [fff] | 
|  | 104 | type=new | 
| Ian Wienand | e2c9fee | 2014-09-26 09:42:11 +1000 | [diff] [blame] | 105 |  | 
| Ian Wienand | f3bf8b6 | 2014-10-29 21:53:56 +1100 | [diff] [blame] | 106 | [[test-env|test-env.conf]] | 
| Ian Wienand | e2c9fee | 2014-09-26 09:42:11 +1000 | [diff] [blame] | 107 | [foo] | 
| Ian Wienand | f3bf8b6 | 2014-10-29 21:53:56 +1100 | [diff] [blame] | 108 | foo=\${FOO_BAR_BAZ} | 
| Fergal Mc Carthy | cc87c28 | 2014-10-09 16:16:42 -0400 | [diff] [blame] | 109 |  | 
|  | 110 | [[test5|test-equals.conf]] | 
|  | 111 | [DEFAULT] | 
|  | 112 | drivers = driver=python.import.path.Driver | 
|  | 113 |  | 
|  | 114 | [[test6|test-strip.conf]] | 
|  | 115 | [DEFAULT] | 
|  | 116 | # next line has trailing space | 
| Kevin Benton | e0d6a46 | 2014-10-14 04:54:42 -0700 | [diff] [blame] | 117 | attr = strip_trailing_space | 
|  | 118 |  | 
|  | 119 | [[test7|test-colon.conf]] | 
|  | 120 | [DEFAULT] | 
|  | 121 | servers=10.11.12.13:80 | 
| Robert Li | 751ad1a | 2014-10-15 21:40:53 -0400 | [diff] [blame] | 122 |  | 
| Thomas Morin | 85f42f6 | 2015-09-01 10:33:10 +0200 | [diff] [blame] | 123 | [[test8|/permission-denied.conf]] | 
|  | 124 | foo=bar | 
|  | 125 |  | 
|  | 126 | [[test9|\$UNDEF]] | 
|  | 127 | foo=bar | 
|  | 128 |  | 
|  | 129 | [[test10|does-not-exist-dir/test.conf]] | 
|  | 130 | foo=bar | 
|  | 131 |  | 
| YAMAMOTO Takashi | 02f3f9a | 2016-11-26 00:43:07 +0900 | [diff] [blame] | 132 | [[test11|test-same.conf]] | 
|  | 133 | [DEFAULT] | 
|  | 134 | foo=bar | 
|  | 135 |  | 
|  | 136 | [[test11|test-same.conf]] | 
|  | 137 | [some] | 
|  | 138 | random=config | 
|  | 139 |  | 
| Robert Li | 751ad1a | 2014-10-15 21:40:53 -0400 | [diff] [blame] | 140 | [[test-multi-sections|test-multi-sections.conf]] | 
|  | 141 | [sec-1] | 
|  | 142 | cfg_item1 = abcd | 
|  | 143 | cfg_item2 = efgh | 
|  | 144 |  | 
|  | 145 | [sec-2] | 
|  | 146 | cfg_item1 = abcd | 
|  | 147 | cfg_item3 = /1/2/3/4:5 | 
|  | 148 | cfg_item4 = end | 
|  | 149 |  | 
|  | 150 | [sec-3] | 
|  | 151 | cfg_item5 = 5555 | 
|  | 152 | cfg_item6 = 6666 | 
|  | 153 | cfg_item5 = 5555another | 
|  | 154 |  | 
|  | 155 | [[test-multiline|test-multiline.conf]] | 
|  | 156 | [multi] | 
| Ian Wienand | f3bf8b6 | 2014-10-29 21:53:56 +1100 | [diff] [blame] | 157 | cfg_item1 = ab:cd:ef:gh | 
| Robert Li | 751ad1a | 2014-10-15 21:40:53 -0400 | [diff] [blame] | 158 | cfg_item1 = abcd | 
|  | 159 | cfg_item2 = efgh | 
| Ian Wienand | f3bf8b6 | 2014-10-29 21:53:56 +1100 | [diff] [blame] | 160 | cfg_item2 = \${FOO_BAR_BAZ} | 
|  | 161 |  | 
| YAMAMOTO Takashi | 02f3f9a | 2016-11-26 00:43:07 +0900 | [diff] [blame] | 162 | [[test11|test-same.conf]] | 
|  | 163 | [another] | 
|  | 164 | non = sense | 
| Ryota MIBU | 410f5c0 | 2014-04-04 02:00:31 +0900 | [diff] [blame] | 165 | EOF | 
| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 166 |  | 
|  | 167 | echo -n "get_meta_section_files: test0 doesn't exist: " | 
|  | 168 | VAL=$(get_meta_section_files test.conf test0) | 
|  | 169 | check_result "$VAL" "" | 
|  | 170 |  | 
|  | 171 | echo -n "get_meta_section_files: test1 3 files: " | 
|  | 172 | VAL=$(get_meta_section_files test.conf test1) | 
|  | 173 | EXPECT_VAL="test1a.conf | 
|  | 174 | test1b.conf | 
|  | 175 | test1c.conf" | 
|  | 176 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 177 |  | 
|  | 178 | echo -n "get_meta_section_files: test2 1 file: " | 
|  | 179 | VAL=$(get_meta_section_files test.conf test2) | 
|  | 180 | EXPECT_VAL="test2a.conf" | 
|  | 181 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 182 |  | 
|  | 183 |  | 
|  | 184 | # Get a section from a group that doesn't exist | 
|  | 185 | echo -n "get_meta_section: test0 doesn't exist: " | 
|  | 186 | VAL=$(get_meta_section test.conf test0 test0.conf) | 
|  | 187 | check_result "$VAL" "" | 
|  | 188 |  | 
|  | 189 | # Get a single section from a group with multiple files | 
|  | 190 | echo -n "get_meta_section: test1c single section: " | 
|  | 191 | VAL=$(get_meta_section test.conf test1 test1c.conf) | 
|  | 192 | check_result "$VAL" "$TEST_1C_ADD" | 
|  | 193 |  | 
|  | 194 | # Get a single section from a group with a single file | 
|  | 195 | echo -n "get_meta_section: test2a single section: " | 
|  | 196 | VAL=$(get_meta_section test.conf test2 test2a.conf) | 
|  | 197 | EXPECT_VAL="[ddd] | 
|  | 198 | # new comment | 
|  | 199 | type=new | 
|  | 200 | additional=true" | 
|  | 201 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 202 |  | 
|  | 203 | # Get a single section that doesn't exist from a group | 
|  | 204 | echo -n "get_meta_section: test2z.conf not in test2: " | 
|  | 205 | VAL=$(get_meta_section test.conf test2 test2z.conf) | 
|  | 206 | check_result "$VAL" "" | 
|  | 207 |  | 
|  | 208 | # Get a section from a conf file that doesn't exist | 
|  | 209 | echo -n "get_meta_section: nofile doesn't exist: " | 
|  | 210 | VAL=$(get_meta_section nofile.ini test1) | 
|  | 211 | check_result "$VAL" "" | 
|  | 212 |  | 
|  | 213 | echo -n "get_meta_section: nofile doesn't exist: " | 
|  | 214 | VAL=$(get_meta_section nofile.ini test0 test0.conf) | 
|  | 215 | check_result "$VAL" "" | 
|  | 216 |  | 
|  | 217 | echo -n "merge_config_file test1c exists: " | 
|  | 218 | create_test1c | 
|  | 219 | merge_config_file test.conf test1 test1c.conf | 
|  | 220 | VAL=$(cat test1c.conf) | 
|  | 221 | # iniset adds values immediately under the section header | 
|  | 222 | EXPECT_VAL="[eee] | 
|  | 223 | multi = foo2 | 
|  | 224 | # original comment | 
|  | 225 | type=new" | 
|  | 226 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 227 |  | 
|  | 228 | echo -n "merge_config_file test2a exists: " | 
|  | 229 | create_test2a | 
|  | 230 | merge_config_file test.conf test2 test2a.conf | 
|  | 231 | VAL=$(cat test2a.conf) | 
|  | 232 | # iniset adds values immediately under the section header | 
|  | 233 | EXPECT_VAL="[ddd] | 
|  | 234 | additional = true | 
|  | 235 | # original comment | 
|  | 236 | type=new" | 
|  | 237 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 238 |  | 
|  | 239 | echo -n "merge_config_file test2a not exist: " | 
|  | 240 | rm test2a.conf | 
|  | 241 | merge_config_file test.conf test2 test2a.conf | 
|  | 242 | VAL=$(cat test2a.conf) | 
|  | 243 | # iniset adds a blank line if it creates the file... | 
|  | 244 | EXPECT_VAL=" | 
|  | 245 | [ddd] | 
| Robert Li | 751ad1a | 2014-10-15 21:40:53 -0400 | [diff] [blame] | 246 | type = new | 
|  | 247 | additional = true" | 
|  | 248 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 249 |  | 
|  | 250 | echo -n "merge_config_file test-multi-sections: " | 
|  | 251 | rm -f test-multi-sections.conf | 
|  | 252 | merge_config_file test.conf test-multi-sections test-multi-sections.conf | 
|  | 253 | VAL=$(cat test-multi-sections.conf) | 
|  | 254 | EXPECT_VAL=' | 
|  | 255 | [sec-1] | 
|  | 256 | cfg_item1 = abcd | 
|  | 257 | cfg_item2 = efgh | 
|  | 258 |  | 
|  | 259 | [sec-2] | 
|  | 260 | cfg_item1 = abcd | 
|  | 261 | cfg_item3 = /1/2/3/4:5 | 
|  | 262 | cfg_item4 = end | 
|  | 263 |  | 
|  | 264 | [sec-3] | 
|  | 265 | cfg_item5 = 5555 | 
|  | 266 | cfg_item5 = 5555another | 
|  | 267 | cfg_item6 = 6666' | 
|  | 268 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 269 |  | 
|  | 270 | echo -n "merge_config_file test-multiline: " | 
|  | 271 | rm -f test-multiline.conf | 
| Ian Wienand | f3bf8b6 | 2014-10-29 21:53:56 +1100 | [diff] [blame] | 272 | FOO_BAR_BAZ="foo bar baz" | 
| Robert Li | 751ad1a | 2014-10-15 21:40:53 -0400 | [diff] [blame] | 273 | merge_config_file test.conf test-multiline test-multiline.conf | 
|  | 274 | VAL=$(cat test-multiline.conf) | 
|  | 275 | EXPECT_VAL=' | 
|  | 276 | [multi] | 
| Ian Wienand | f3bf8b6 | 2014-10-29 21:53:56 +1100 | [diff] [blame] | 277 | cfg_item1 = ab:cd:ef:gh | 
| Robert Li | 751ad1a | 2014-10-15 21:40:53 -0400 | [diff] [blame] | 278 | cfg_item1 = abcd | 
| Ian Wienand | f3bf8b6 | 2014-10-29 21:53:56 +1100 | [diff] [blame] | 279 | cfg_item2 = efgh | 
|  | 280 | cfg_item2 = foo bar baz' | 
| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 281 | check_result "$VAL" "$EXPECT_VAL" | 
| Ian Wienand | f3bf8b6 | 2014-10-29 21:53:56 +1100 | [diff] [blame] | 282 | unset FOO_BAR_BAZ | 
| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 283 |  | 
|  | 284 | echo -n "merge_config_group test2: " | 
|  | 285 | rm test2a.conf | 
|  | 286 | merge_config_group test.conf test2 | 
|  | 287 | VAL=$(cat test2a.conf) | 
|  | 288 | # iniset adds a blank line if it creates the file... | 
|  | 289 | EXPECT_VAL=" | 
|  | 290 | [ddd] | 
| Robert Li | 751ad1a | 2014-10-15 21:40:53 -0400 | [diff] [blame] | 291 | type = new | 
|  | 292 | additional = true" | 
| Dean Troyer | 893e663 | 2013-09-13 15:05:51 -0500 | [diff] [blame] | 293 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 294 |  | 
|  | 295 | echo -n "merge_config_group test2 no conf file: " | 
|  | 296 | rm test2a.conf | 
|  | 297 | merge_config_group x-test.conf test2 | 
|  | 298 | if [[ ! -r test2a.conf ]]; then | 
|  | 299 | echo "OK" | 
|  | 300 | else | 
|  | 301 | echo "failed: $VAL != $EXPECT_VAL" | 
|  | 302 | fi | 
|  | 303 |  | 
| Dean Troyer | 2ac8b3f | 2013-12-04 17:20:28 -0600 | [diff] [blame] | 304 | echo -n "merge_config_file test-space: " | 
|  | 305 | rm -f test-space.conf | 
|  | 306 | merge_config_file test.conf test3 test-space.conf | 
|  | 307 | VAL=$(cat test-space.conf) | 
|  | 308 | # iniset adds a blank line if it creates the file... | 
|  | 309 | EXPECT_VAL=" | 
|  | 310 | [DEFAULT] | 
|  | 311 | attribute = value" | 
|  | 312 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 313 |  | 
| Ian Wienand | f3bf8b6 | 2014-10-29 21:53:56 +1100 | [diff] [blame] | 314 | echo -n "merge_config_file test-env: " | 
|  | 315 | rm -f test-env.conf | 
|  | 316 | FOO_BAR_BAZ="foo bar baz" | 
|  | 317 | merge_config_file test.conf test-env test-env.conf | 
|  | 318 | VAL=$(cat test-env.conf) | 
| Ian Wienand | e2c9fee | 2014-09-26 09:42:11 +1000 | [diff] [blame] | 319 | EXPECT_VAL=' | 
|  | 320 | [foo] | 
| Ian Wienand | f3bf8b6 | 2014-10-29 21:53:56 +1100 | [diff] [blame] | 321 | foo = foo bar baz' | 
| Ian Wienand | e2c9fee | 2014-09-26 09:42:11 +1000 | [diff] [blame] | 322 | check_result "$VAL" "$EXPECT_VAL" | 
| Ian Wienand | f3bf8b6 | 2014-10-29 21:53:56 +1100 | [diff] [blame] | 323 | unset FOO_BAR_BAZ | 
| Ian Wienand | e2c9fee | 2014-09-26 09:42:11 +1000 | [diff] [blame] | 324 |  | 
| Ryota MIBU | 410f5c0 | 2014-04-04 02:00:31 +0900 | [diff] [blame] | 325 | echo -n "merge_config_group test4 variable filename: " | 
|  | 326 | setup_test4 | 
|  | 327 | merge_config_group test.conf test4 | 
|  | 328 | VAL=$(cat test-etc/test4.conf) | 
|  | 329 | EXPECT_VAL="[fff] | 
|  | 330 | # original comment | 
|  | 331 | type=new" | 
|  | 332 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 333 |  | 
|  | 334 | echo -n "merge_config_group test4 variable filename (not exist): " | 
|  | 335 | setup_test4 | 
|  | 336 | rm test-etc/test4.conf | 
|  | 337 | merge_config_group test.conf test4 | 
|  | 338 | VAL=$(cat test-etc/test4.conf) | 
|  | 339 | EXPECT_VAL=" | 
|  | 340 | [fff] | 
|  | 341 | type = new" | 
|  | 342 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 343 |  | 
| Fergal Mc Carthy | cc87c28 | 2014-10-09 16:16:42 -0400 | [diff] [blame] | 344 | echo -n "merge_config_file test5 equals in value: " | 
|  | 345 | rm -f test-equals.conf | 
|  | 346 | merge_config_file test.conf test5 test-equals.conf | 
|  | 347 | VAL=$(cat test-equals.conf) | 
|  | 348 | # iniset adds a blank line if it creates the file... | 
|  | 349 | EXPECT_VAL=" | 
|  | 350 | [DEFAULT] | 
|  | 351 | drivers = driver=python.import.path.Driver" | 
|  | 352 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 353 |  | 
|  | 354 | echo -n "merge_config_file test6 value stripped: " | 
|  | 355 | rm -f test-strip.conf | 
|  | 356 | merge_config_file test.conf test6 test-strip.conf | 
|  | 357 | VAL=$(cat test-strip.conf) | 
|  | 358 | # iniset adds a blank line if it creates the file... | 
|  | 359 | EXPECT_VAL=" | 
|  | 360 | [DEFAULT] | 
|  | 361 | attr = strip_trailing_space" | 
|  | 362 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 363 |  | 
| Kevin Benton | e0d6a46 | 2014-10-14 04:54:42 -0700 | [diff] [blame] | 364 | echo -n "merge_config_file test7 colon in value: " | 
|  | 365 | rm -f test-colon.conf | 
|  | 366 | merge_config_file test.conf test7 test-colon.conf | 
|  | 367 | VAL=$(cat test-colon.conf) | 
|  | 368 | EXPECT_VAL=" | 
|  | 369 | [DEFAULT] | 
|  | 370 | servers = 10.11.12.13:80" | 
|  | 371 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 372 |  | 
| Thomas Morin | 85f42f6 | 2015-09-01 10:33:10 +0200 | [diff] [blame] | 373 | echo "merge_config_file test8 non-touchable conf file: " | 
|  | 374 | set +e | 
|  | 375 | # function is expected to fail and exit, running it | 
|  | 376 | # in a subprocess to let this script proceed | 
|  | 377 | (merge_config_file test.conf test8 /permission-denied.conf) | 
|  | 378 | VAL=$? | 
|  | 379 | EXPECT_VAL=255 | 
|  | 380 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 381 | set -e | 
|  | 382 |  | 
|  | 383 | echo -n "merge_config_group test9 undefined conf file: " | 
|  | 384 | set +e | 
| Sean Dague | 22b6366 | 2016-12-09 07:33:01 -0500 | [diff] [blame] | 385 | # function is expected to trigger warn and continue | 
| Thomas Morin | 85f42f6 | 2015-09-01 10:33:10 +0200 | [diff] [blame] | 386 | (merge_config_group test.conf test9) | 
|  | 387 | VAL=$? | 
| Sean Dague | 22b6366 | 2016-12-09 07:33:01 -0500 | [diff] [blame] | 388 | EXPECT_VAL=0 | 
| Thomas Morin | 85f42f6 | 2015-09-01 10:33:10 +0200 | [diff] [blame] | 389 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 390 | set -e | 
|  | 391 |  | 
|  | 392 | echo -n "merge_config_group test10 not directory: " | 
|  | 393 | set +e | 
|  | 394 | # function is expected to fail and exit, running it | 
|  | 395 | # in a subprocess to let this script proceed | 
|  | 396 | (merge_config_group test.conf test10) | 
|  | 397 | VAL=$? | 
|  | 398 | EXPECT_VAL=255 | 
|  | 399 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 400 | set -e | 
|  | 401 |  | 
| YAMAMOTO Takashi | 02f3f9a | 2016-11-26 00:43:07 +0900 | [diff] [blame] | 402 | echo -n "merge_config_file test11 same section: " | 
|  | 403 | rm -f test-same.conf | 
|  | 404 | merge_config_group test.conf test11 | 
|  | 405 | VAL=$(cat test-same.conf) | 
|  | 406 | EXPECT_VAL=' | 
|  | 407 | [DEFAULT] | 
|  | 408 | foo = bar | 
|  | 409 |  | 
|  | 410 | [some] | 
|  | 411 | random = config | 
|  | 412 |  | 
|  | 413 | [another] | 
|  | 414 | non = sense' | 
|  | 415 | check_result "$VAL" "$EXPECT_VAL" | 
|  | 416 |  | 
|  | 417 |  | 
| Ian Wienand | f3bf8b6 | 2014-10-29 21:53:56 +1100 | [diff] [blame] | 418 | rm -f test.conf test1c.conf test2a.conf \ | 
|  | 419 | test-space.conf test-equals.conf test-strip.conf \ | 
|  | 420 | test-colon.conf test-env.conf test-multiline.conf \ | 
| YAMAMOTO Takashi | 02f3f9a | 2016-11-26 00:43:07 +0900 | [diff] [blame] | 421 | test-multi-sections.conf test-same.conf | 
| Ryota MIBU | 410f5c0 | 2014-04-04 02:00:31 +0900 | [diff] [blame] | 422 | rm -rf test-etc |