summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-12-25 18:03:40 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-12-25 18:03:40 +0000
commitbd3adc978bed06496f88a563644f333cd0a1248d (patch)
treeb83bc342788a0a93e02733a0cd06a64e3b03df5d /test
parent66dfcf4efb68ace12d46e5a71a169ed8e8f432b8 (diff)
test/regex/tst-regexloc.c: include ok/bad indicator in the message
test/regex/tst-regex2.c: do not exit at the first error
Diffstat (limited to 'test')
-rw-r--r--test/regex/tst-regex2.c44
-rw-r--r--test/regex/tst-regexloc.c15
2 files changed, 40 insertions, 19 deletions
diff --git a/test/regex/tst-regex2.c b/test/regex/tst-regex2.c
index db7c533b3..2e2b85f62 100644
--- a/test/regex/tst-regex2.c
+++ b/test/regex/tst-regex2.c
@@ -27,6 +27,7 @@ do_test(void)
struct stat st;
unsigned len;
int testno;
+ int exitcode = 0;
int fd = open(fname, O_RDONLY);
if (fd < 0) {
@@ -71,14 +72,16 @@ do_test(void)
char errstr[300];
regerror(err, &rbuf, errstr, sizeof(errstr));
puts(errstr);
- return err;
+ exitcode = 1;
+ goto contin1;
}
regmatch_t pmatch[71];
err = regexec(&rbuf, string, 71, pmatch, 0);
if (err == REG_NOMATCH) {
puts("regexec failed");
- return 1;
+ exitcode = 1;
+ goto contin1;
}
if (testno == 0) {
@@ -91,7 +94,8 @@ do_test(void)
) != 0
) {
puts("regexec without REG_NOSUB did not find the correct match");
- return 1;
+ exitcode = 1;
+ goto contin1;
}
if (i > 0) {
@@ -102,7 +106,8 @@ do_test(void)
|| pmatch[l].rm_eo != pmatch[l].rm_so + 1
) {
printf("pmatch[%d] incorrect\n", l);
- return 1;
+ exitcode = 1;
+ goto contin1;
}
}
}
@@ -118,6 +123,7 @@ do_test(void)
stop.tv_usec -= start.tv_usec;
printf(" %lu.%06lus\n", (unsigned long) stop.tv_sec,
(unsigned long) stop.tv_usec);
+ contin1:
regfree(&rbuf);
}
}
@@ -140,22 +146,26 @@ do_test(void)
s = re_compile_pattern(pat[i], strlen(pat[i]), &rpbuf);
if (s != NULL) {
printf("%s\n", s);
- return 1;
+ exitcode = 1;
+ goto contin2;
}
memset(&regs, 0, sizeof(regs));
match = re_search(&rpbuf, string, len, 0, len, &regs);
if (match < 0) {
printf("re_search failed (err:%d)\n", match);
- return 1;
+ exitcode = 1;
+ goto contin2;
}
if (match + 13 > len) {
printf("re_search: match+13 > len (%d > %d)\n", match + 13, len);
- return 1;
+ exitcode = 1;
+ goto contin2;
}
if (match < len - 100) {
printf("re_search: match < len-100 (%d < %d)\n", match, len - 100);
- return 1;
+ exitcode = 1;
+ goto contin2;
}
if (strncmp(string + match, " ChangeLog.13 for earlier changes",
sizeof(" ChangeLog.13 for earlier changes") - 1
@@ -163,7 +173,8 @@ do_test(void)
) {
printf("re_search did not find the correct match"
"(found '%s' instead)\n", string + match);
- return 1;
+ exitcode = 1;
+ goto contin2;
}
if (testno == 2) {
@@ -174,7 +185,8 @@ do_test(void)
expected = 9;
if (regs.num_regs != expected) {
printf("incorrect num_regs %d, expected %d\n", regs.num_regs, expected);
- return 1;
+ exitcode = 1;
+ goto contin2;
}
if (regs.start[0] != match || regs.end[0] != match + 13) {
printf("incorrect regs.{start,end}[0] = { %d, %d },"
@@ -182,7 +194,8 @@ do_test(void)
regs.start[0], regs.end[0],
match, match + 13
);
- return 1;
+ exitcode = 1;
+ goto contin2;
}
if (regs.start[regs.num_regs - 1] != -1
|| regs.end[regs.num_regs - 1] != -1
@@ -191,7 +204,8 @@ do_test(void)
" expected { -1, -1 }\n",
regs.start[regs.num_regs - 1], regs.end[regs.num_regs - 1]
);
- return 1;
+ exitcode = 1;
+ goto contin2;
}
if (i > 0) {
@@ -207,7 +221,8 @@ do_test(void)
regs.start[l], regs.end[l],
match + j, match + j + 1
);
- return 1;
+ exitcode = 1;
+ goto contin2;
}
}
}
@@ -223,10 +238,11 @@ do_test(void)
stop.tv_usec -= start.tv_usec;
printf(" %lu.%06lus\n", (unsigned long) stop.tv_sec,
(unsigned long) stop.tv_usec);
+ contin2:
regfree(&rpbuf);
}
}
- return 0;
+ return exitcode;
}
#define TIMEOUT 20
diff --git a/test/regex/tst-regexloc.c b/test/regex/tst-regexloc.c
index 88ab58116..4bc65f660 100644
--- a/test/regex/tst-regexloc.c
+++ b/test/regex/tst-regexloc.c
@@ -24,10 +24,12 @@
int
main (int argc, char *argv[])
{
-#ifdef __UCLIBC_HAS_XLOCALE__
+/* If uclibc has extended locale, or if it's a host build
+ * (assuming host libc always has locale): */
+#if defined __UCLIBC_HAS_XLOCALE__ || !defined __UCLIBC__
regex_t re;
regmatch_t mat[1];
- int res = 1;
+ int exitcode = 1;
if (setlocale (LC_ALL, "de_DE.ISO-8859-1") == NULL)
puts ("cannot set locale");
@@ -37,11 +39,14 @@ main (int argc, char *argv[])
puts ("no match");
else
{
- printf ("match from %d to %d\n", mat[0].rm_so, mat[0].rm_eo);
- res = mat[0].rm_so != 0 || mat[0].rm_eo != 6;
+ exitcode = mat[0].rm_so != 0 || mat[0].rm_eo != 6;
+ printf ("match from %d to %d - %s\n",
+ mat[0].rm_so, mat[0].rm_eo,
+ exitcode ? "WRONG!" : "ok"
+ );
}
- return res;
+ return exitcode;
#else
puts("Test requires locale; skipping");
return 0;