Add i686 __libc_ifunc_impl_list
[glibc.git] / posix / runptests.c
blobab0385d3ea642112bacd9b9b35474b0553357e6f
1 /* POSIX regex testsuite from IEEE 2003.2.
2 Copyright (C) 1998, 2003 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #include <sys/types.h>
21 #include <regex.h>
22 #include <stdio.h>
23 #include <string.h>
25 /* Data structure to describe the tests. */
26 struct test
28 int start;
29 int end;
30 const char *reg;
31 const char *str;
32 int options;
33 } tests[] =
35 #include "ptestcases.h"
39 int
40 main (int argc, char *argv[])
42 size_t cnt;
43 int errors = 0;
45 for (cnt = 0; cnt < sizeof (tests) / sizeof (tests[0]); ++cnt)
46 if (tests[cnt].str == NULL)
48 printf ("\n%s\n%.*s\n", tests[cnt].reg,
49 (int) strlen (tests[cnt].reg),
50 "-----------------------------------------------------");
52 else if (tests[cnt].reg == NULL)
53 printf ("!!! %s\n", tests[cnt].str);
54 else
56 regex_t re;
57 regmatch_t match[20];
58 int err;
60 printf ("regexp: \"%s\", string: \"%s\" -> ", tests[cnt].reg,
61 tests[cnt].str);
63 /* Compile the expression. */
64 err = regcomp (&re, tests[cnt].reg, tests[cnt].options);
65 if (err != 0)
67 if (tests[cnt].start == -2)
68 puts ("compiling failed, OK");
69 else
71 char buf[100];
72 regerror (err, &re, buf, sizeof (buf));
73 printf ("FAIL: %s\n", buf);
74 ++errors;
77 continue;
79 else if (tests[cnt].start == -2)
81 puts ("compiling suceeds, FAIL");
82 errors++;
83 continue;
86 /* Run the actual test. */
87 err = regexec (&re, tests[cnt].str, 20, match, 0);
89 if (err != 0)
91 if (tests[cnt].start == -1)
92 puts ("no match, OK");
93 else
95 puts ("no match, FAIL");
96 ++errors;
99 else
101 if (match[0].rm_so == 0 && tests[cnt].start == 0
102 && match[0].rm_eo == 0 && tests[cnt].end == 0)
103 puts ("match, OK");
104 else if (match[0].rm_so + 1 == tests[cnt].start
105 && match[0].rm_eo == tests[cnt].end)
106 puts ("match, OK");
107 else
109 printf ("wrong match (%d to %d): FAIL\n",
110 match[0].rm_so, match[0].rm_eo);
111 ++errors;
115 /* Free all resources. */
116 regfree (&re);
119 printf ("\n%Zu tests, %d errors\n", cnt, errors);
121 return errors != 0;