1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361
|
# Tests for aug_srun
# Blank lines and lines starting with '#' are ignored. This file is
# processed by test-run.c
#
# The syntax for a test specification is
# test NAME RESULT ERRCODE
# COMMANDS
# prints
# OUTPUT
#
# where
# NAME - the name printed to identify the test
# RESULT - an integer that is compared against the return code
# of aug_srun
# ERRCODE - one of the error codes defined in enum errcode_t in augeas.h
# without the AUG_ prefix, i.e. NOERROR, EMMATCH etc. If ERRCODE
# is ommitted, it defaults to NOERROR
# COMMANDS - the commands to hand to aug_srun; can be multiple lines,
# which are passed as one string.
# OUTPUT - the string that aug_srun should print on the OUT file stream
#
# The prints keyword and OUTPUT are optional; if they are not provided, the
# output of aug_srun must be empty
#
# Leading spaces are stripped from COMMANDS and OUTPUT; a leading or trailing
# ':' is also stripped, but the rest of the line is used verbatim.
#
# A test passes when RESULT and ERRCODE agree with what aug_srun given
# COMMANDS produces, and OUTPUT coincides with what aug_srun prints on its
# OUT stream.
#
# The test is run against a tree initialized with AUG_NO_STDINC|AUG_NO_LOAD
# and file system root /dev/null
#
# Various corner cases
#
test null 0
test empty 0
:
test quit -2
quit
test quit-2 -2
get /augeas
quit
prints
/augeas (none)
test two-commands 2
get /augeas/root
get /augeas/span
prints
/augeas/root = /dev/null/
/augeas/span = disable
test comment 1
:# Get /augeas
get /augeas
prints
/augeas (none)
test get_wspace 2
: get /augeas :
: rm /augeas/root :
prints
/augeas (none)
rm : /augeas/root 1
test get_wspace_between 1
: get /augeas
prints
/augeas (none)
test unknown-cmd -1 ECMDRUN
nocommand
test help 1
help
prints something
#
# ls tests
#
test ls-root 1
ls /
prints
augeas/ = (none)
files = (none)
test ls-bad-pathx -1 EPATHX
ls /files[]
#
# match tests
#
test match-root 1
match /
prints
/augeas = (none)
/files = (none)
test match-context 1
match .
prints
/files = (none)
test match-root-star 1
match /*
prints
/augeas = (none)
/files = (none)
test match-bad-pathx -1 EPATHX
match /files[]
test match-nothing 1
match /not-there
prints
: (no matches)
#
# test rm
#
test rm-save-modes 1
rm /augeas/version/save
prints
rm : /augeas/version/save 5
test rm-bad-pathx -1 EPATHX
rm /files[]
#
# test mv
#
test mv 1
mv /augeas/version /files
test mv-not-there -1 ENOMATCH
mv /not-there /files
test mv-to-not-there 1
mv /files /new-node
test mv-into-descendant -1 EMVDESC
mv /augeas /augeas/version
test mv-into-self -1 EMVDESC
mv /augeas /augeas
test mv-into-multiple -1 EMMATCH
mv /files /augeas/version/save/*
test mv-multiple -1 EMMATCH
mv /augeas/version/save/* /files
test mv-tree1 3
set /a/b/c value
mv /a/b/c /x
print /*[ label() != 'augeas' and label() != 'files']
prints
/a
/a/b
/x = "value"
test mv-tree2 3
set /a/b/c value
mv /a/b/c /a/x
print /*[ label() != 'augeas' and label() != 'files']
prints
/a
/a/b
/a/x = "value"
test mv-tree3 3
set /a/b/c value
mv /a/b/c /x/y
print /*[ label() != 'augeas' and label() != 'files']
prints
/a
/a/b
/x
/x/y = "value"
test mv-tree4 -1 EMVDESC
set /a/b/c value
mv /a/b/c /a/b/c/d
print /*[ label() != 'augeas' and label() != 'files']
test mv-tree5 3
set /a/b/c value
mv /a/b/c /a/b/d
print /*[ label() != 'augeas' and label() != 'files']
prints
/a
/a/b
/a/b/d = "value"
test mv-tree6 3
set /a/b/c value
mv /a /x/y
print /*[ label() != 'augeas' and label() != 'files']
prints
/x
/x/y
/x/y/b
/x/y/b/c = "value"
#
# test set
#
test set-not-there 2
set /foo value
get /foo
prints
/foo = value
test set-existing 2
set /files value
get /files
prints
/files = value
test set-trailing-slash 2
set /files/ value
get /files
prints
/files = value
test set-bad-pathx -1 EPATHX
set /files[] 1
test set-multiple -1 EMMATCH
set /augeas/version/save/mode value
test set-args -1 ECMDRUN
set /files
#
# test set/get parsing with quoting, whitespace and escaping
#
test set-single-quotes 2
set /files 'a test value'
get /files
prints
/files = a test value
test set-double-quotes 2
set /files "a test value"
get /files
prints
/files = a test value
test set-mixed-quotes1 2
set /files "a 'mixed quotes' test"
get /files
prints
/files = a 'mixed quotes' test
test set-mixed-quotes2 2
set /files 'a "mixed quotes" test'
get /files
prints
/files = a "mixed quotes" test
test set-escaped-quotes 2
set /files "''\"''"
get /files
prints
/files = ''"''
test set-escaped-path 2
set /white\ space\ tab value
get /white\ space\ tab
prints
/white space tab = value
test set-escaped-path-bracket 2
set /white\ space/\[section value
print /white\ space/\[section
prints
/white space/[section = "value"
test set-squote-escaped-bracket 2
set '/augeas/\[section' value
print '/augeas/\[section'
prints
/augeas/[section = "value"
test set-squote-escaped-path 2
set '/white\ space' value
get '/white\ space'
prints
/white\ space = value
test set-dquote-escaped-path 2
set "/white\ space" value
get "/white\ space"
prints
/white\ space = value
#
# test clear
#
test clear-not-there 2
clear /foo
get /foo
prints
/foo (none)
test clear-existing 2
clear /files
get /files
prints
/files (none)
test clear-bad-pathx -1 EPATHX
clear /files[]
test clear-multiple -1 EMMATCH
clear /augeas/version/save/mode
test clear-args -1 ECMDRUN
clear /files value
#
# test get
#
test get-save-mode 1
get /augeas/version/save/mode[1]
prints
/augeas/version/save/mode[1] = backup
test get-too-many -1 EMMATCH
get /augeas/*
test get-not-there 1
get /not-there
prints
/not-there (o)
test get-bad-pathx -1 EPATHX
get /files[]
#
# test print
#
test print-save 1
print /augeas/version/save
prints
/augeas/version/save
/augeas/version/save/mode[1] = "backup"
/augeas/version/save/mode[2] = "newfile"
/augeas/version/save/mode[3] = "noop"
/augeas/version/save/mode[4] = "overwrite"
test print-root 1
print /
|