Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwcCt-0003aW-F3 for pgsql-committers@arkaria.postgresql.org; Fri, 25 Jun 2021 03:08:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lwcCr-0000jg-5K for pgsql-committers@arkaria.postgresql.org; Fri, 25 Jun 2021 03:08:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwcCq-0000jY-BV for pgsql-committers@lists.postgresql.org; Fri, 25 Jun 2021 03:08:36 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lwcCn-0007pl-Ve for pgsql-committers@lists.postgresql.org; Fri, 25 Jun 2021 03:08:35 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 10EC55C0160; Thu, 24 Jun 2021 23:08:33 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 24 Jun 2021 23:08:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=bc/zZDz12rmI7LtiF4PwfgpJgsf O6Dk3lFqdSy0KbU8=; b=W9noD5ho7eHObmaPs1+oXwVs57U0XOt55vXIZhDRIzf NYc1HwZiJAKGoxVc0vLF92/CAwM9ikcC7S5d/JQo+476v9cOFPTHVFSpYamcC4bn 5LZVl97pzUz3PhkP88hbUcDNDmT96GCwZiPOfT6QJbbEWVFJUYy+YjeA564QcA/O JjhMYBslQgfYFILJwCc8nWIToVkdCvbIegnTkYk3Ru40pYiOWJgtLtCNlELgnURj VtCAUlsdUPW8xRipr8xSiH6iBvGDng8tCic3XLbIIJfplR1DAVp/8PNt+78fvd5o 0BObeIs7ChZKgUlxR84rRaalpEe0Qoa0Ujxls4tfwKw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=bc/zZD z12rmI7LtiF4PwfgpJgsfO6Dk3lFqdSy0KbU8=; b=tr8Mu9HcFchiDCov2g5XxQ Oh8qoWBVu+TF5XXZy1WoMHxsEb9ZPkwQJI37UoNefTwkOJfAi9GU/x2sxlm8rXnB HZBnUvSuG0rQ5FECEbuAdxG8DJmPBDBA/MN/lbuen4xvD6PXJY+9+9CyIJT8rErc DpBfGSRsDz4xfSfSqxBgxXgoopKaL0ZnKq4XM+zDSgRJ8N4n2r5JX6bLC6KLMPTJ 2IDdkqew2aT53j410CN+E1/QsZ2t41D2b2LTS0husMNewkSf3lQOgSBqObKoUx0Y tCUsX1n2/JvnY54d8/cvoV0eW2BrP1EsnUHmYtcEWEHBl7XclljFuw2LGB7XrjZg == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeegiedgieejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpedvgeduuefhtdeuleettdevjeeh heeiveeuieegleetgeeljeelieeuieehgeevhfenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 24 Jun 2021 23:08:31 -0400 (EDT) Date: Fri, 25 Jun 2021 12:08:29 +0900 From: Michael Paquier To: Andrew Dunstan Cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Fix pattern matching logic for logs in TAP tests of pgbench Message-ID: References: <0f49303e-7784-b3ee-200b-cbf67be2eb9e@dunslane.net> <4a58ca30-7d79-8005-b427-9e73f004f457@dunslane.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="7B/Y01ZAdvCqa6d1" Content-Disposition: inline In-Reply-To: <4a58ca30-7d79-8005-b427-9e73f004f457@dunslane.net> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --7B/Y01ZAdvCqa6d1 Content-Type: multipart/mixed; boundary="ckBmSKkjyuCbR/WN" Content-Disposition: inline --ckBmSKkjyuCbR/WN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jun 24, 2021 at 10:26:18PM -0400, Andrew Dunstan wrote: > Since the file isn't read in using slurp_file, that $ won't match > because the lines will end \r\n instead of \n. I did not remember this one with Msys, thanks. I am not sure that there is any need for an eval block here actually once you remove open()? What do you think about something like the attached? -- Michael --ckBmSKkjyuCbR/WN Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pgbench-tap-fix.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench= /t/001_pgbench_with_server.pl index ff5b31d4df..a136e18b0e 100644 --- a/src/bin/pgbench/t/001_pgbench_with_server.pl +++ b/src/bin/pgbench/t/001_pgbench_with_server.pl @@ -1193,28 +1193,29 @@ sub check_pgbench_logs my $log_number =3D 0; for my $log (sort @logs) { - eval { - open my $fh, '<', $log or die "$@"; - my @contents =3D <$fh>; - my $clen =3D @contents; - ok( $min <=3D $clen && $clen <=3D $max, - "transaction count for $log ($clen)"); - my $clen_match =3D grep(/$re/, @contents); - ok($clen_match =3D=3D $clen, "transaction format for $prefix"); - # Show more information if some logs don't match - # to help with debugging. - if ($clen_match !=3D $clen) + # Check the contents of each log file. + my $contents_raw =3D slurp_file($log); + + # On Msys, filter out any CRLF. + $contents_raw =3D~ s/\r\n/\n/g if $Config{osname} eq 'msys'; + my @contents =3D split("\n", $contents_raw); + my $clen =3D @contents; + ok( $min <=3D $clen && $clen <=3D $max, + "transaction count for $log ($clen)"); + my $clen_match =3D grep(/$re/, @contents); + ok($clen_match =3D=3D $clen, "transaction format for $prefix"); + + # Show more information if some logs don't match + # to help with debugging. + if ($clen_match !=3D $clen) + { + foreach my $log (@contents) { - foreach my $log (@contents) - { - print "# Log entry not matching: $log\n" - unless $log =3D~ /$re/; - } + print "# Log entry not matching: $log\n" + unless $log =3D~ /$re/; } - close $fh or die "$@"; - }; + } } - ok(unlink(@logs), "remove log files"); return; } =20 --ckBmSKkjyuCbR/WN-- --7B/Y01ZAdvCqa6d1 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmDVSKwACgkQnvQgOdby QH0FFg//etLQ4+9tr+oZGx7dLbgCWjVm3MARurecQxYPTTpB+SntAIKwrE+oXPWB jfyF3HsqBfRJwfZd7ZJYA4MuPl6oQVhG+ZWoA8jm6zD+13NdPIRwNClgcBH521Hu UUf0sLFzkOx4Ngw2P5eddHvHEfI5gnqnZPnBBV1k2m5/ebJpeAhr28cQkP9q69fV NP7CZ4KXPOxVi85JlvVT6gYNioU6bwWVvqb8QZXijArof9k53eIWt/BXry63wRwv OOefemhzwtfIZ4rW+BxbyCR6zJweWLnbcZbGLg+E43CO9IbWilHBNtiCg8HPj7Me pUwIu3PF/UwTr54+bSOM8Xt9ko+gzO6JU1PeNEUBbQs8N5qeOsjO9Fk2MG20DH+i co/HG5Hll+o8pK3eAMYpr4t5iqBUAPIBwtPu8x8SY/7qeRkQFiQs6WGApowyHjSu Fdor+ADty2xPYOgRZX5Zj/OJvTYxns1bLbOSQCjgcuvu1Wm1V19/eSJ22lROCSr5 BsWnxtxdjBO+I7x/R2stE1hSiozGsoo7ptUML0Iz21ZUaID73pMKB5RNHIyYLSCA Akay19w6kJ6NK0Tl1zfiyJV4qVUmFMzyy2aQDfzZMzUZ2N+teU+v7476V/cP6+HR LMeDo/cZWCm+kp8D/8ytzGIVBKWd4syar39qz7ij2jxfswCECIk= =VjsC -----END PGP SIGNATURE----- --7B/Y01ZAdvCqa6d1--