[augeas-devel] augeas: master - More xpath tests; allow ... in tests

David Lutterkort lutter at fedoraproject.org
Sat Jan 31 00:57:44 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=6bdc40a07280736c11ccaf4a99f7db514f3bd8cc
Commit:        6bdc40a07280736c11ccaf4a99f7db514f3bd8cc
Parent:        a37e2a599d1f1b14f8891a3e13c648cd78eddf77
Author:        David Lutterkort <lutter at redhat.com>
AuthorDate:    Sat Jan 10 22:53:25 2009 -0800
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Fri Jan 30 16:54:44 2009 -0800

More xpath tests; allow ... in tests

---
 tests/test-xpath.c |    8 +++++---
 tests/xpath.tests  |   41 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/tests/test-xpath.c b/tests/test-xpath.c
index 0293a31..25ce47d 100644
--- a/tests/test-xpath.c
+++ b/tests/test-xpath.c
@@ -153,9 +153,11 @@ static int run_one_test(struct augeas *aug, struct test *t) {
         for (e = t->entries, i = 0; e != NULL; e = e->next, i++) {
             if (!STREQ(e->path, matches[i]))
                 result = -1;
-            aug_get(aug, e->path, &val);
-            if (!streqv(e->value, val))
-                result = -1;
+            if (! streqv(e->value, "...")) {
+                aug_get(aug, e->path, &val);
+                if (!streqv(e->value, val))
+                    result = -1;
+            }
         }
     }
     if (result == 0) {
diff --git a/tests/xpath.tests b/tests/xpath.tests
index 1eda449..6af4c41 100644
--- a/tests/xpath.tests
+++ b/tests/xpath.tests
@@ -8,7 +8,8 @@
 # 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
+# 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
@@ -97,3 +98,41 @@ 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]
+     /augeas/files/etc/sysconfig/kudzu/path = /files/etc/sysconfig/kudzu
+     /augeas/files/etc/sysconfig/kudzu/lens
+     /augeas/files/etc/sysconfig/kudzu/lens/info = ...
+     /augeas/files/etc/sysconfig/kudzu/lens/id = ...
+     /files/etc/sysconfig/kudzu/SAFE = no




More information about the augeas-devel mailing list