summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Misch2017-12-16 18:03:35 +0000
committerNoah Misch2017-12-16 18:03:35 +0000
commitc757a3da0af0e5eb636eeee2af6602d279162b0a (patch)
tree24163e0234593c82df48d8573be6403019b9d0b2
parent997071691f66dfe92e97e6b4e3d29d153317be31 (diff)
Avoid and detect SIGPIPE race in TAP tests.
Don't write to stdin of a psql process that could have already exited with an authentication failure. Buildfarm members crake and mandrill have failed once by doing so. Ignore SIGPIPE in all TAP tests. Back-patch to v10, where these tests were introduced. Reviewed by Michael Paquier. Discussion: https://postgr.es/m/[email protected]
-rw-r--r--src/test/authentication/t/001_password.pl3
-rw-r--r--src/test/authentication/t/002_saslprep.pl3
-rw-r--r--src/test/perl/TestLib.pm4
3 files changed, 6 insertions, 4 deletions
diff --git a/src/test/authentication/t/001_password.pl b/src/test/authentication/t/001_password.pl
index 2d3f674144..9340f2f1ab 100644
--- a/src/test/authentication/t/001_password.pl
+++ b/src/test/authentication/t/001_password.pl
@@ -44,8 +44,7 @@ sub test_role
$status_string = 'success' if ($expected_res eq 0);
- my $res =
- $node->psql('postgres', 'SELECT 1', extra_params => [ '-U', $role ]);
+ my $res = $node->psql('postgres', undef, extra_params => [ '-U', $role ]);
is($res, $expected_res,
"authentication $status_string for method $method, role $role");
}
diff --git a/src/test/authentication/t/002_saslprep.pl b/src/test/authentication/t/002_saslprep.pl
index df9f85d6a9..e09273edd4 100644
--- a/src/test/authentication/t/002_saslprep.pl
+++ b/src/test/authentication/t/002_saslprep.pl
@@ -41,8 +41,7 @@ sub test_login
$status_string = 'success' if ($expected_res eq 0);
$ENV{"PGPASSWORD"} = $password;
- my $res =
- $node->psql('postgres', 'SELECT 1', extra_params => [ '-U', $role ]);
+ my $res = $node->psql('postgres', undef, extra_params => [ '-U', $role ]);
is($res, $expected_res,
"authentication $status_string for role $role with password $password"
);
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
index d1a2eb5883..60190400de 100644
--- a/src/test/perl/TestLib.pm
+++ b/src/test/perl/TestLib.pm
@@ -75,6 +75,10 @@ BEGIN
INIT
{
+ # Return EPIPE instead of killing the process with SIGPIPE. An affected
+ # test may still fail, but it's more likely to report useful facts.
+ $SIG{PIPE} = 'IGNORE';
+
# Determine output directories, and create them. The base path is the
# TESTDIR environment variable, which is normally set by the invoking
# Makefile.