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

Raphaël Pinson raphael.pinson at camptocamp.com
Wed Aug 1 07:33:28 UTC 2012


---
 tests/test-xpath.c |   18 ++++++++++++++++++
 tests/xpath.tests  |    4 ++++
 2 files changed, 22 insertions(+)

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..de2b483 100644
--- a/tests/xpath.tests
+++ b/tests/xpath.tests
@@ -233,6 +233,10 @@ 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 glob1 /files[ 'axxa' =~ glob('a*a') ]
      /files
 
-- 
1.7.9.5




More information about the augeas-devel mailing list