[augeas-devel] [PATCH 5/5] Add tests for regexp builtin with flag

lutter at redhat.com lutter at redhat.com
Fri Nov 9 22:59:31 UTC 2012


From: Raphaël Pinson <raphael.pinson at camptocamp.com>

---
 tests/test-xpath.c |   18 ++++++++++++++++++
 tests/xpath.tests  |    8 ++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/tests/test-xpath.c b/tests/test-xpath.c
index 313c033..335e7bf 100644
--- a/tests/test-xpath.c
+++ b/tests/test-xpath.c
@@ -316,6 +316,21 @@ static int test_invalid_regexp(struct augeas *aug) {
     return -1;
 }
 
+static int test_wrong_regexp_flag(struct augeas *aug) {
+    int r;
+
+    printf("%-30s ... ", "wrong_regexp_flag");
+    r = aug_match(aug, "/files/*[ * =~ regexp('abc', 'o')]", NULL);
+    if (r >= 0)
+        goto fail;
+
+    printf("PASS\n");
+    return 0;
+ fail:
+    printf("FAIL\n");
+    return -1;
+}
+
 static int run_tests(struct test *tests, int argc, char **argv) {
     char *lensdir;
     struct augeas *aug = NULL;
@@ -356,6 +371,9 @@ static int run_tests(struct test *tests, int argc, char **argv) {
 
         if (test_invalid_regexp(aug) < 0)
             result = EXIT_FAILURE;
+
+        if (test_wrong_regexp_flag(aug) < 0)
+            result = EXIT_FAILURE;
     }
     aug_close(aug);
 
diff --git a/tests/xpath.tests b/tests/xpath.tests
index 742b9ff..41bb555 100644
--- a/tests/xpath.tests
+++ b/tests/xpath.tests
@@ -233,6 +233,14 @@ test regexp3 /files/etc/hosts/*[ipaddr =~ regexp(/files/etc/hosts/*/ipaddr)]
 # Check that we don't crash when the nodeset contains all NULL's
 test regexp4 /files/etc/hosts/*[ipaddr =~ regexp(/files/etc/hosts/*[ipaddr])]
 
+# Check case-insensitive matches
+test regexp5 /files/etc/sysconfig/network-scripts/*[label() =~ regexp('.*-ETH0', 'i')]
+     /files/etc/sysconfig/network-scripts/ifcfg-eth0
+
+test regexp6 /files/etc/hosts/*[ipaddr =~ regexp(/files/etc/hosts/*/ipaddr, 'i')]
+     /files/etc/hosts/1
+     /files/etc/hosts/2
+
 test glob1 /files[ 'axxa' =~ glob('a*a') ]
      /files
 
-- 
1.7.7.6




More information about the augeas-devel mailing list