diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libc/fnmatch/Makefile | 4 | ||||
| -rw-r--r-- | src/regress/lib/libc/fnmatch/fnm_test.c | 23 | ||||
| -rw-r--r-- | src/regress/lib/libc/fnmatch/fnm_test.in | 254 |
3 files changed, 277 insertions, 4 deletions
diff --git a/src/regress/lib/libc/fnmatch/Makefile b/src/regress/lib/libc/fnmatch/Makefile index b2f357105f..4acdd351bc 100644 --- a/src/regress/lib/libc/fnmatch/Makefile +++ b/src/regress/lib/libc/fnmatch/Makefile | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2008/10/01 23:04:58 millert Exp $ | 1 | # $OpenBSD: Makefile,v 1.2 2011/09/17 15:12:38 stsp Exp $ |
| 2 | 2 | ||
| 3 | PROG= fnm_test | 3 | PROG= fnm_test |
| 4 | LDADD+= -lutil | ||
| 5 | DPADD+= ${LIBUTIL} | ||
| 4 | 6 | ||
| 5 | run-regress-${PROG}: | 7 | run-regress-${PROG}: |
| 6 | ./${PROG} ${.CURDIR}/${PROG}.in | 8 | ./${PROG} ${.CURDIR}/${PROG}.in |
diff --git a/src/regress/lib/libc/fnmatch/fnm_test.c b/src/regress/lib/libc/fnmatch/fnm_test.c index e987010095..f5958837e2 100644 --- a/src/regress/lib/libc/fnmatch/fnm_test.c +++ b/src/regress/lib/libc/fnmatch/fnm_test.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: fnm_test.c,v 1.1 2008/10/01 23:04:58 millert Exp $ */ | 1 | /* $OpenBSD: fnm_test.c,v 1.2 2011/09/17 15:12:38 stsp Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Public domain, 2008, Todd C. Miller <Todd.Miller@courtesan.com> | 4 | * Public domain, 2008, Todd C. Miller <Todd.Miller@courtesan.com> |
| @@ -8,12 +8,15 @@ | |||
| 8 | #include <fnmatch.h> | 8 | #include <fnmatch.h> |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| 10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
| 11 | #include <util.h> | ||
| 11 | 12 | ||
| 12 | int | 13 | int |
| 13 | main(int argc, char **argv) | 14 | main(int argc, char **argv) |
| 14 | { | 15 | { |
| 15 | FILE *fp = stdin; | 16 | FILE *fp = stdin; |
| 16 | char pattern[1024], string[1024]; | 17 | char pattern[1024], string[1024]; |
| 18 | char *line; | ||
| 19 | const char delim[3] = {'\0', '\0', '#'}; | ||
| 17 | int errors = 0, flags, got, want; | 20 | int errors = 0, flags, got, want; |
| 18 | 21 | ||
| 19 | if (argc > 1) { | 22 | if (argc > 1) { |
| @@ -26,12 +29,22 @@ main(int argc, char **argv) | |||
| 26 | * | 29 | * |
| 27 | * pattern string flags expected_result | 30 | * pattern string flags expected_result |
| 28 | * | 31 | * |
| 32 | * lines starting with '#' are comments | ||
| 29 | */ | 33 | */ |
| 30 | for (;;) { | 34 | for (;;) { |
| 31 | got = fscanf(fp, "%s %s 0x%x %d\n", pattern, string, &flags, | 35 | line = fparseln(fp, NULL, NULL, delim, 0); |
| 36 | if (!line) | ||
| 37 | break; | ||
| 38 | got = sscanf(line, "%s %s 0x%x %d", pattern, string, &flags, | ||
| 32 | &want); | 39 | &want); |
| 33 | if (got == EOF) | 40 | if (got == EOF) { |
| 41 | free(line); | ||
| 34 | break; | 42 | break; |
| 43 | } | ||
| 44 | if (pattern[0] == '#') { | ||
| 45 | free(line); | ||
| 46 | continue; | ||
| 47 | } | ||
| 35 | if (got == 4) { | 48 | if (got == 4) { |
| 36 | got = fnmatch(pattern, string, flags); | 49 | got = fnmatch(pattern, string, flags); |
| 37 | if (got != want) { | 50 | if (got != want) { |
| @@ -39,7 +52,11 @@ main(int argc, char **argv) | |||
| 39 | string, flags, want, got); | 52 | string, flags, want, got); |
| 40 | errors++; | 53 | errors++; |
| 41 | } | 54 | } |
| 55 | } else { | ||
| 56 | warnx("unrecognized line '%s'\n", line); | ||
| 57 | errors++; | ||
| 42 | } | 58 | } |
| 59 | free(line); | ||
| 43 | } | 60 | } |
| 44 | exit(errors); | 61 | exit(errors); |
| 45 | } | 62 | } |
diff --git a/src/regress/lib/libc/fnmatch/fnm_test.in b/src/regress/lib/libc/fnmatch/fnm_test.in index 3c707f8a19..c20077966d 100644 --- a/src/regress/lib/libc/fnmatch/fnm_test.in +++ b/src/regress/lib/libc/fnmatch/fnm_test.in | |||
| @@ -3,3 +3,257 @@ | |||
| 3 | /bin/[[:opper:][:alnum:]]* /bin/ls 0x0 1 | 3 | /bin/[[:opper:][:alnum:]]* /bin/ls 0x0 1 |
| 4 | [[:alpha:][:alnum:]]*.c foo1.c 0x4 0 | 4 | [[:alpha:][:alnum:]]*.c foo1.c 0x4 0 |
| 5 | [[:upper:]]* FOO 0x0 0 | 5 | [[:upper:]]* FOO 0x0 0 |
| 6 | # 'te\st' 'test'; no match if FNM_NOESCAPE | ||
| 7 | te\st test 0x0 0 | ||
| 8 | te\st test 0x1 1 | ||
| 9 | te\st test 0x1e 0 | ||
| 10 | # 'te\\st' 'te\st'; no match if FNM_NOESCAPE | ||
| 11 | te\\st te\st 0x0 0 | ||
| 12 | te\\st te\st 0x1 1 | ||
| 13 | te\\st te\st 0x1e 0 | ||
| 14 | # 'te\*t' 'te*t'; no match if FNM_NOESCAPE | ||
| 15 | te\*t te*t 0x0 0 | ||
| 16 | te\*t te*t 0x1 1 | ||
| 17 | te\*t te*t 0x1e 0 | ||
| 18 | # 'te\*t' 'test'; no match | ||
| 19 | te\*t test 0x0 1 | ||
| 20 | te\*t test 0x1f 1 | ||
| 21 | # 'te\?t' 'te?t'; no match if FNM_NOESCAPE | ||
| 22 | te\?t te?t 0x0 0 | ||
| 23 | te\?t te?t 0x1 1 | ||
| 24 | te\?t te?t 0x1e 0 | ||
| 25 | # 'te\?t' 'test'; no match | ||
| 26 | te\?t test 0x0 1 | ||
| 27 | te\?t test 0x1f 1 | ||
| 28 | # 'tesT' 'test'; match if FNM_CASEFOLD | ||
| 29 | tesT test 0x0 1 | ||
| 30 | tesT test 0xf 1 | ||
| 31 | tesT test 0x10 0 | ||
| 32 | # 'test' 'Test'; match if FNM_CASEFOLD | ||
| 33 | test Test 0x0 1 | ||
| 34 | test Test 0xf 1 | ||
| 35 | test Test 0x10 0 | ||
| 36 | # 'tEst' 'teSt'; match if FNM_CASEFOLD | ||
| 37 | tEst teSt 0x0 1 | ||
| 38 | tEst teSt 0xf 1 | ||
| 39 | tEst teSt 0x10 0 | ||
| 40 | # '?est' 'test'; match always | ||
| 41 | ?est test 0x0 0 | ||
| 42 | ?est test 0x1f 0 | ||
| 43 | # 'te?t' 'test'; match always | ||
| 44 | te?t test 0x0 0 | ||
| 45 | te?t test 0x1f 0 | ||
| 46 | # 'tes?' 'test'; match always | ||
| 47 | tes? test 0x0 0 | ||
| 48 | tes? test 0x1f 0 | ||
| 49 | # 'test?' 'test'; no match | ||
| 50 | test? test 0x0 1 | ||
| 51 | test? test 0x1f 1 | ||
| 52 | # '*' always matches anything | ||
| 53 | * test 0x0 0 | ||
| 54 | * test 0x1f 0 | ||
| 55 | # '*test' 'test'; match always | ||
| 56 | *test test 0x0 0 | ||
| 57 | *test test 0x1f 0 | ||
| 58 | # '*est' 'test'; match always | ||
| 59 | *est test 0x0 0 | ||
| 60 | *est test 0x1f 0 | ||
| 61 | # '*st' 'test'; match always | ||
| 62 | *st test 0x0 0 | ||
| 63 | *st test 0x1f 0 | ||
| 64 | # 't*t' 'test'; match always | ||
| 65 | t*t test 0x0 0 | ||
| 66 | t*t test 0x1f 0 | ||
| 67 | # 'te*t' 'test'; match always | ||
| 68 | te*t test 0x0 0 | ||
| 69 | te*t test 0x1f 0 | ||
| 70 | # 'te*st' 'test'; match always | ||
| 71 | te*st test 0x0 0 | ||
| 72 | te*st test 0x1f 0 | ||
| 73 | # 'te*' 'test'; match always | ||
| 74 | te* test 0x0 0 | ||
| 75 | te* test 0x1f 0 | ||
| 76 | # 'tes*' 'test'; match always | ||
| 77 | tes* test 0x0 0 | ||
| 78 | tes* test 0x1f 0 | ||
| 79 | # 'test*' 'test'; match always | ||
| 80 | test* test 0x0 0 | ||
| 81 | test* test 0x1f 0 | ||
| 82 | # '.[\-\t]' '.t'; match always | ||
| 83 | .[\-\t] .t 0x0 0 | ||
| 84 | .[\-\t] .t 0x1f 0 | ||
| 85 | # 'test*?*[a-z]*' 'testgoop'; match always | ||
| 86 | test*?*[a-z]* testgoop 0x0 0 | ||
| 87 | test*?*[a-z]* testgoop 0x1f 0 | ||
| 88 | # 'te[^abc]t' 'test'; match always | ||
| 89 | te[^abc]t test 0x0 0 | ||
| 90 | te[^abc]t test 0x1f 0 | ||
| 91 | # 'te[^x]t' 'test'; match always | ||
| 92 | te[^x]t test 0x0 0 | ||
| 93 | te[^x]t test 0x1f 0 | ||
| 94 | # 'te[!x]t' 'test'; match always | ||
| 95 | te[!x]t test 0x0 0 | ||
| 96 | te[^x]t test 0x1f 0 | ||
| 97 | # 'te[^x]t' 'text'; no match | ||
| 98 | te[^x]t text 0x0 1 | ||
| 99 | te[^x]t text 0x1f 1 | ||
| 100 | # 'te[^\x]t' 'text'; no match | ||
| 101 | te[^\x]t text 0x0 1 | ||
| 102 | te[^\x]t text 0x1f 1 | ||
| 103 | # 'te[^\x' 'text'; no match | ||
| 104 | te[^\x text 0x0 1 | ||
| 105 | te[^\x text 0x1f 1 | ||
| 106 | # 'te[/]t' 'text'; no match | ||
| 107 | te[/]t text 0x0 1 | ||
| 108 | te[/]t text 0x1f 1 | ||
| 109 | # 'te[S]t' 'test'; match if FNM_CASEFOLD | ||
| 110 | te[S]t test 0x0 1 | ||
| 111 | te[S]t test 0xf 1 | ||
| 112 | te[S]t test 0x10 0 | ||
| 113 | # 'te[r-t]t' 'test'; match always | ||
| 114 | te[r-t]t test 0x0 0 | ||
| 115 | te[r-t]t test 0x1f 0 | ||
| 116 | # 'te[r-t]t' 'teSt'; match if FNM_CASEFOLD | ||
| 117 | te[r-t]t teSt 0x0 1 | ||
| 118 | te[r-t]t teSt 0xf 1 | ||
| 119 | te[r-t]t teSt 0x10 0 | ||
| 120 | # 'te[r-T]t' 'test'; match if FNM_CASEFOLD | ||
| 121 | te[r-T]t test 0x0 1 | ||
| 122 | te[r-T]t test 0xf 1 | ||
| 123 | te[r-T]t test 0x10 0 | ||
| 124 | # 'te[R-T]t' 'test'; match if FNM_CASEFOLD | ||
| 125 | te[R-T]t test 0x0 1 | ||
| 126 | te[R-T]t test 0xf 1 | ||
| 127 | te[R-T]t test 0x10 0 | ||
| 128 | # 'te[r-Tz]t' 'tezt'; match always | ||
| 129 | te[r-Tz]t tezt 0x0 0 | ||
| 130 | te[r-Tz]t tezt 0x1f 0 | ||
| 131 | # 'te[R-T]t' 'tent'; no match | ||
| 132 | te[R-T]t tent 0x0 1 | ||
| 133 | te[R-T]t tent 0x1f 1 | ||
| 134 | # 'tes[]t]' 'test'; match always | ||
| 135 | tes[]t] test 0x0 0 | ||
| 136 | tes[]t] test 0x1f 0 | ||
| 137 | # 'tes[t-]' 'test'; match always | ||
| 138 | tes[t-] test 0x0 0 | ||
| 139 | tes[t-] test 0x1f 0 | ||
| 140 | # 'tes[t-]]' 'test]'; match always | ||
| 141 | tes[t-]] test] 0x0 0 | ||
| 142 | tes[t-]] test] 0x1f 0 | ||
| 143 | # 'tes[t-]]' 'test'; no match | ||
| 144 | tes[t-]] test 0x0 1 | ||
| 145 | tes[t-]] test 0x1f 1 | ||
| 146 | # 'tes[u-]' 'test'; no match | ||
| 147 | tes[u-] test 0x0 1 | ||
| 148 | tes[u-] test 0x1f 1 | ||
| 149 | # 'tes[t-]' 'tes[t-]'; no match | ||
| 150 | tes[t-] test[t-] 0x0 1 | ||
| 151 | tes[t-] test[t-] 0x1f 1 | ||
| 152 | # 'test[/-/]' 'test[/-/]'; no match | ||
| 153 | test[/-/] test/-/ 0x0 1 | ||
| 154 | test[/-/] test/-/ 0x1f 1 | ||
| 155 | # 'test[\/-/]' 'test[/-/]'; no match | ||
| 156 | test[\/-/] test/-/ 0x0 1 | ||
| 157 | test[\/-/] test/-/ 0x1f 1 | ||
| 158 | # 'test[/-\/]' 'test[/-/]'; no match | ||
| 159 | test[/-\/] test/-/ 0x0 1 | ||
| 160 | test[/-\/] test/-/ 0x1f 1 | ||
| 161 | # 'test[/-/]' 'test/'; no match if APR_FNM_PATHNAME | ||
| 162 | test[/-/] test/ 0x0 0 | ||
| 163 | test[/-/] test/ 0x2 1 | ||
| 164 | test[/-/] test/ 0x1d 0 | ||
| 165 | # 'test[\/-/]' 'test/'; no match if APR_FNM_PATHNAME | ||
| 166 | test[\/-/] test/ 0x0 0 | ||
| 167 | test[\/-/] test/ 0x2 1 | ||
| 168 | test[\/-/] test/ 0x1d 0 | ||
| 169 | # 'test[/-\/]' 'test/'; no match if APR_FNM_PATHNAME | ||
| 170 | test[/-\/] test/ 0x0 0 | ||
| 171 | test[/-\/] test/ 0x2 1 | ||
| 172 | test[/-\/] test/ 0x1d 0 | ||
| 173 | # '/test' 'test'; no match | ||
| 174 | /test test 0x0 1 | ||
| 175 | /test test 0x1f 1 | ||
| 176 | # 'test' '/test'; no match | ||
| 177 | test /test 0x0 1 | ||
| 178 | test /test 0x1f 1 | ||
| 179 | # 'test/' 'test'; no match | ||
| 180 | test/ test 0x0 1 | ||
| 181 | test/ test 0x1f 1 | ||
| 182 | # 'test' 'test/'; match if FNM_LEADING_DIR | ||
| 183 | test test/ 0x0 1 | ||
| 184 | test test/ 0x17 1 | ||
| 185 | test test/ 0x8 0 | ||
| 186 | # '\/test' '/test'; match unless FNM_NOESCAPE | ||
| 187 | \/test /test 0x0 0 | ||
| 188 | \/test /test 0x1 1 | ||
| 189 | \/test /test 0x1e 0 | ||
| 190 | # '*test' '/test'; match unless FNM_PATHNAME | ||
| 191 | *test /test 0x0 0 | ||
| 192 | *test /test 0x2 1 | ||
| 193 | *test /test 0x1d 0 | ||
| 194 | # '/*/test' '/test'; no match | ||
| 195 | /*/test /test 0x0 1 | ||
| 196 | /*/test /test 0x1f 1 | ||
| 197 | # '/*/test' '/test/test'; match always | ||
| 198 | /*/test /test/test 0x0 0 | ||
| 199 | /*/test /test/test 0x1f 0 | ||
| 200 | # 'test/this' 'test/'; match never | ||
| 201 | test/this test/ 0x0 1 | ||
| 202 | test/this test/ 0x1f 1 | ||
| 203 | # 'test/' 'test/this'; match never | ||
| 204 | test/ test/this 0x0 1 | ||
| 205 | test/ test/this 0x1f 1 | ||
| 206 | # 'test*/this' 'test/this'; match always | ||
| 207 | test*/this test/this 0x0 0 | ||
| 208 | test*/this test/this 0x1f 0 | ||
| 209 | # 'test*/this' 'test/that'; match never | ||
| 210 | test*/this test/that 0x0 1 | ||
| 211 | test*/this test/that 0x1f 1 | ||
| 212 | # 'test/*this' 'test/this'; match always | ||
| 213 | test/*this test/this 0x0 0 | ||
| 214 | test/*this test/this 0x1f 0 | ||
| 215 | # '.*' '.this'; match always | ||
| 216 | .* .this 0x0 0 | ||
| 217 | .* .this 0x1f 0 | ||
| 218 | # '*' '.this'; fails if FNM_PERIOD | ||
| 219 | * .this 0x0 0 | ||
| 220 | * .this 0x4 1 | ||
| 221 | * .this 0x1b 0 | ||
| 222 | # '?this' '.this'; fails if FNM_PERIOD | ||
| 223 | ?this .this 0x0 0 | ||
| 224 | ?this .this 0x4 1 | ||
| 225 | ?this .this 0x1b 0 | ||
| 226 | # '[.]this' '.this'; fails if FNM_PERIOD | ||
| 227 | [.]this .this 0x0 0 | ||
| 228 | [.]this .this 0x4 1 | ||
| 229 | [.]this .this 0x1b 0 | ||
| 230 | # 'test/this' 'test/this'; match always | ||
| 231 | test/this test/this 0x0 0 | ||
| 232 | test/this test/this 0x1f 0 | ||
| 233 | # 'test?this' 'test/this'; fails if FNM_PATHNAME | ||
| 234 | test?this test/this 0x0 0 | ||
| 235 | test?this test/this 0x2 1 | ||
| 236 | test?this test/this 0x1d 0 | ||
| 237 | # 'test*this' 'test/this'; fails if FNM_PATHNAME | ||
| 238 | test*this test/this 0x0 0 | ||
| 239 | test*this test/this 0x2 1 | ||
| 240 | test*this test/this 0x1d 0 | ||
| 241 | # 'test[/]this' 'test/this'; fails if FNM_PATHNAME | ||
| 242 | test[/]this test/this 0x0 0 | ||
| 243 | test[/]this test/this 0x2 1 | ||
| 244 | test[/]this test/this 0x1d 0 | ||
| 245 | # 'test/.*' 'test/.this'; match always | ||
| 246 | test/.* test/.this 0x0 0 | ||
| 247 | test/.* test/.this 0x1f 0 | ||
| 248 | # 'test/*' 'test/.this'; fails if FNM_PERIOD and FNM_PATHNAME | ||
| 249 | test/* test/.this 0x0 0 | ||
| 250 | test/* test/.this 0x6 1 | ||
| 251 | test/* test/.this 0x19 0 | ||
| 252 | # 'test/?' 'test/.this'; fails if FNM_PERIOD and FNM_PATHNAME | ||
| 253 | test/?this test/.this 0x0 0 | ||
| 254 | test/?this test/.this 0x6 1 | ||
| 255 | test/?this test/.this 0x19 0 | ||
| 256 | # 'test/[.]this' 'test/.this'; fails if FNM_PERIOD and FNM_PATHNAME | ||
| 257 | test/[.]this test/.this 0x0 0 | ||
| 258 | test/[.]this test/.this 0x6 1 | ||
| 259 | test/[.]this test/.this 0x19 0 | ||
