diff options
Diffstat (limited to 'regress')
-rw-r--r-- | regress/unittests/match/tests.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/regress/unittests/match/tests.c b/regress/unittests/match/tests.c index 44b89a586..e6eb4af26 100644 --- a/regress/unittests/match/tests.c +++ b/regress/unittests/match/tests.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tests.c,v 1.1 2016/08/19 06:44:13 djm Exp $ */ | 1 | /* $OpenBSD: tests.c,v 1.2 2016/08/23 08:17:04 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Regress test for matching functions | 3 | * Regress test for matching functions |
4 | * | 4 | * |
@@ -56,12 +56,16 @@ tests(void) | |||
56 | ASSERT_INT_EQ(match_pattern_list("a", "", 0), 0); | 56 | ASSERT_INT_EQ(match_pattern_list("a", "", 0), 0); |
57 | ASSERT_INT_EQ(match_pattern_list("a", "*", 0), 1); | 57 | ASSERT_INT_EQ(match_pattern_list("a", "*", 0), 1); |
58 | ASSERT_INT_EQ(match_pattern_list("a", "!*", 0), -1); | 58 | ASSERT_INT_EQ(match_pattern_list("a", "!*", 0), -1); |
59 | ASSERT_INT_EQ(match_pattern_list("a", "!a", 0), -1); | ||
60 | ASSERT_INT_EQ(match_pattern_list("a", "!b", 0), 1); | ||
59 | ASSERT_INT_EQ(match_pattern_list("a", "!a,*", 0), -1); | 61 | ASSERT_INT_EQ(match_pattern_list("a", "!a,*", 0), -1); |
60 | ASSERT_INT_EQ(match_pattern_list("b", "!a,*", 0), 1); | 62 | ASSERT_INT_EQ(match_pattern_list("b", "!a,*", 0), 1); |
61 | ASSERT_INT_EQ(match_pattern_list("a", "*,!a", 0), -1); | 63 | ASSERT_INT_EQ(match_pattern_list("a", "*,!a", 0), -1); |
62 | ASSERT_INT_EQ(match_pattern_list("b", "*,!a", 0), 1); | 64 | ASSERT_INT_EQ(match_pattern_list("b", "*,!a", 0), 1); |
63 | ASSERT_INT_EQ(match_pattern_list("a", "a,!*", 0), -1); | 65 | ASSERT_INT_EQ(match_pattern_list("a", "a,!*", 0), -1); |
64 | ASSERT_INT_EQ(match_pattern_list("b", "a,!*", 0), -1); | 66 | ASSERT_INT_EQ(match_pattern_list("b", "a,!*", 0), -1); |
67 | ASSERT_INT_EQ(match_pattern_list("a", "a,!a", 0), -1); | ||
68 | ASSERT_INT_EQ(match_pattern_list("b", "a,!a", 0), 1); | ||
65 | ASSERT_INT_EQ(match_pattern_list("a", "!*,a", 0), -1); | 69 | ASSERT_INT_EQ(match_pattern_list("a", "!*,a", 0), -1); |
66 | ASSERT_INT_EQ(match_pattern_list("b", "!*,a", 0), -1); | 70 | ASSERT_INT_EQ(match_pattern_list("b", "!*,a", 0), -1); |
67 | TEST_DONE(); | 71 | TEST_DONE(); |
@@ -73,14 +77,35 @@ tests(void) | |||
73 | ASSERT_INT_EQ(match_pattern_list("ABC", "abc", 1), 0); | 77 | ASSERT_INT_EQ(match_pattern_list("ABC", "abc", 1), 0); |
74 | TEST_DONE(); | 78 | TEST_DONE(); |
75 | 79 | ||
80 | TEST_START("addr_match_list"); | ||
81 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "127.0.0.1/44"), -2); | ||
82 | ASSERT_INT_EQ(addr_match_list(NULL, "127.0.0.1/44"), -2); | ||
83 | ASSERT_INT_EQ(addr_match_list("a", "*"), 0); | ||
84 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "*"), 1); | ||
85 | ASSERT_INT_EQ(addr_match_list(NULL, "*"), 0); | ||
86 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "127.0.0.1"), 1); | ||
87 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "127.0.0.2"), 0); | ||
88 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "!127.0.0.1"), -1); | ||
89 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "!127.0.0.2"), 1); | ||
90 | ASSERT_INT_EQ(addr_match_list("127.0.0.255", "127.0.0.0/24"), 1); | ||
91 | ASSERT_INT_EQ(addr_match_list("127.0.1.1", "127.0.0.0/24"), 0); | ||
92 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "127.0.0.0/24"), 1); | ||
93 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "127.0.1.0/24"), 0); | ||
94 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "!127.0.0.0/24"), -1); | ||
95 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "!127.0.1.0/24"), 1); | ||
96 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "10.0.0.1,!127.0.0.1"), -1); | ||
97 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "!127.0.0.1,10.0.0.1"), -1); | ||
98 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "10.0.0.1,127.0.0.2"), 0); | ||
99 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "127.0.0.2,10.0.0.1"), 0); | ||
100 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "10.0.0.1,!127.0.0.2"), 1); | ||
101 | ASSERT_INT_EQ(addr_match_list("127.0.0.1", "!127.0.0.2,10.0.0.1"), 1); | ||
102 | TEST_DONE(); | ||
103 | |||
76 | /* | 104 | /* |
77 | * XXX TODO | 105 | * XXX TODO |
78 | * int match_host_and_ip(const char *, const char *, const char *); | 106 | * int match_host_and_ip(const char *, const char *, const char *); |
79 | * int match_user(const char *, const char *, const char *, const char *); | 107 | * int match_user(const char *, const char *, const char *, const char *); |
80 | * char *match_list(const char *, const char *, u_int *); | 108 | * char *match_list(const char *, const char *, u_int *); |
81 | * int addr_match_list(const char *, const char *); | ||
82 | * int addr_match_cidr_list(const char *, const char *); | 109 | * int addr_match_cidr_list(const char *, const char *); |
83 | */ | 110 | */ |
84 | |||
85 | } | 111 | } |
86 | |||