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
|
# Tests of the XPath matching
# Blank lines and lines starting with '#' are ignored
#
# Each test consists of one line declaring the test followed by a complete
# list of the expected result of the match.
#
# The test is declared with a line 'test NAME MATCH'. A result is either
# just a path (meaning that the value associated with that node must be
# NULL) or of the form PATH = VALUE, meaning that the value for the node at
# PATH must be VALUE. If VALUE is '...', the test does not check the value
# associated with PATH in the tree.
#
# The MATCH XPath expression is matched against a fixed tree (the one from the
# root/ subdirectory) and the result of the aug_match is compared with the
# results listed in the test
#
# The test framework sets up variables:
# hosts /files/etc/hosts/*
# localhost '127.0.0.1'
# php /files/etc/php.ini
# Very simple to warm up
test wildcard /files/etc/hosts/*/ipaddr
/files/etc/hosts/1/ipaddr = 127.0.0.1
/files/etc/hosts/2/ipaddr = 172.31.122.14
test wildcard-var $hosts/ipaddr
/files/etc/hosts/1/ipaddr = 127.0.0.1
/files/etc/hosts/2/ipaddr = 172.31.122.14
# Compare the value of the current node with a constant
test self-value /files/etc/hosts/*/ipaddr[ . = '127.0.0.1' ]
/files/etc/hosts/1/ipaddr = 127.0.0.1
test self-value-var $hosts/ipaddr[ . = $localhost ]
/files/etc/hosts/1/ipaddr = 127.0.0.1
# Find nodes that have a child named 'ipaddr' with a fixed value
test child-value /files/etc/hosts/*[ipaddr = '127.0.0.1']
/files/etc/hosts/1
test child-value-var $hosts[ipaddr = $localhost]
/files/etc/hosts/1
# Find nodes that have a child 'ipaddr' that has no value
test child-nil-value /files/etc/hosts/*[ipaddr = '']
test child-nil-value-var $hosts[ipaddr = '']
# Find nodes that have no value
test self-nil-value /files/etc/hosts/*[. = '']
/files/etc/hosts/1
/files/etc/hosts/2
test self-nil-value-var $hosts[. = '']
/files/etc/hosts/1
/files/etc/hosts/2
# Match over two levels of the tree
test two-wildcards /files/etc/*/*[ipaddr='127.0.0.1']
/files/etc/hosts/1
test pam-system-auth /files/etc/pam.d/*/*[module = 'system-auth']
/files/etc/pam.d/login/2
/files/etc/pam.d/login/4
/files/etc/pam.d/login/5
/files/etc/pam.d/login/8
/files/etc/pam.d/postgresql/1
/files/etc/pam.d/postgresql/2
/files/etc/pam.d/newrole/1
/files/etc/pam.d/newrole/2
/files/etc/pam.d/newrole/3
# Multiple predicates are treated with 'and'
test pam-two-preds /files/etc/pam.d/*/*[module = 'system-auth'][type = 'account']
/files/etc/pam.d/login/4
/files/etc/pam.d/postgresql/2
/files/etc/pam.d/newrole/2
# Find nodes that have siblings with a given value
test pam-two-preds-control /files/etc/pam.d/*/*[module = 'system-auth'][type = 'account']/control
/files/etc/pam.d/login/4/control = include
/files/etc/pam.d/postgresql/2/control = include
/files/etc/pam.d/newrole/2/control = include
# last() gives the last node with a certain name
test last /files/etc/hosts/*[ipaddr = "127.0.0.1"]/alias[last()]
/files/etc/hosts/1/alias[3] = galia
test last-var $hosts[ipaddr = $localhost]/alias[last()]
/files/etc/hosts/1/alias[3] = galia
# We can get nodes counting from the right with 'last()-N'
test last-minus-one /files/etc/hosts/*[ipaddr = "127.0.0.1"]/alias[ last() - 1 ]
/files/etc/hosts/1/alias[2] = galia.watzmann.net
# Make sure we look at all nodes with a given label (ticket #23)
test transparent-multi-node /files/etc/ssh/sshd_config/AcceptEnv/10
/files/etc/ssh/sshd_config/AcceptEnv[2]/10 = LC_ADDRESS
test abbrev-descendants /files/etc/pam.d//1
/files/etc/pam.d/login/1
/files/etc/pam.d/postgresql/1
/files/etc/pam.d/newrole/1
test descendant-or-self /files/descendant-or-self :: 4
/files/etc/ssh/sshd_config/AcceptEnv[1]/4 = LC_TIME
/files/etc/aliases/4
/files/etc/fstab/4
/files/etc/pam.d/login/4
/files/etc/pam.d/newrole/4
/files/etc/inittab/4
test descendant /files/etc/aliases/4/descendant::4
test descendant-or-self-2 /files/etc/aliases/4/descendant-or-self::4
/files/etc/aliases/4
# No matches because the predicate asks if there is a toplevel node
# 'ipaddr' with the given value
test abs-locpath /files/etc/hosts/*[/ipaddr = '127.0.0.1']/canonical
test rel-pred /files/etc/hosts/*/canonical[../ipaddr = '127.0.0.1']
/files/etc/hosts/1/canonical = localhost.localdomain
# Not the best way to write this, but entirely acceptable
test path-with-parent /files/etc/hosts/*/canonical[../ipaddr = '127.0.0.1']/../alias
/files/etc/hosts/1/alias[1] = localhost
/files/etc/hosts/1/alias[2] = galia.watzmann.net
/files/etc/hosts/1/alias[3] = galia
test node-exists-pred /files/etc/hosts/*/canonical[../alias]
/files/etc/hosts/1/canonical = localhost.localdomain
/files/etc/hosts/2/canonical = orange.watzmann.net
test ipaddr-child //*[ipaddr]
/files/etc/hosts/1
/files/etc/hosts/2
test ipaddr-sibling //*[../ipaddr]
/files/etc/hosts/1/ipaddr = 127.0.0.1
/files/etc/hosts/1/canonical = localhost.localdomain
/files/etc/hosts/1/alias[1] = localhost
/files/etc/hosts/1/alias[2] = galia.watzmann.net
/files/etc/hosts/1/alias[3] = galia
/files/etc/hosts/2/ipaddr = 172.31.122.14
/files/etc/hosts/2/canonical = orange.watzmann.net
/files/etc/hosts/2/alias = orange
test lircd-ancestor //*[ancestor::kudzu][label() != '#comment']
/augeas/files/etc/sysconfig/kudzu/path = /files/etc/sysconfig/kudzu
/augeas/files/etc/sysconfig/kudzu/mtime = ...
/augeas/files/etc/sysconfig/kudzu/lens = @Shellvars
/augeas/files/etc/sysconfig/kudzu/lens/info = ...
/files/etc/sysconfig/kudzu/SAFE = no
test wildcard-last /files/etc/hosts/*[position() = last()]
/files/etc/hosts/2
test wildcard-not-last /files/etc/hosts/*[position() != last()][ipaddr]
/files/etc/hosts/1
test nodeset-nodeset-eq /files/etc/sysconfig/network-scripts/*[BRIDGE = /files/etc/sysconfig/network-scripts/ifcfg-br0/DEVICE]
/files/etc/sysconfig/network-scripts/ifcfg-eth0
test last-ssh-service /files/etc/services/service-name[port = '22'][last()]
/files/etc/services/service-name[24] = ssh
test count-one-alias /files/etc/hosts/*[count(alias) = 1]
/files/etc/hosts/2
test number-gt /files/etc/hosts/*[count(alias) > 1]
/files/etc/hosts/1
test pred-or /files/etc/hosts/*[canonical = 'localhost' or alias = 'localhost']
/files/etc/hosts/1
test pred-and-or /files/etc/hosts/*[(canonical = 'localhost' or alias = 'localhost') and ipaddr = '127.0.0.1']
/files/etc/hosts/1
# We used to parse this as '/files/etc/.' followed by garbage, that
# was silently ignored. This path must not match anything, instead of
# every child of /files/etc
test path-with-dot /files/etc/.notthere
test str-neq /files/etc/*['foo' != 'foo']
# label() returns the label of the context node as a string
test label-neq /files/etc/hosts/*[label() != '#comment']
/files/etc/hosts/1
/files/etc/hosts/2
# 'and' and 'or' need to coerce types to boolean
test coerce-or /files[/files/etc/hosts/*[ipaddr = '127.0.0.1'] or /files/etc/aliases/*[name = 'root'] ]
/files
test coerce-and-true /files['foo' and count(/files/etc/hosts/*) ]
/files
test coerce-and-false /files['' and count(/none) and /none]
test preceding-sibling /files/etc/hosts/*/preceding-sibling::*[alias = 'localhost']
/files/etc/hosts/1
test preceding-sibling-pred /files/etc/grub.conf/*[preceding-sibling::*[1] = ../default]
/files/etc/grub.conf/timeout = 5
test preceding-sibling-pred2 /files/etc/grub.conf/*[preceding-sibling::*[1][self::default]]
/files/etc/grub.conf/timeout = 5
test following-sibling /files/etc/hosts/1/*/following-sibling::alias
/files/etc/hosts/1/alias[1] = localhost
/files/etc/hosts/1/alias[2] = galia.watzmann.net
/files/etc/hosts/1/alias[3] = galia
test following-sibling-pred /files/etc/hosts/1/*[following-sibling::alias]
/files/etc/hosts/1/ipaddr = 127.0.0.1
/files/etc/hosts/1/canonical = localhost.localdomain
/files/etc/hosts/1/alias[1] = localhost
/files/etc/hosts/1/alias[2] = galia.watzmann.net
test regexp1 /files/etc/sysconfig/network-scripts/*[label() =~ regexp('.*-eth0')]
/files/etc/sysconfig/network-scripts/ifcfg-eth0
test regexp2 /files/etc/hosts/*[* =~ regexp('127\..*')]
/files/etc/hosts/1
test regexp3 /files/etc/hosts/*[ipaddr =~ regexp(/files/etc/hosts/*/ipaddr)]
/files/etc/hosts/1
/files/etc/hosts/2
# Check that we don't crash when the nodeset contains all NULL's
test regexp4 /files/etc/hosts/*[ipaddr =~ regexp(/files/etc/hosts/*[ipaddr])]
test glob1 /files[ 'axxa' =~ glob('a*a') ]
/files
test glob2 /files[ 'axxa' =~ glob('a?[a-z]a') ]
/files
test glob3 /files[ '^a' =~ glob('^a') ]
/files
test glob4 /augeas/load/*[ '/etc/hosts' =~ glob(incl) ]
/augeas/load/Hosts
test glob5 /files[ '/files/etc/hosts/1' =~ glob('/files/*/1') ]
test glob6 /files[ '/files/etc/hosts/1' =~ glob('/files/*/*/1') ]
/files
test glob_nomatch /files/etc/hosts/*[ipaddr][ ipaddr !~ glob(/files/etc/hosts/*/ipaddr[1]) ]
/files/etc/hosts/2
test glob_for_lens /augeas/load/*[ '/etc/hosts/1/ipaddr' =~ glob(incl) + regexp('/.*') ]/lens
/augeas/load/Hosts/lens = @Hosts
# Union of nodesets
test union (/files/etc/yum.conf | /files/etc/yum.repos.d/*)/*/gpgcheck
/files/etc/yum.conf/main/gpgcheck = 1
/files/etc/yum.repos.d/fedora-updates.repo/updates/gpgcheck = 1
/files/etc/yum.repos.d/fedora-updates.repo/updates-debuginfo/gpgcheck = 1
/files/etc/yum.repos.d/fedora-updates.repo/updates-source/gpgcheck = 1
/files/etc/yum.repos.d/fedora.repo/fedora/gpgcheck = 1
/files/etc/yum.repos.d/fedora.repo/fedora-debuginfo/gpgcheck = 1
/files/etc/yum.repos.d/fedora.repo/fedora-source/gpgcheck = 1
/files/etc/yum.repos.d/remi.repo/remi/gpgcheck = 1
/files/etc/yum.repos.d/remi.repo/remi-test/gpgcheck = 1
# Paths with whitespace in them
test php1 $php/mail function
/files/etc/php.ini/mail function
test php2 $php[mail function]
/files/etc/php.ini
test php3 $php[count(mail function) = 1]
/files/etc/php.ini
test php4 $php/mail function/SMTP
/files/etc/php.ini/mail function/SMTP = localhost
test php5 $php/mail\ function
/files/etc/php.ini/mail function
test expr-or /files/etc/group/root/*[self::gid or self::user]
/files/etc/group/root/gid = 0
/files/etc/group/root/user = root
test int-ns-eq /files/etc/group/*[int(gid) = 30]
/files/etc/group/gopher
test int-ns-lt /files/etc/group/*[int(gid) < 3]
/files/etc/group/root
/files/etc/group/bin
/files/etc/group/daemon
test int-bool-f /files[int(1 = 0) > 0]
test int-bool-t /files[int(1 = 1) > 0]
/files
# Relative paths, relying on default /files context
test ctx_file etc/network/interfaces
/files/etc/network/interfaces
test ctx_file_pred etc/network/interfaces/iface[. = "lo"]
/files/etc/network/interfaces/iface[1] = lo
|