diff options
Diffstat (limited to 'posix')
-rw-r--r-- | posix/Makefile | 12 | ||||
-rw-r--r-- | posix/PTESTS | 309 | ||||
-rw-r--r-- | posix/PTESTS2C.sed | 4 | ||||
-rw-r--r-- | posix/runptests.c | 117 |
4 files changed, 440 insertions, 2 deletions
diff --git a/posix/Makefile b/posix/Makefile index 069a470..20c1c2b 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -29,6 +29,7 @@ headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \ bits/sched.h re_comp.h wait.h bits/environments.h cpio.h distribute := confstr.h TESTS TESTS2C.sed testcases.h \ + PTESTS PTESTS2C.sed ptestcases.h \ globtest.c globtest.sh wordexp-tst.sh routines := \ @@ -52,14 +53,14 @@ routines := \ pread pwrite pread64 pwrite64 aux := init-posix environ -tests := tstgetopt testfnm runtests wordexp-test +tests := tstgetopt testfnm runtests wordexp-test runptests test-srcs := globtest others := getconf install-bin := getconf install-lib := libposix.a gpl2lgpl := getopt.c getopt1.c getopt.h regex.c regex.h -before-compile := testcases.h +before-compile := testcases.h ptestcases.h # So they get cleaned up. generated := $(addprefix wordexp-test-result, 1 2 3 4 5 6 7 8 9 10) @@ -89,6 +90,13 @@ testcases.h: TESTS TESTS2C.sed ifeq ($(with-cvs),yes) test ! -d CVS || cvs $(CVSOPTS) commit -mRegenerated $@ endif + +ptestcases.h: PTESTS PTESTS2C.sed + sed -f PTESTS2C.sed < $< > $@T + mv -f $@T $@ +ifeq ($(with-cvs),yes) + test ! -d CVS || cvs $(CVSOPTS) commit -mRegenerated $@ +endif # Make the standalone glob/fnmatch package. diff --git a/posix/PTESTS b/posix/PTESTS new file mode 100644 index 0000000..636c824 --- /dev/null +++ b/posix/PTESTS @@ -0,0 +1,309 @@ +# 2.8.2 Regular Expression General Requirement +2¦4¦bb*¦abbbc¦ +2¦2¦bb*¦ababbbc¦ +7¦9¦A#*::¦A:A#:qA::qA#::qA##::q¦ +1¦5¦A#*::¦A##::A#::qA::qA#:q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¦ +-1¦-1¦\(^a\)\1¦^a^abc¦ +1¦2¦\(^^a\)¦^a¦ +1¦1¦\(^^\)¦^^¦ +1¦3¦\(^abc\)¦abcdef¦ +-1¦-1¦\(^def\)¦abcdef¦ +# GA145(2) +-1¦-1¦\(^a\)\1¦aabc¦ +1¦4¦\(^a\)\1¦^a^abc¦ +-1¦-1¦\(^^a\)¦^a¦ +1¦2¦\(^^\)¦^^¦ +# GA146 +3¦3¦a$¦cba¦ +-1¦-1¦a$¦abc¦ +5¦7¦[a-z]*$¦99ZZxyz¦ +-1¦-1¦[a-z]*$¦99ZZxyz99¦ +3¦3¦$$¦ab$¦ +-1¦-1¦$$¦$ab¦ +3¦3¦\$$¦ab$¦ +# GA147(1) +-1¦-1¦\(a$\)\1¦bcaa¦ +-1¦-1¦\(a$\)\1¦ba$¦ +-1¦-1¦\(ab$\)¦ab$¦ +1¦2¦\(ab$\)¦ab¦ +4¦6¦\(def$\)¦abcdef¦ +-1¦-1¦\(abc$\)¦abcdef¦ +# GA147(2) +-1¦-1¦\(a$\)\1¦bcaa¦ +2¦5¦\(a$\)\1¦ba$a$¦ +-1¦-1¦\(ab$\)¦ab¦ +1¦3¦\(ab$\)¦ab$¦ +# GA148 +0¦0¦^$¦¦ +1¦3¦^abc$¦abc¦ +-1¦-1¦^xyz$¦^xyz^¦ +-1¦-1¦^234$¦^234$¦ +1¦9¦^[a-zA-Z0-9]*$¦2aA3bB9zZ¦ +-1¦-1¦^[a-z0-9]*$¦2aA3b#B9zZ¦ diff --git a/posix/PTESTS2C.sed b/posix/PTESTS2C.sed new file mode 100644 index 0000000..98a547d --- /dev/null +++ b/posix/PTESTS2C.sed @@ -0,0 +1,4 @@ +/^##/d +s/# \(.*\)/ { 0, 0, "\1", NULL, },/ +s/\([^¦]*\)¦\([^¦]*\)¦\([^¦]*\)¦\([^¦]*\)¦\(.*\)/ { \1, \2, "\3", "\4", \5 },/ +s/\\/\\\\/g diff --git a/posix/runptests.c b/posix/runptests.c new file mode 100644 index 0000000..50b157b --- /dev/null +++ b/posix/runptests.c @@ -0,0 +1,117 @@ +/* POSIX regex testsuite from IEEE 2003.2. + Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sys/types.h> +#include <regex.h> +#include <stdio.h> + +/* Data structure to describe the tests. */ +struct test +{ + int start; + int end; + const char *reg; + const char *str; + int options; +} tests[] = +{ +#include "ptestcases.h" +}; + + +int +main (int argc, char *argv[]) +{ + size_t cnt; + int errors = 0; + + for (cnt = 0; cnt < sizeof (tests) / sizeof (tests[0]); ++cnt) + if (tests[cnt].str == NULL) + { + printf ("\n%s\n%.*s\n", tests[cnt].reg, + (int) strlen (tests[cnt].reg), + "-----------------------------------------------------"); + } + else + { + regex_t re; + regmatch_t match[20]; + int err; + + printf ("regexp: \"%s\", string: \"%s\" -> ", tests[cnt].reg, + tests[cnt].str); + + /* Compile the expression. */ + err = regcomp (&re, tests[cnt].reg, tests[cnt].options); + if (err != 0) + { + if (tests[cnt].start == -1) + puts ("failed, OK"); + else + { + char buf[100]; + regerror (err, &re, buf, sizeof (buf)); + printf ("FAIL: %s\n", buf); + ++errors; + } + + continue; + } + + /* Run the actual test. */ + err = regexec (&re, tests[cnt].str, 20, match, 0); + + if (err != 0) + { + if (tests[cnt].start == -1) + puts ("no match, OK"); + else + { + puts ("no match, FAIL"); + ++errors; + } + } + else + { + if (match[0].rm_so == 0 && tests[cnt].start == 0 + && match[0].rm_eo == 0 && tests[cnt].end == 0) + puts ("match, OK"); + else if (match[0].rm_so + 1 == tests[cnt].start + && match[0].rm_eo == tests[cnt].end) + puts ("match, OK"); + else + { + printf ("wrong match (%d to %d): FAIL\n", + match[0].rm_so, match[0].rm_eo); + ++errors; + } + } + + /* Free all resources. */ + regfree (&re); + } + + printf ("\n%u tests, %d errors\n", cnt, errors); + + /* We should return here the error status but since some tests are known + to fail this would only cause the libc testsuite to fail. */ + //return errors != 0; + return 0; +} |