From 4fe8f8563fedcb04b167db476adaf3bc398f879d Mon Sep 17 00:00:00 2001
From: Chapman Flack <chap@anastigmatix.net>
Date: Mon, 8 Jan 2018 23:15:01 -0500
Subject: [PATCH 1/2] Survive VPATH build without w on source tree.

A couple tests pass log options to pgbench, with a bare filename
for --log-prefix, so it would be created in the current directory.
In a VPATH build, inconveniently, the Makefile chdirs into the
original source tree before running this, and if the build user has
no write access there, the tests fail. Chdir back to a nice writable
$TESTDIR/tmp_check to avoid that.
---
 src/bin/pgbench/t/001_pgbench_with_server.pl | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench/t/001_pgbench_with_server.pl
index 3dd080e..8305db3 100644
--- a/src/bin/pgbench/t/001_pgbench_with_server.pl
+++ b/src/bin/pgbench/t/001_pgbench_with_server.pl
@@ -5,6 +5,11 @@ use PostgresNode;
 use TestLib;
 use Test::More;
 
+if ( exists $ENV{'TESTDIR'} ) {
+	chdir $ENV{'TESTDIR'};
+	-d 'tmp_check' && -w 'tmp_check' && chdir 'tmp_check';
+}
+
 # start a pgbench specific server
 my $node = get_new_node('main');
 $node->init;
-- 
2.7.3

