Msys2 tweaks for pg_validatebackup corruption test
1. Tell Msys2 not to mangle the tablespace map parameter
2. If rmdir doesn't work, fall back to trying unlink on the entry in
pg_tblspc.
Discussion:
@@ -16,6 +16,9 @@ $master->start;
# Include a user-defined tablespace in the hopes of detecting problems in that
# area.
my $source_ts_path = TestLib::perl2host(TestLib::tempdir_short());
+my $source_ts_prefix = $source_ts_path;
+$source_ts_prefix =~ s!(^[A-Z]:/[^/]*)/.*!$1!;
+
$master->safe_psql('postgres', <<EOM);
CREATE TABLE x1 (a int);
INSERT INTO x1 VALUES (111);
@@ -105,6 +108,10 @@ for my $scenario (@scenario)
# Take a backup and check that it validates OK.
my $backup_path = $master->backup_dir . '/' . $name;
my $backup_ts_path = TestLib::perl2host(TestLib::tempdir_short());
+ # The tablespace map parameter confuses Msys2, which tries to mangle
+ # it. Tell it not to.
+ # See https://www.msys2.org/wiki/Porting/#filesystem-namespaces
+ local $ENV{MSYS2_ARG_CONV_EXCL} = $source_ts_prefix;
$master->command_ok(['pg_basebackup', '-D', $backup_path, '--no-sync',
'-T', "${source_ts_path}=${backup_ts_path}"],
"base backup ok");
@@ -179,7 +186,14 @@ sub mutilate_missing_tablespace
my $pathname = "$backup_path/pg_tblspc/$tsoid";
if ($windows_os)
{
- rmdir($pathname) || die "$pathname: $!";
+ # rmdir works on some windows setups, unlink on others.
+ # Instead of trying to implement precise rules, just try one and then
+ # the other.
+ unless (rmdir($pathname))
+ {
+ my $err = $!;
+ unlink($pathname) || die "$pathname: rmdir: $err, unlink: $!";
+ }
}
else
{
