From eaa5ebe046c4f247d843bdfd36da4c28be9dbfab Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Sat, 21 May 2022 12:01:48 +0900 Subject: [PATCH] Improve and fix some issues in the TAP tests of pg_upgrade This is based on a set of suggestions from Noah, with the following changes made: - The set of databases created in the tests are now prefixed with "regression" to not trigger any warnings with name restrictions when compiling the code with -DENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS, and now only the first name checks after the Windows case of double quotes mixed with backslashes. - Fix an issue with EXTRA_REGRESS_OPTS, which were not processed in a way consistent with 027_stream_regress.pl (missing space between the option string and pg_regress). This got introduced in 7dd3ee5. - Add a check on the exit code of the pg_regress command, to catch failures after running the regression tests. Reviewed-by: Noah Misch Discussion: https://postgr.es/m/YoHhWD5vQzb2mmiF@paquier.xyz --- src/bin/pg_upgrade/t/002_pg_upgrade.pl | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl index 8372a85e6ef..75ac768a96e 100644 --- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl +++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl @@ -13,18 +13,16 @@ use Test::More; # Generate a database with a name made of a range of ASCII characters. sub generate_db { - my ($node, $from_char, $to_char) = @_; + my ($node, $prefix, $from_char, $to_char, $suffix) = @_; - my $dbname = ''; + my $dbname = $prefix; for my $i ($from_char .. $to_char) { next if $i == 7 || $i == 10 || $i == 13; # skip BEL, LF, and CR $dbname = $dbname . sprintf('%c', $i); } - # Exercise backslashes adjacent to double quotes, a Windows special - # case. - $dbname = '\\"\\' . $dbname . '\\\\"\\\\\\'; + $dbname .= $suffix; $node->command_ok([ 'createdb', $dbname ]); } @@ -79,10 +77,12 @@ else { # Default is to use pg_regress to set up the old instance. - # Create databases with names covering most ASCII bytes - generate_db($oldnode, 1, 45); - generate_db($oldnode, 46, 90); - generate_db($oldnode, 91, 127); + # Create databases with names covering most ASCII bytes. The + # first name exercises backslashes adjacent to double quotes, a + # Windows special case. + generate_db($oldnode, 'regression\\"\\', 1, 45, '\\\\"\\\\\\'); + generate_db($oldnode, 'regression', 46, 90, ''); + generate_db($oldnode, 'regression', 91, 127, ''); # Grab any regression options that may be passed down by caller. my $extra_opts = $ENV{EXTRA_REGRESS_OPTS} || ""; @@ -99,7 +99,7 @@ else my $rc = system($ENV{PG_REGRESS} - . "$extra_opts " + . " $extra_opts " . "--dlpath=\"$dlpath\" " . "--bindir= " . "--host=" @@ -121,6 +121,7 @@ else print "=== EOF ===\n"; } } + is($rc, 0, 'regression tests pass'); } # Before dumping, get rid of objects not existing or not supported in later