Imported Upstream version 3.3.2
[debian/amanda] / common-src / match-test.c
index 63717385b68aef34bb19ec6b0931c6f9c5b3d325..30f21b2623b2e539f7d0d6d9ddac5a34adef526a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010 Zmanda, Inc.  All Rights Reserved.
+ * Copyright (c) 2010-2012 Zmanda, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 as published
@@ -26,7 +26,7 @@
  * Tests
  */
 
-static int
+static gboolean
 test_validate_regexp(void)
 {
     gboolean ok = TRUE;
@@ -59,7 +59,7 @@ test_validate_regexp(void)
     return ok;
 }
 
-static int
+static gboolean
 test_match(void)
 {
     gboolean ok = TRUE;
@@ -184,7 +184,7 @@ test_match(void)
     return ok;
 }
 
-static int
+static gboolean
 test_validate_glob(void)
 {
     gboolean ok = TRUE;
@@ -224,7 +224,7 @@ test_validate_glob(void)
     return ok;
 }
 
-static int
+static gboolean
 test_glob_to_regex(void)
 {
     gboolean ok = TRUE;
@@ -253,7 +253,7 @@ test_glob_to_regex(void)
     return ok;
 }
 
-static int
+static gboolean
 test_match_glob(void)
 {
     gboolean ok = TRUE;
@@ -325,7 +325,7 @@ test_match_glob(void)
     return ok;
 }
 
-static int
+static gboolean
 test_match_tar(void)
 {
     gboolean ok = TRUE;
@@ -442,7 +442,7 @@ test_match_tar(void)
     return ok;
 }
 
-static int
+static gboolean
 test_make_exact_host_expression(void)
 {
     gboolean ok = TRUE;
@@ -493,7 +493,7 @@ test_make_exact_host_expression(void)
     return ok;
 }
 
-static int
+static gboolean
 test_match_host(void)
 {
     gboolean ok = TRUE;
@@ -605,7 +605,7 @@ test_match_host(void)
     return ok;
 }
 
-static int
+static gboolean
 test_make_exact_disk_expression(void)
 {
     gboolean ok = TRUE;
@@ -649,7 +649,7 @@ test_make_exact_disk_expression(void)
     return ok;
 }
 
-static int
+static gboolean
 test_match_disk(void)
 {
     gboolean ok = TRUE;
@@ -706,8 +706,10 @@ test_match_disk(void)
        { "\\\\\\\\windows\\\\share", "\\\\windows\\share", TRUE },
 
        /* other expressions */
-       { "^local", "/local", TRUE },
-       { "^local", "/local/vore", TRUE },
+       { "^local", "/local", FALSE },
+       { "^/local", "/local", TRUE },
+       { "^local", "/local/vore", FALSE },
+       { "^/local", "/local/vore", TRUE },
        { "^local", "/usr/local", FALSE },
 
        { "local/bin", "/local/bin", TRUE },
@@ -740,7 +742,41 @@ test_match_disk(void)
        { "/usr\\/bin", "/usr/bin", TRUE },
        { "^/usr\\/bin$", "/usr/bin", TRUE },
        { "\\/usr\\/bin", "/usr/bin", FALSE },
-       { "^\\/usr\\/bin$", "/usr/bin", FALSE },
+       { "^\\/usr\\/bin$", "/usr/bin", TRUE },
+       { "/usr\\/bin\\/", "/usr/bin/", TRUE },
+       { "^/usr\\/bin\\/$", "/usr/bin/", TRUE },
+       { "\\/usr\\/bin\\/", "/usr/bin/", FALSE },
+       { "^\\/usr\\/bin\\/$", "/usr/bin/", TRUE },
+
+       { "oracle", "oracle", TRUE },
+       { "oracle", "/oracle", TRUE },
+       { "oracle", "oracle/", TRUE },
+       { "oracle", "/oracle/", TRUE },
+       { "/oracle", "oracle", TRUE },
+       { "/oracle", "/oracle", TRUE },
+       { "/oracle", "oracle/", TRUE },
+       { "/oracle", "/oracle/", TRUE },
+       { "^oracle", "oracle", TRUE },
+       { "^oracle", "/oracle", FALSE },
+       { "^oracle", "oracle/", TRUE },
+       { "^oracle", "/oracle/", FALSE },
+       { "^/oracle", "oracle", FALSE },
+       { "^/oracle", "/oracle", TRUE },
+       { "^/oracle", "oracle/", FALSE },
+       { "^/oracle", "/oracle/", TRUE },
+
+       { "oracle", "oracle", TRUE },
+       { "oracle", "/oracle", TRUE },
+       { "oracle", "oracle/", TRUE },
+       { "oracle", "/oracle/", TRUE },
+       { "oracle$", "oracle", TRUE },
+       { "oracle$", "/oracle", TRUE },
+       { "oracle$", "oracle/", FALSE },
+       { "oracle$", "/oracle/", FALSE },
+       { "oracle/$", "oracle", FALSE },
+       { "oracle/$", "/oracle", FALSE },
+       { "oracle/$", "oracle/", TRUE },
+       { "oracle/$", "/oracle/", TRUE },
 
        { NULL, NULL, FALSE },
     }, *t;
@@ -762,7 +798,7 @@ test_match_disk(void)
     return ok;
 }
 
-static int
+static gboolean
 test_match_datestamp(void)
 {
     gboolean ok = TRUE;
@@ -846,7 +882,7 @@ test_match_datestamp(void)
     return ok;
 }
 
-static int
+static gboolean
 test_match_level(void)
 {
     gboolean ok = TRUE;