how to use valgrind for TAP tests

Started by osumi.takamichi@fujitsu.comalmost 6 years ago5 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrytests failedCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t43417
psql -h localhost -U postgres

Built from patchset v3 (message #3), July 27, 2026 at 05:53 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t43417_3 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t43417_3 && git checkout t43417_3

Patchset v3 (message #3) is on t43417_3

Jump to latest
#1osumi.takamichi@fujitsu.com
osumi.takamichi@fujitsu.com

Hello, hackers

I have a question about how to execute valgrind with TAP tests
in order to check some patches in the community.
My main interest is testing src/test/subscription now but
is there any general way to do it ?

The documentation [1]https://www.postgresql.org/docs/13/regress-tap.html says
"It's important to realize that the TAP tests will start test server(s) even when you say make installcheck".
Then, when I executed postgres that is launched by valgrind, it didn't react to the test execution of "make installcheck".

In other words, I can execute make installcheck without starting up my instance,
because TAP tests create their own servers
at least in terms of the case of my interested test, src/test/subscription.

[1]: https://www.postgresql.org/docs/13/regress-tap.html

Could someone give me an advice ?

Best Regards,
Takamichi Osumi

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: osumi.takamichi@fujitsu.com (#1)
Re: how to use valgrind for TAP tests

"osumi.takamichi@fujitsu.com" <osumi.takamichi@fujitsu.com> writes:

I have a question about how to execute valgrind with TAP tests
in order to check some patches in the community.
My main interest is testing src/test/subscription now but
is there any general way to do it ?

The standard solution is

(1) Build normally (well, with -DUSE_VALGRIND)
(2) Move the postgres executable aside, say
mv src/backend/postgres src/backend/postgres.orig
(3) Replace the executable with a wrapper script that invokes
valgrind on the original executable
(4) Now you can run "make check" with a valgrind'ed server,
as well as things that depend on "make check", such as TAP tests

The script I use for (3) is attached; adjust paths and options to taste.

regards, tom lane

Attachments:

postgres-substitute.shtext/x-shellscript; charset=us-ascii; name=postgres-substitute.shDownload
#3Alexander Lakhin
exclusion@gmail.com
In reply to: Tom Lane (#2)
Re: how to use valgrind for TAP tests

Hello,

18.12.2020 19:02, Tom Lane wrote:

"osumi.takamichi@fujitsu.com" <osumi.takamichi@fujitsu.com> writes:

I have a question about how to execute valgrind with TAP tests
in order to check some patches in the community.
My main interest is testing src/test/subscription now but
is there any general way to do it ?

The standard solution is

(1) Build normally (well, with -DUSE_VALGRIND)
(2) Move the postgres executable aside, say
mv src/backend/postgres src/backend/postgres.orig
(3) Replace the executable with a wrapper script that invokes
valgrind on the original executable
(4) Now you can run "make check" with a valgrind'ed server,
as well as things that depend on "make check", such as TAP tests

The script I use for (3) is attached; adjust paths and options to taste.

I use the attached patch for this purpose, that slightly simplifies
things and covers all the other binaries:
git apply .../install-vrunner.patch
CPPFLAGS="-DUSE_VALGRIND -Og" ./configure --enable-tap-tests
--enable-debug --enable-cassert && make && make check
`make check-world` is possible too, with
src/bin/pg_ctl/t/001_start_stop.pl disabled (removed).

Best regards,
Alexander

Attachments:

t43417_3
install-vrunner.patchtext/x-patch; charset=UTF-8; name=install-vrunner.patchDownload+32-5
#4osumi.takamichi@fujitsu.com
osumi.takamichi@fujitsu.com
In reply to: Tom Lane (#2)
RE: how to use valgrind for TAP tests

Hello

On Saturday, December 19, 2020 1:03 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:

"osumi.takamichi@fujitsu.com" <osumi.takamichi@fujitsu.com> writes:

I have a question about how to execute valgrind with TAP tests in
order to check some patches in the community.
My main interest is testing src/test/subscription now but is there any
general way to do it ?

The standard solution is

(1) Build normally (well, with -DUSE_VALGRIND)
(2) Move the postgres executable aside, say
mv src/backend/postgres src/backend/postgres.orig
(3) Replace the executable with a wrapper script that invokes
valgrind on the original executable
(4) Now you can run "make check" with a valgrind'ed server,
as well as things that depend on "make check", such as TAP tests

The script I use for (3) is attached; adjust paths and options to taste.

Thank you so much.
I couldn't come up with the idea to prepare a wrapper script.
This worked successfully.

Best,
Takamichi Osumi

#5osumi.takamichi@fujitsu.com
osumi.takamichi@fujitsu.com
In reply to: Alexander Lakhin (#3)
RE: how to use valgrind for TAP tests

Hi, Alexander

On Sunday, December 20, 2020 5:00 PM Alexander Lakhin wrote:

"osumi.takamichi@fujitsu.com" <osumi.takamichi@fujitsu.com> writes:

I have a question about how to execute valgrind with TAP tests in
order to check some patches in the community.
My main interest is testing src/test/subscription now but is there
any general way to do it ?

The standard solution is

(1) Build normally (well, with -DUSE_VALGRIND)
(2) Move the postgres executable aside, say
mv src/backend/postgres src/backend/postgres.orig
(3) Replace the executable with a wrapper script that invokes
valgrind on the original executable
(4) Now you can run "make check" with a valgrind'ed server,
as well as things that depend on "make check", such as TAP tests

The script I use for (3) is attached; adjust paths and options to taste.

I use the attached patch for this purpose, that slightly simplifies things and
covers all the other binaries:
git apply .../install-vrunner.patch
CPPFLAGS="-DUSE_VALGRIND -Og" ./configure --enable-tap-tests
--enable-debug --enable-cassert && make && make check `make
check-world` is possible too, with src/bin/pg_ctl/t/001_start_stop.pl
disabled (removed).

Thank you for giving me a fruitful advice !
When I encounter another needs, I'll apply this method as well.

Best Regards,
Takamichi Osumi