On 03/07/2016 08:39 PM, Andres Freund wrote:
> Hi,
>
> I'm setting up a buildfarm animal that runs under
> valgrind. Unfortunately there's not really any good solution to force
> make check et al. to start postgres wrapped in valgrind. For now I've
> resorted to adding something like
>
> sub replace_postgres
> {
> my $srcdir=$use_vpath ? "../pgsql/" : ".";
> my $builddir=abs_path("$pgsql");
> $srcdir=abs_path("$pgsql/$srcdir");
> chdir "$pgsql/src/backend/";
> rename "postgres", "postgres.orig";
> sysopen my $fh, "postgres", O_CREAT|O_TRUNC|O_RDWR, 0700
> or die "Could not create postgres wrapper";
> print $fh <<"END";
> #!/bin/bash
> ~/src/valgrind/vg-in-place \\
> --quiet \\
> --error-exitcode=128 \\
> --suppressions=$srcdir/src/tools/valgrind.supp \\
> --trace-children=yes --track-origins=yes --read-var-info=yes \\
> --leak-check=no \\
> $builddir/src/backend/postgres.orig \\
> "\$@"
> END
> close $fh;
> chdir $branch_root;
> }
> to the buildfarm client.
>
> i.e. a script that replaces the postgres binary with a wrapper that
> invokes postgres via valgrind.
>
> That's obviously not a very good approach though. It's buildfarm
> specific and thus can't be invoked by developers and it doesn't really
> support being installed somewhere.
>
> Does anybody have a better idea about how to do this?
>
Why not just create a make target which does this? It could be run after
'make' and before 'make check'. I would make it assume valgrind was
installed and in the path rather than using vg-in-place.
If that doesn't work and you want to do something with the buildfarm,
probably a buildfarm module would be the way to go. We might need to add
a new module hook to support it, to run right after make(), but that
would be a one line addition to run_build.pl.
cheers
andrew