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 1haCOQ-00031A-N6 for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Jun 2019 04:58:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1haCOP-0006DJ-Hc for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Jun 2019 04:58:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1haCOP-0006DB-0n for pgsql-hackers@lists.postgresql.org; Mon, 10 Jun 2019 04:58:49 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1haCOK-0001iC-Sj for pgsql-hackers@postgresql.org; Mon, 10 Jun 2019 04:58:48 +0000 Received: by mail-pf1-x441.google.com with SMTP id 81so4519730pfy.13 for ; Sun, 09 Jun 2019 21:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=BqcRetgJRfEvLxrICSGMmjDpuBp0JXOGdxwdBC563lY=; b=ceBEg4oso4qYvtdMwoIU5A90KcegZrGZ8rWZC60+XxvNkS62NnQP8y7wbe/LYYfwUc z7fmeOTVM4A/J5CwqC6W9Q9z7nx09fOpgl+KW/OR47//r1AU2vWy1fklaj4LaRRz6Tz+ w7BvldzLTxzd46ETViX1ptL6Jj+67IEWEA7Tc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=BqcRetgJRfEvLxrICSGMmjDpuBp0JXOGdxwdBC563lY=; b=ZBBCD+YG4mJo4zcezh7I0ohztD+tGVQ+qZrTVmzgQEE6PBZ1+szM/KIThnHdWJMG6c iDhtbLbZJQ2rw6OfxMTEaYyyuO15BAXyl02tAnVfbyeKz8DmBDbaDbzeVEAuEsA+C7oh A/UIsGMg8gV621ddSBLJ1d+j0ozuPy8rB8i9fat1tdTPult0Of7270m4yINg9RMZQ0Pa sARbrAMAPBvpJDSv5oT24NRXXSsWPGxqOMOswkcI7ezwrH6oE5t5nUiU5oV1lwWT1crQ LNUnGA2bSoCs31gpV1FIFnvBItbuHtuIyjjPlvo33DpxFstestV7+ENFa7HAoW9gpE+Q 3Xjg== X-Gm-Message-State: APjAAAUlTHobQUooW3rubTipJRhZS2HB+NTuTF7cQ3S6/4AoNCbGIqkf p9ZdNsAvyIYBNQVRcj5FMczWaxEoms4= X-Google-Smtp-Source: APXvYqxwts+nGfvioYyla1kXUNknI7ajNZwAzazhdwGASiehsGVkLKq/7asnDWTbLaD+Zbx4EjmBlA== X-Received: by 2002:a62:4dc5:: with SMTP id a188mr73347583pfb.8.1560142721752; Sun, 09 Jun 2019 21:58:41 -0700 (PDT) Received: from rfd.leadboat.com (108-233-125-46.lightspeed.sntcca.sbcglobal.net. [108.233.125.46]) by smtp.gmail.com with ESMTPSA id j22sm8841415pfh.71.2019.06.09.21.58.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Jun 2019 21:58:40 -0700 (PDT) Date: Sun, 9 Jun 2019 21:58:38 -0700 From: Noah Misch To: pgsql-hackers@postgresql.org Subject: Fix testing on msys when builddir is under /c mount point Message-ID: <20190610045838.GA238501@rfd.leadboat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="HcAYCG3uE/tztfnV" Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Several TAP test suites have a need to translate from an msys path to a Windows path. They currently use two ways to do that: 1. TestLib::real_dir, new in v11, is sound but works for directories only. 2. The $vfs_path approach is semi-private to PostgresNode.pm and 017_shm.pl, and it does not work if the file falls in a mount point other than "/". For example, it has been doing the wrong thing when builddir is /c/nm/postgresql (falling in mount point /c). I'd like to fix the mount point problem and consolidate these two methods. I plan to call it TestLib::perl2host, since it translates a path in Perl's notion of the filesystem to a path in the @host@ notion of the filesystem. Attached. --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="msys2-mount-point-v1.patch" diff --git a/src/bin/pg_checksums/t/002_actions.pl b/src/bin/pg_checksums/t/002_actions.pl index ce24d06..59228b9 100644 --- a/src/bin/pg_checksums/t/002_actions.pl +++ b/src/bin/pg_checksums/t/002_actions.pl @@ -183,7 +183,7 @@ check_relation_corruption($node, 'corrupt1', 'pg_default'); my $basedir = $node->basedir; my $tablespace_dir = "$basedir/ts_corrupt_dir"; mkdir($tablespace_dir); -$tablespace_dir = TestLib::real_dir($tablespace_dir); +$tablespace_dir = TestLib::perl2host($tablespace_dir); $node->safe_psql('postgres', "CREATE TABLESPACE ts_corrupt LOCATION '$tablespace_dir';"); check_relation_corruption($node, 'corrupt2', 'ts_corrupt'); diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm index 8d5ad6b..6019f37 100644 --- a/src/test/perl/PostgresNode.pm +++ b/src/test/perl/PostgresNode.pm @@ -107,15 +107,6 @@ our @EXPORT = qw( our ($use_tcp, $test_localhost, $test_pghost, $last_host_assigned, $last_port_assigned, @all_nodes, $died); -# Windows path to virtual file system root - -our $vfs_path = ''; -if ($Config{osname} eq 'msys') -{ - $vfs_path = `cd / && pwd -W`; - chomp $vfs_path; -} - INIT { @@ -945,7 +936,7 @@ primary_conninfo='$root_connstr' sub enable_restoring { my ($self, $root_node) = @_; - my $path = $vfs_path . $root_node->archive_dir; + my $path = TestLib::perl2host($root_node->archive_dir); my $name = $self->name; print "### Enabling WAL restore for node \"$name\"\n"; @@ -990,7 +981,7 @@ sub set_standby_mode sub enable_archiving { my ($self) = @_; - my $path = $vfs_path . $self->archive_dir; + my $path = TestLib::perl2host($self->archive_dir); my $name = $self->name; print "### Enabling WAL archiving for node \"$name\"\n"; diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm index f8eb705..d2a9828 100644 --- a/src/test/perl/TestLib.pm +++ b/src/test/perl/TestLib.pm @@ -166,22 +166,31 @@ sub tempdir_short return File::Temp::tempdir(CLEANUP => 1); } -# Return the real directory for a virtual path directory under msys. -# The directory must exist. If it's not an existing directory or we're -# not under msys, return the input argument unchanged. -sub real_dir +# Translate a Perl file name to a host file name. Currently, this is a no-op +# except for the case of Perl=msys and host=mingw32. The subject need not +# exist, but its parent directory must exist. +sub perl2host { - my $dir = "$_[0]"; - return $dir unless -d $dir; - return $dir unless $Config{osname} eq 'msys'; + my ($subject) = @_; + return $subject unless $Config{osname} eq 'msys'; my $here = cwd; - chdir $dir; + my $leaf; + if (chdir $subject) + { + $leaf = ''; + } + else + { + $leaf = '/' . basename $subject; + my $parent = dirname $subject; + chdir $parent or die "could not chdir \"$parent\": $!"; + } # this odd way of calling 'pwd -W' is the only way that seems to work. - $dir = qx{sh -c "pwd -W"}; + my $dir = qx{sh -c "pwd -W"}; chomp $dir; chdir $here; - return $dir; + return $dir . $leaf; } sub system_log diff --git a/src/test/recovery/t/014_unlogged_reinit.pl b/src/test/recovery/t/014_unlogged_reinit.pl index 103c0a2..ee05e1a 100644 --- a/src/test/recovery/t/014_unlogged_reinit.pl +++ b/src/test/recovery/t/014_unlogged_reinit.pl @@ -30,7 +30,7 @@ ok(-f "$pgdata/$baseUnloggedPath", 'main fork in base exists'); my $tablespaceDir = TestLib::tempdir; -my $realTSDir = TestLib::real_dir($tablespaceDir); +my $realTSDir = TestLib::perl2host($tablespaceDir); $node->safe_psql('postgres', "CREATE TABLESPACE ts1 LOCATION '$realTSDir'"); $node->safe_psql('postgres', diff --git a/src/test/recovery/t/017_shm.pl b/src/test/recovery/t/017_shm.pl index f16821d..7f10ff5 100644 --- a/src/test/recovery/t/017_shm.pl +++ b/src/test/recovery/t/017_shm.pl @@ -12,14 +12,6 @@ use Time::HiRes qw(usleep); plan tests => 5; -# See PostgresNode -my $vfs_path = ''; -if ($Config{osname} eq 'msys') -{ - $vfs_path = `cd / && pwd -W`; - chomp $vfs_path; -} - my $tempdir = TestLib::tempdir; my $port; @@ -103,10 +95,11 @@ log_ipcs(); # Scenarios involving no postmaster.pid, dead postmaster, and a live backend. # Use a regress.c function to emulate the responsiveness of a backend working # through a CPU-intensive task. +my $regress_shlib = TestLib::perl2host($ENV{REGRESS_SHLIB}); $gnat->safe_psql('postgres', <