Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iZaL2-0005zN-6s for pgsql-committers@arkaria.postgresql.org; Tue, 26 Nov 2019 12:53:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iZaK1-0006MI-Nu for pgsql-committers@arkaria.postgresql.org; Tue, 26 Nov 2019 12:52:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iZaK1-0006Lx-9U for pgsql-committers@lists.postgresql.org; Tue, 26 Nov 2019 12:52:01 +0000 Received: from mail-yw1-xc41.google.com ([2607:f8b0:4864:20::c41]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iZaJu-0001U0-5m for pgsql-committers@lists.postgresql.org; Tue, 26 Nov 2019 12:51:59 +0000 Received: by mail-yw1-xc41.google.com with SMTP id d80so6790909ywa.6 for ; Tue, 26 Nov 2019 04:51:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:cc:references:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=B4xuYT7K0tBqsToutVyaAItC4Ei6wqhbJjxZ9fCAOQQ=; b=07O+c4EjibzATNPMmy//DjSHEy5ewItFQBA+Bidy5brOk+ZeTHXqdNJXcQ2K+4mXZR 5ZLzUAQzIqsz7f20SI1bSZlaQgrLKiZyGPucjYMaxcedhog3ZymW2Aq+TotvYF7LpTT9 G64ceCRicXiDxm2jPCzHGLeMgRIlLcOGAAgxO4p8FP/EUg5jTrdkMcE+cZQgjEAysoFw HoyJujCAg4Pu8AZ2ZUSrEp+xV+onRgk3jNE63aj9r/DiSma6nXdzVqxYFjCGJKEwLMnw GizlPASWk9gTGrWMi9u42of/edylXk4Ik8ajQXFDGYK2TT+pzWW0fFVzO63XtCmz6o7v 1T7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language; bh=B4xuYT7K0tBqsToutVyaAItC4Ei6wqhbJjxZ9fCAOQQ=; b=ZmZtr+7iUUuRWDVPkyF/PsbkYGFOQQz4R4FxZSn9FuLq7qYNEljFsVYl74h+yQAAP/ FubL95eSSVLm9I0Cat2/1KZbKBsBbjNL/ZsGMmxoJxqWTzdTOkTlowCuMDpoGGRkoW0H RRy+3BvgNEKxrEwJRId8K3KKR+qC9yN1HFkrU8QMCUnEvcFtH7lsFTj/fZ05QIzl76mi VVrjUIUYHEEMurD/bdHqpVAwR0Bk+ZC/62kq5FFmWUtug/U+7oX89qAiOa0oS/SjRqPe BRGXt78j+UEWkk1D9jBzEnTgeLxC6Fw9SbV80uWIMHw5s/k6oWGxJ9s6Ue+ljtz5xEAR Pp4Q== X-Gm-Message-State: APjAAAXkfAOb22LXwsoun3TFlEQw9p47l5vJnGUyYgZp50Tcmm2UbNKU X86/w6MBShLlAug1dzOvgTLob8TudMyzGoI1Gyr+x+twADwE7k6HBwq3WnomS3bDZDzVeEVoA1E j7gmDSuB7mx+cMFSMW3r5bKqpxE2RKsquwolsXwQeY2YyAvcjZwd/B1FsSdzJjdwe2mlh1gqmvf YbvRxN3ha/ny6ks79OqtzB8qfw X-Google-Smtp-Source: APXvYqz9F8fM6VtgdymsBi5DKALE2MEngf6wfJlqZnoCJOkUiLzzaxxCxz1JafA+vsQy09jqxw3CnQ== X-Received: by 2002:a81:61c6:: with SMTP id v189mr1167773ywb.415.1574772712189; Tue, 26 Nov 2019 04:51:52 -0800 (PST) Received: from [192.168.10.146] (99-10-92-30.lightspeed.rlghnc.sbcglobal.net. [99.10.92.30]) by smtp.gmail.com with ESMTPSA id b199sm5409843ywh.23.2019.11.26.04.51.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 Nov 2019 04:51:50 -0800 (PST) From: Andrew Dunstan X-Google-Original-From: Andrew Dunstan Subject: Re: pgsql: Close stdin where it's not needed in TestLib.pm procedures To: Michael Paquier , Tom Lane Cc: Andrew Dunstan , pgsql-committers@lists.postgresql.org References: <20191126044302.GC5435@paquier.xyz> <29991.1574752430@sss.pgh.pa.us> <20191126084702.GF5435@paquier.xyz> Openpgp: preference=signencrypt Autocrypt: addr=andrew.dunstan@2ndQuadrant.com; prefer-encrypt=mutual; keydata= xsBNBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX2HBXBx4syI gY6b0ugohXrr274+baoAlvSbq6cAoQuEVrk5IZFzt20b1Xkx65FwGSEj526yiKLocqkJceSq Xr9xcA5SGY+FZv441chh5SU92v4q6z+6LPpoHOh97ptAVXZYNTtU0LevyvD5lja0TzbvJm6C eFXitJfnm1pLEr0DGJCR/iUOl/N62Kh4855zZC7NHIjQHPOvV5Stz/l5ilDhvGVk+xkXFPys SjZoUr1rXhYLpiyi5sR0X9FHXT0KnGuz1F5ERO7ZTLSSQ6fJwPj6gOk9K+vvoKvoeql5ABEB AAHNL0FuZHJldyBEdW5zdGFuIDxhbmRyZXcuZHVuc3RhbkAybmRRdWFkcmFudC5jb20+wsCY BBMBAgBCAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgBYhBOQ+WEYd/Hy/RGkVpZn6f8tZ /DuBAhkBBQJd1pSYBQkSzqMsAAoJEJn6f8tZ/DuBJmEIAIVFBIC3qGqh+YTPVTkfowwxpHz0 tZSPjZ6GS/5y62kgoZrZOVXw+Rg2ceuMM3a+In/RRjTx4bembgYqRKgzXlDfiNBJeq5ioVuN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0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20191126084702.GF5435@paquier.xyz> Content-Type: multipart/mixed; boundary="------------0DA8AA039757B316CA94CC25" Content-Language: en-MW List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------0DA8AA039757B316CA94CC25 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit On 11/26/19 3:47 AM, Michael Paquier wrote: > On Tue, Nov 26, 2019 at 02:13:50AM -0500, Tom Lane wrote: >> Perhaps the "where possible" caveat needs to include a test whether >> IO::Pty is installed? It's evidently not there by default everywhere. >> >> It's possible that we should just move the goalposts and say IO::Pty >> is required for TAP testing. I can foresee that we'll have to do >> that if we ever want automated tests of psql's tab completion, >> for example. > Hmm. I am not sure that we are at that point yet (in which case we'd > need to check after it in configure). Any other modules we require to > be installed are directly imported to our code, but here we visibly > have a dependency forced by the loaded code. My point is that it does > not impact platforms that do not need it, so it seems like a waste to > require for everybody something which is actually necessary only for a > portion of users running the TAP tests. Yeah, I don't want to go that far at this stage at least. here's my proposed fix. I will adjust the code that wants to use it to have a block containing the tests that need the pty code something like this: SKIP: {   skip 3, "no Pty support" unless $have_io_pty;   ... } cheers andrew -- Andrew Dunstan https://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --------------0DA8AA039757B316CA94CC25 Content-Type: text/x-patch; name="fix-testlib-pty.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fix-testlib-pty.patch" diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm index 18b4ce35c2..7d62914218 100644 --- a/src/test/perl/TestLib.pm +++ b/src/test/perl/TestLib.pm @@ -21,6 +21,7 @@ TestLib - helper module for writing PostgreSQL's C tests. # Miscellanea print "on Windows" if $TestLib::windows_os; + print "IO::Pty is available" If $TestLib::have_io_pty; my $path = TestLib::perl2host($backup_dir); ok(check_mode_recursive($stream_dir, 0700, 0600), "check stream dir permissions"); @@ -83,9 +84,10 @@ our @EXPORT = qw( command_checks_all $windows_os + $have_io_pty ); -our ($windows_os, $tmp_check, $log_path, $test_logfile); +our ($windows_os, $tmp_check, $log_path, $test_logfile, $have_io_pty); my @no_stdin; @@ -119,6 +121,9 @@ BEGIN require Win32API::File; Win32API::File->import(qw(createFile OsFHandleOpen CloseHandle)); } + + eval { require IO::Pty; }; + $have_io_pty = 1 unless $@; } =pod @@ -133,6 +138,11 @@ Set to true when running under Windows, except on Cygwin. =back +=item C<$have_io_pty> + +Set to true when IO::Pty is available. + +=back =cut INIT @@ -182,18 +192,17 @@ INIT autoflush $testlog 1; # Settings to close stdin for certain commands. - # On non-Windows, use a pseudo-terminal, so that libraries like openssl - # which open the tty if they think stdin isn't one for a password - # don't block. Windows doesn't have ptys, so just provide an empty - # string for stdin. - if ($windows_os) + # If IO::Pty is present, use a pseudo-terminal, so that libraries like + # openssl which open the tty if they think stdin isn't one for a password + # don't block. Elsewhere just provide an empty string for stdin. + if ($have_io_pty) { - @no_stdin = ('<', \""); + use charnames ':full'; + @no_stdin = ('