diff options
author | Peter Eisentraut | 2014-07-03 01:44:02 +0000 |
---|---|---|
committer | Peter Eisentraut | 2014-07-03 01:47:14 +0000 |
commit | f545d233ebce6971b6f9847680e48b679e707d22 (patch) | |
tree | 358a239fc12070ca352c161ba0a997a2881015ca /src/test | |
parent | 0490db62871dc6888c52bd9465d9ade16ab8e795 (diff) |
Use a separate temporary directory for the Unix-domain socket
Creating the Unix-domain socket in the build directory can run into
name-length limitations. Therefore, create the socket file in the
default temporary directory of the operating system. Keep the temporary
data directory etc. in the build tree.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/perl/TestLib.pm | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm index 775c75d7ab1..f80d1c5bd72 100644 --- a/src/test/perl/TestLib.pm +++ b/src/test/perl/TestLib.pm @@ -6,6 +6,7 @@ use warnings; use Exporter 'import'; our @EXPORT = qw( tempdir + tempdir_short start_test_server restart_test_server psql @@ -65,6 +66,13 @@ sub tempdir return File::Temp::tempdir('tmp_testXXXX', DIR => $ENV{TESTDIR} || cwd(), CLEANUP => 1); } +sub tempdir_short +{ + # Use a separate temp dir outside the build tree for the + # Unix-domain socket, to avoid file name length issues. + return File::Temp::tempdir(CLEANUP => 1); +} + my ($test_server_datadir, $test_server_logfile); sub start_test_server @@ -72,10 +80,12 @@ sub start_test_server my ($tempdir) = @_; my $ret; + my $tempdir_short = tempdir_short; + system "initdb -D $tempdir/pgdata -A trust -N >/dev/null"; $ret = system 'pg_ctl', '-D', "$tempdir/pgdata", '-s', '-w', '-l', "$tempdir/logfile", '-o', - "--fsync=off -k $tempdir --listen-addresses='' --log-statement=all", + "--fsync=off -k $tempdir_short --listen-addresses='' --log-statement=all", 'start'; if ($ret != 0) @@ -84,7 +94,7 @@ sub start_test_server BAIL_OUT("pg_ctl failed"); } - $ENV{PGHOST} = $tempdir; + $ENV{PGHOST} = $tempdir_short; $test_server_datadir = "$tempdir/pgdata"; $test_server_logfile = "$tempdir/logfile"; } |