Here's a patch to provide for the pg_upgrade tests to be run in MSVC builds. I want to get this running on the buildfarm before long on HEAD and REL9_2_STABLE.

cheers

andrew
diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm
index 3923532..235a150 100644
--- a/src/tools/msvc/Install.pm
+++ b/src/tools/msvc/Install.pm
@@ -37,9 +37,16 @@ sub Install
 	$| = 1;
 
 	my $target = shift;
-	our $config;
-	require "config_default.pl";
-	require "config.pl" if (-f "config.pl");
+	# if called from vcregress, the config will be passed to us
+	# so no need to re-include these
+	our $config = shift;
+	unless ($config)
+	{
+		# suppress warning about harmless redeclaration of $config
+		no warnings 'misc'; 
+		require "config_default.pl";
+		require "config.pl" if (-f "config.pl");
+	}
 
 	chdir("../../..")    if (-f "../../../configure");
 	chdir("../../../..") if (-f "../../../../configure");
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 530770c..fed4916 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -9,15 +9,19 @@ our $config;
 use Cwd;
 use File::Copy;
 
+use Install qw(Install);
+
 my $startdir = getcwd();
 
 chdir "../../.." if (-d "../../../src/tools/msvc");
 
+my $topdir = getcwd();
+
 require 'src/tools/msvc/config_default.pl';
 require 'src/tools/msvc/config.pl' if (-f 'src/tools/msvc/config.pl');
 
 # buildenv.pl is for specifying the build environment settings
-# it should contian lines like:
+# it should contain lines like:
 # $ENV{PATH} = "c:/path/to/bison/bin;$ENV{PATH}";
 
 if (-e "src/tools/msvc/buildenv.pl")
@@ -27,7 +31,7 @@ if (-e "src/tools/msvc/buildenv.pl")
 
 my $what = shift || "";
 if ($what =~
-	/^(check|installcheck|plcheck|contribcheck|ecpgcheck|isolationcheck)$/i)
+	/^(check|installcheck|plcheck|contribcheck|ecpgcheck|isolationcheck|upgradecheck)$/i)
 {
 	$what = uc $what;
 }
@@ -73,7 +77,8 @@ my %command = (
 	INSTALLCHECK   => \&installcheck,
 	ECPGCHECK      => \&ecpgcheck,
 	CONTRIBCHECK   => \&contribcheck,
-	ISOLATIONCHECK => \&isolationcheck,);
+	ISOLATIONCHECK => \&isolationcheck,
+    UPGRADECHECK   => \&upgradecheck,);
 
 my $proc = $command{$what};
 
@@ -231,6 +236,76 @@ sub contribcheck
 	exit $mstat if $mstat;
 }
 
+sub upgradecheck
+{
+	my $status;
+	my $cwd = getcwd();
+
+	# Much of this comes from the pg_upgrade test.sh script,
+	# but it only covers the --install case, and not the case
+	# where the old and new source or bin dirs are different.
+	# i.e. only the this version to this version check. That's
+	# what pg_upgrade's "make check" does.
+
+	$ENV{PGPORT} ||= 50432;
+	my $tmp_root = "$topdir/contrib/pg_upgrade/tmp_check";
+	mkdir $tmp_root unless -d $tmp_root;
+	my $tmp_install = "$tmp_root/install";
+	print "Setting up temp install\n\n";
+	Install($tmp_install, $config);
+	# Install does a chdir, so change back after that
+	chdir $cwd;
+	my ($bindir,$libdir,$oldsrc,$newsrc) = 
+	  ("$tmp_install/bin", "$tmp_install/lib", $topdir, $topdir);
+	$ENV{PATH} = "$bindir;$ENV{PATH}";
+	my $data = "$tmp_root/data";
+	$ENV{PGDATA} = $data;
+	my $logdir = "$topdir/contrib/pg_upgrade/log";
+	mkdir $logdir unless -d $logdir;
+	print "\nRunning initdb on old cluster\n\n";
+	system("initdb");
+	print "\nStarting old cluster\n\n";
+	system("pg_ctl start -l $logdir/postmaster1.log -w");
+	print "\nSetting up data for upgrading\n\n";
+	installcheck();
+	# now we can chdir into the source dir
+	chdir "$topdir/contrib/pg_upgrade";
+	print "\nDuming old cluster\n\n";
+	system("pg_dumpall -f $tmp_root/dump1.sql");
+	print "\nStopping old cluster\n\n";
+	system("pg_ctl -m fast stop");
+	rename $data, "$data.old";
+	print "\nSetting up new cluster\n\n";
+	system("initdb");
+	print "\nRunning pg_upgrade\n\n";
+	system("pg_upgrade -d $data.old -D $data -b $bindir -B $bindir");
+	print "\nStarting new cluster\n\n";
+	system("pg_ctl -l $logdir/postmaster2.log -w start");
+	print "\nSetting up stats on new cluster\n\n";
+	system(".\\analyze_new_cluster.bat");
+	print "\nDumping new cluster\n\n";
+	system("pg_dumpall -f $tmp_root/dump2.sql");
+	print "\nStopping new cluster\n\n";
+	system("pg_ctl -m fast stop");
+	print "\nDeleting old cluster\n\n";
+	system(".\\delete_old_cluster.bat");
+	print "\nComparing old and new cluster dumps\n\n";
+
+	# If any of the above failed, the following will also fail, so
+	# this should be a sufficient check of the whole thing.
+	system("diff -q $tmp_root/dump1.sql $tmp_root/dump2.sql");
+	$status = $?;
+	if (!$status)
+	{
+		print "PASSED\n";
+	}
+	else
+	{
+		print "dumps not identical!\n";
+		exit(1);
+	}
+}
+
 sub fetchRegressOpts
 {
 	my $handle;
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to