Test harness for regex code (to allow importing Tcl's test suite)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Test harness for regex code (to allow importing Tcl's test suite)
Date: 2021-01-04 03:49:24
Message-ID: 2873268.1609732164@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Over the holiday break I've been fooling with some regex performance
improvements. I don't have anything ready to show yet in that line,
but I was feeling the need for more-thorough test coverage, so I set
to work on something that's been in the back of my mind for a long
time: we need to absorb the test cases that Henry Spencer wrote way-
back-when for that code, which up to now existed only as a script
in the Tcl test suite. That state of affairs seemed OK to me in
the beginning, when we thought of Tcl as the upstream for that code,
and figured they'd vet any nontrivial changes. They've pretty
thoroughly dropped the ball on that though, and indeed I think that
they now believe *we're* the upstream. So we need to have a test
suite that reflects that status, at least to the extent of running
all the test cases that exist for that code.

Accordingly, here's a new src/test/modules package that creates a
function modeled on regexp_matches(), but using a set of flags that
matches Spencer's design for the Tcl test suite, allowing parts
of src/backend/regex/ to be tested that can't be reached with our
existing SQL-exposed functions. The test scripts in the module
reproduce all the tests in Tcl's "tests/reg.test" script as of
Tcl 8.6.10, plus a few others that I felt advisable, such as tests
for the lookbehind constraints we added a few years ago. (Note:
Tcl also has regexp.test and regexpComp.test, but those seem to be
oriented towards testing their language-specific wrappers not the
regex engine itself.)

According to my testing, this increases our test code coverage for
src/backend/regex/ from 71.1% to 86.7%, which is not too shabby,
especially seeing that a lot of the remainder is not-deterministically-
reachable code for malloc failure handling.

Thoughts? Is anyone interested in reviewing this? Since it's only
test code, I'd be okay with pushing it without review, but I'd be
happy if someone else wants to look at it.

regards, tom lane

Attachment Content-Type Size
add-test_regex-module-1.patch text/x-diff 227.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2021-01-04 03:54:38 pg_waldump/heapdesc.c and struct field names
Previous Message Tang, Haiying 2021-01-04 03:31:01 RE: [Patch] Optimize dropping of relation buffers using dlist