1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-03 22:24:49 +03:00

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
This commit is contained in:
Michael Paquier 2022-05-21 12:01:48 +09:00
parent 5e5fa32335
commit eaa5ebe046

View File

@ -13,18 +13,16 @@ use Test::More;
# Generate a database with a name made of a range of ASCII characters. # Generate a database with a name made of a range of ASCII characters.
sub generate_db 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) for my $i ($from_char .. $to_char)
{ {
next if $i == 7 || $i == 10 || $i == 13; # skip BEL, LF, and CR next if $i == 7 || $i == 10 || $i == 13; # skip BEL, LF, and CR
$dbname = $dbname . sprintf('%c', $i); $dbname = $dbname . sprintf('%c', $i);
} }
# Exercise backslashes adjacent to double quotes, a Windows special $dbname .= $suffix;
# case.
$dbname = '\\"\\' . $dbname . '\\\\"\\\\\\';
$node->command_ok([ 'createdb', $dbname ]); $node->command_ok([ 'createdb', $dbname ]);
} }
@ -79,10 +77,12 @@ else
{ {
# Default is to use pg_regress to set up the old instance. # Default is to use pg_regress to set up the old instance.
# Create databases with names covering most ASCII bytes # Create databases with names covering most ASCII bytes. The
generate_db($oldnode, 1, 45); # first name exercises backslashes adjacent to double quotes, a
generate_db($oldnode, 46, 90); # Windows special case.
generate_db($oldnode, 91, 127); 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. # Grab any regression options that may be passed down by caller.
my $extra_opts = $ENV{EXTRA_REGRESS_OPTS} || ""; my $extra_opts = $ENV{EXTRA_REGRESS_OPTS} || "";
@ -99,7 +99,7 @@ else
my $rc = my $rc =
system($ENV{PG_REGRESS} system($ENV{PG_REGRESS}
. "$extra_opts " . " $extra_opts "
. "--dlpath=\"$dlpath\" " . "--dlpath=\"$dlpath\" "
. "--bindir= " . "--bindir= "
. "--host=" . "--host="
@ -121,6 +121,7 @@ else
print "=== EOF ===\n"; print "=== EOF ===\n";
} }
} }
is($rc, 0, 'regression tests pass');
} }
# Before dumping, get rid of objects not existing or not supported in later # Before dumping, get rid of objects not existing or not supported in later