Lines Matching refs:test

4  * regex(3) test harness
16 * The following license covers testregex.c and all associated test data.
169 T(" testregex - regex(3) test harness\n");
175 T(" testregex reads regex(3) test specifications, one per line, from the\n");
176 T(" standard input and writes one output line for each failed test. A\n");
178 T(" test is run again with REG_NOSUB. Unsupported features are noted\n");
179 T(" before the first test, and tests requiring these features are\n");
191 T(" -v list each test line\n");
192 T(" -A list failed test lines with actual answers\n");
193 T(" -B list all test lines with actual answers\n");
194 T(" -F list failed test lines\n");
195 T(" -P list passed test lines\n");
199 T(" Input lines may be blank, a comment beginning with #, or a test\n");
205 T(" flag. The test is skipped if REG_feature is not supported by the\n");
208 T(" specified; the test will be repeated for each mode.\n");
251 T(" ?test ... output field 5 if passed and != EXPECTED, silent otherwise\n");
252 T(" &test ... output field 5 if current and previous passed\n");
253 T(" |test ... output field 5 if current passed and previous failed\n");
255 T(" {test ... skip if failed until }\n");
259 T(" :comment:test :comment: ignored\n");
272 T(" Field 4: the test outcome. This is either one of the posix error\n");
278 T(" each test. All array elements from 0 to nmatch-1 must be specified\n");
574 quote(char* s, int len, unsigned long test)
587 else if (test & TEST_EXPAND)
592 if (test & TEST_DELIMIT)
601 if (test & TEST_DELIMIT)
646 if (test & TEST_DELIMIT)
654 report(char* comment, char* fun, char* re, char* s, int len, char* msg, int flags, unsigned long test)
662 quote(re, -1, test|TEST_DELIMIT);
666 quote(s, len, test|TEST_DELIMIT);
669 if (test & TEST_UNSPECIFIED)
717 bad(char* comment, char* re, char* s, int len, unsigned long test)
719 printf("bad test case ");
720 report(comment, NiL, re, s, len, NiL, 0, test);
860 matchprint(regmatch_t* match, int nmatch, int nsub, char* ans, unsigned long test)
865 if ((match[nmatch-1].rm_so != -1 || match[nmatch-1].rm_eo != -1) && (!(test & TEST_IGNORE_POSITION) || match[nmatch-1].rm_so >= 0 && match[nmatch-1].rm_eo >= 0))
875 if (!(test & (TEST_ACTUAL|TEST_BASELINE)))
884 matchcheck(regmatch_t* match, int nmatch, int nsub, char* ans, char* re, char* s, int len, int flags, unsigned long test)
892 return test & (TEST_BASELINE|TEST_PASS|TEST_VERIFY);
904 if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY))
906 report("callout failed", NiL, re, s, len, NiL, flags, test);
907 quote(p, -1, test);
909 quote(x, -1, test);
916 bad("improper answer\n", re, s, -1, test);
932 bad("improper answer\n", re, s, -1, test);
948 bad("improper answer\n", re, s, -1, test);
951 if (!(test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY)))
953 report("failed: match was", NiL, re, s, len, NiL, flags, test);
954 matchprint(match, nmatch, nsub, ans, test);
963 if (!(test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_VERIFY)))
965 if ((test & TEST_IGNORE_POSITION) && (match[i].rm_so<0 || match[i].rm_eo<0))
970 if (!(test & TEST_SUMMARY))
972 report("failed: match was", NiL, re, s, len, NiL, flags, test);
973 matchprint(match, nmatch, nsub, ans, test);
979 if (!(test & TEST_IGNORE_OVER) && match[nmatch].rm_so != state.NOMATCH.rm_so)
981 if (!(test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY)))
983 report("failed: overran match array", NiL, re, s, len, NiL, flags, test);
984 matchprint(match, nmatch + 1, nsub, NiL, test);
1063 note(unsigned long level, char* msg, unsigned long skip, unsigned long test)
1065 if (!(test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_SUMMARY)) && !skip)
1080 extract(int* tabs, char* spec, char* re, char* s, char* ans, char* msg, char* accept, regmatch_t* match, int nmatch, int nsub, unsigned long skip, unsigned long level, unsigned long test)
1082 if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_OK|TEST_PASS|TEST_SUMMARY))
1085 if (test & TEST_OK)
1088 if ((test & TEST_VERIFY) && !(test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_SUMMARY)))
1094 test &= ~(TEST_PASS|TEST_QUERY);
1096 if (test & (TEST_QUERY|TEST_VERIFY))
1098 if (test & TEST_BASELINE)
1099 test &= ~(TEST_BASELINE|TEST_PASS);
1101 test |= TEST_PASS;
1104 if (!(test & TEST_OK))
1106 if (test & TEST_UNSPECIFIED)
1111 if (test & (TEST_PASS|TEST_SUMMARY))
1113 test &= ~TEST_DELIMIT;
1115 if ((test & (TEST_BASELINE|TEST_SAME)) == (TEST_BASELINE|TEST_SAME))
1118 quote(re, -1, test);
1120 quote(s, -1, test);
1122 if (!(test & (TEST_ACTUAL|TEST_BASELINE)) || !accept && !match)
1127 matchprint(match, nmatch, nsub, NiL, test);
1132 else if (test & TEST_QUERY)
1133 skip = note(level, msg, skip, test);
1134 else if (test & TEST_VERIFY)
1140 catchfree(regex_t* preg, int flags, int* tabs, char* spec, char* re, char* s, char* ans, char* msg, char* accept, regmatch_t* match, int nmatch, int nsub, unsigned long skip, unsigned long level, unsigned long test)
1144 if (!(test & TEST_CATCH))
1155 else if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY))
1156 extract(tabs, spec, re, s, ans, msg, NiL, NiL, 0, 0, skip, level, test);
1159 report("failed", "regfree", re, NiL, -1, msg, flags, test);
1265 unsigned long test = 0;
1283 test |= TEST_CATCH;
1286 test |= TEST_IGNORE_ERROR;
1299 test |= TEST_IGNORE_OVER;
1302 test |= TEST_IGNORE_POSITION;
1316 test |= TEST_VERBOSE;
1319 test |= TEST_ACTUAL;
1322 test |= TEST_BASELINE;
1325 test |= TEST_FAIL;
1328 test |= TEST_PASS;
1331 test |= TEST_SUMMARY;
1358 if (!(test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_SUMMARY)))
1392 if (test & TEST_CATCH)
1394 if (test & TEST_IGNORE_ERROR)
1396 if (test & TEST_IGNORE_POSITION)
1402 if (test & TEST_VERBOSE)
1445 if (test & TEST_CATCH)
1462 if (test & TEST_BASELINE)
1471 if (test & TEST_BASELINE)
1477 if (test & TEST_BASELINE)
1479 else if (!(test & (TEST_ACTUAL|TEST_FAIL|TEST_PASS|TEST_SUMMARY)))
1532 test &= TEST_GLOBAL;
1549 test |= TEST_ARE;
1552 test |= TEST_BRE;
1555 if (!(test & TEST_QUERY) && !(skip & level))
1557 test &= ~TEST_QUERY;
1575 skip = note(level, s, skip, test);
1578 if (!(test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_SUMMARY)))
1583 skip = note(level, skip, test, "locales not supported");
1589 test |= TEST_ERE;
1592 test |= TEST_KRE;
1595 test |= TEST_LRE;
1598 test |= TEST_SRE;
1662 test |= TEST_UNSPECIFIED;
1674 test |= TEST_LENIENT;
1684 test |= TEST_EXPAND;
1688 test |= TEST_SUB;
1692 test |= TEST_DECOMP;
1696 test |= TEST_VERIFY;
1697 test &= ~(TEST_AND|TEST_OR);
1701 test |= TEST_VERIFY|TEST_AND;
1702 test &= ~TEST_OR;
1705 test |= TEST_VERIFY|TEST_OR;
1706 test &= ~TEST_AND;
1709 test |= TEST_OR;
1710 test &= ~TEST_AND;
1723 test |= TEST_QUERY;
1731 if (!(test & (TEST_BASELINE|TEST_SUMMARY)))
1733 if (test & (TEST_ACTUAL|TEST_FAIL))
1735 else if (!(test & TEST_PASS))
1748 if (!(test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_SUMMARY)))
1750 else if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_PASS))
1753 else if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL))
1762 bad("bad spec\n", spec, NiL, 0, test);
1768 if ((cflags|eflags) == NOTEST || (skip & level) && (test & TEST_BASELINE))
1770 if (test & TEST_BASELINE)
1778 if (test & TEST_OR)
1780 if (!(test & TEST_VERIFY))
1782 test &= ~TEST_OR;
1790 else if (test & TEST_AND)
1796 if (i < ((test & TEST_DECOMP) ? 3 : 4))
1797 bad("too few fields\n", NiL, NiL, 0, test);
1805 test |= TEST_SAME;
1809 if (test & TEST_EXPAND)
1821 if (test & TEST_EXPAND)
1830 if (!(ans = field[(test & TEST_DECOMP) ? 2 : 3]))
1831 bad("NIL answer\n", NiL, NiL, 0, test);
1834 if (test & TEST_SUB)
1841 if (test & TEST_DECOMP)
1851 if (REG_EXTENDED != 0 && (test & TEST_BRE))
1853 if (test & TEST_BRE)
1856 test &= ~TEST_BRE;
1863 if (test & TEST_ERE)
1865 test &= ~TEST_ERE;
1872 if (test & TEST_ARE)
1874 test &= ~TEST_ARE;
1881 if (test & TEST_LRE)
1883 test &= ~TEST_LRE;
1890 if (test & TEST_SRE)
1892 test &= ~TEST_SRE;
1898 if (test & TEST_KRE)
1900 test &= ~TEST_KRE;
1908 if (test & (TEST_BASELINE|TEST_PASS|TEST_VERIFY))
1909 extract(tabs, line, re, s, ans, msg, NiL, NiL, 0, 0, skip, level, test|TEST_OK);
1912 if ((test & (TEST_QUERY|TEST_VERBOSE|TEST_VERIFY)) == TEST_VERBOSE)
1914 printf("test %-3d %s ", state.lineno, state.which);
1915 quote(re, -1, test|TEST_DELIMIT);
1917 quote(s, nstr, test|TEST_DELIMIT);
1932 if (!(test & TEST_QUERY))
1941 if (!(test & TEST_CATCH))
1950 if (!cret && (test & TEST_SUB))
1954 if (!(test & TEST_CATCH))
1964 if (catchfree(&preg, flags, tabs, line, re, s, ans, msg, NiL, NiL, 0, 0, skip, level, test))
1971 if (!cret && (test & TEST_DECOMP))
1979 if (!(test & TEST_CATCH))
1989 catchfree(&preg, flags, tabs, line, re, s, ans, msg, NiL, NiL, 0, 0, skip, level, test);
1994 report("failed", fun, re, s, nstr, msg, flags, test);
2000 report("failed", fun, re, s, nstr, msg, flags, test);
2001 quote(ans, -1, test|TEST_DELIMIT);
2003 quote(buf, -1, test|TEST_DELIMIT);
2021 if (test & TEST_IGNORE_OVER)
2030 if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY))
2031 skip = extract(tabs, line, re, s, ans, msg, "OK", NiL, 0, 0, skip, level, test|TEST_DELIMIT);
2034 report("re_nsub incorrect", fun, re, NiL, -1, msg, flags, test);
2044 if (!(test & (TEST_DECOMP|TEST_SUB)) && *ans && *ans != '(' && !streq(ans, "OK") && !streq(ans, "NOMATCH"))
2046 if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY))
2047 skip = extract(tabs, line, re, s, ans, msg, "OK", NiL, 0, 0, skip, level, test|TEST_DELIMIT);
2048 else if (!(test & TEST_LENIENT))
2050 report("failed", fun, re, NiL, -1, msg, flags, test);
2053 catchfree(&preg, flags, tabs, line, re, s, ans, msg, NiL, NiL, 0, 0, skip, level, test);
2059 if (test & TEST_LENIENT)
2067 if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY))
2068 skip = extract(tabs, line, re, s, ans, msg, codes[got].name, NiL, 0, 0, skip, level, test|TEST_DELIMIT);
2071 report("failed", fun, re, NiL, -1, msg, flags, test);
2088 if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY))
2089 skip = extract(tabs, line, re, s, ans, msg, codes[got].name, NiL, 0, 0, skip, level, test|TEST_DELIMIT);
2092 report("failed: invalid error code", NiL, re, NiL, -1, msg, flags, test);
2098 if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY))
2099 skip = extract(tabs, line, re, s, ans, msg, codes[got].name, NiL, 0, 0, skip, level, test|TEST_DELIMIT);
2100 else if (test & TEST_IGNORE_ERROR)
2104 report("should fail and did", fun, re, NiL, -1, msg, flags, test);
2135 if (!(test & TEST_CATCH))
2145 if ((test & TEST_SUB) && !eret)
2148 if (!(test & TEST_CATCH))
2164 if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY))
2165 skip = extract(tabs, line, re, s, ans, msg, "NOMATCH", NiL, 0, 0, skip, level, test|TEST_DELIMIT);
2168 report("REG_NOSUB failed", fun, re, s, nstr, msg, flags, test);
2175 if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY))
2176 skip = extract(tabs, line, re, s, ans, msg, NiL, match, nmatch, nsub, skip, level, test|TEST_DELIMIT);
2179 report("should fail and didn't", fun, re, s, nstr, msg, flags, test);
2188 if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY))
2189 skip = extract(tabs, line, re, s, ans, msg, "NOMATCH", NiL, 0, nsub, skip, level, test|TEST_DELIMIT);
2192 report("failed", fun, re, s, nstr, msg, flags, test);
2204 if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY))
2205 skip = extract(tabs, line, re, s, ans, msg, NiL, match, nmatch, nsub, skip, level, test|TEST_DELIMIT);
2208 report("should fail and didn't", fun, re, s, nstr, msg, flags, test);
2209 matchprint(match, nmatch, nsub, NiL, test);
2213 else if (test & TEST_SUB)
2218 report("failed", fun, re, s, nstr, msg, flags, test);
2219 quote(ans, -1, test|TEST_DELIMIT);
2221 quote(p, -1, test|TEST_DELIMIT);
2230 if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY))
2231 skip = extract(tabs, line, re, s, ans, msg, NiL, NiL, 0, 0, skip, level, test);
2234 report("failed: no match but match array assigned", NiL, re, s, nstr, msg, flags, test);
2235 matchprint(match, nmatch, nsub, NiL, test);
2239 else if (matchcheck(match, nmatch, nsub, ans, re, s, nstr, flags, test))
2250 if (!(test & (TEST_DECOMP|TEST_SUB|TEST_VERIFY)) && !nonosub)
2252 if (catchfree(&preg, flags, tabs, line, re, s, ans, msg, NiL, NiL, 0, 0, skip, level, test))
2257 if (test & (TEST_BASELINE|TEST_PASS|TEST_VERIFY))
2258 skip = extract(tabs, line, re, s, ans, msg, NiL, match, nmatch, nsub, skip, level, test|TEST_OK);
2260 else if (test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS|TEST_QUERY|TEST_SUMMARY|TEST_VERIFY))
2261 skip = extract(tabs, line, re, s, ans, msg, NiL, match, nmatch, nsub, skip, level, test|TEST_DELIMIT);
2262 if (catchfree(&preg, flags, tabs, line, re, s, ans, msg, NiL, NiL, 0, 0, skip, level, test))
2266 if (test & TEST_SUMMARY)
2268 else if (!(test & (TEST_ACTUAL|TEST_BASELINE|TEST_FAIL|TEST_PASS)))
2273 printf(", %d test%s", testno, testno == 1 ? "" : "s");