1 # -*-perl-*- hey - emacs - this is a perl file
3 # src/tools/msvc/vcregress.pl
12 use Install qw(Install);
14 my $startdir = getcwd();
16 chdir "../../.." if (-d "../../../src/tools/msvc");
18 my $topdir = getcwd();
20 require 'src/tools/msvc/config_default.pl';
21 require 'src/tools/msvc/config.pl' if (-f 'src/tools/msvc/config.pl');
23 # buildenv.pl is for specifying the build environment settings
24 # it should contain lines like:
25 # $ENV{PATH} = "c:/path/to/bison/bin;$ENV{PATH}";
27 if (-e "src/tools/msvc/buildenv.pl")
29 require "src/tools/msvc/buildenv.pl";
32 my $what = shift || "";
34 /^(check|installcheck|plcheck|contribcheck|ecpgcheck|isolationcheck|upgradecheck)$/i
44 # use a capital C here because config.pl has $config
45 my $Config = -e "release/postgres/postgres.exe" ? "Release" : "Debug";
47 copy("$Config/refint/refint.dll", "src/test/regress");
48 copy("$Config/autoinc/autoinc.dll", "src/test/regress");
49 copy("$Config/regress/regress.dll", "src/test/regress");
50 copy("$Config/dummy_seclabel/dummy_seclabel.dll", "src/test/regress");
52 $ENV{PATH} = "../../../$Config/libpq;../../$Config/libpq;$ENV{PATH}";
58 $schedule = "parallel" if ($what eq 'CHECK' || $what =~ /PARALLEL/);
61 $ENV{PERL5LIB} = "$topdir/src/tools/msvc";
64 $maxconn = "--max_connections=$ENV{MAX_CONNECTIONS}"
65 if $ENV{MAX_CONNECTIONS};
68 $temp_config = "--temp-config=\"$ENV{TEMP_CONFIG}\""
71 chdir "src/test/regress";
76 INSTALLCHECK => \&installcheck,
77 ECPGCHECK => \&ecpgcheck,
78 CONTRIBCHECK => \&contribcheck,
79 ISOLATIONCHECK => \&isolationcheck,
80 UPGRADECHECK => \&upgradecheck,);
82 my $proc = $command{$what};
90 ########################################################################
95 "../../../$Config/pg_regress/pg_regress",
97 "--psqldir=../../../$Config/psql",
98 "--schedule=${schedule}_schedule",
99 "--encoding=SQL_ASCII",
101 push(@args, $maxconn) if $maxconn;
103 my $status = $? >> 8;
104 exit $status if $status;
110 "../../../$Config/pg_regress/pg_regress",
112 "--psqldir=../../../$Config/psql",
113 "--schedule=${schedule}_schedule",
114 "--encoding=SQL_ASCII",
116 "--temp-install=./tmp_check",
117 "--top-builddir=\"$topdir\"");
118 push(@args, $maxconn) if $maxconn;
119 push(@args, $temp_config) if $temp_config;
121 my $status = $? >> 8;
122 exit $status if $status;
128 system("msbuild ecpg_regression.proj /p:config=$Config");
129 my $status = $? >> 8;
130 exit $status if $status;
131 chdir "$topdir/src/interfaces/ecpg/test";
134 "../../../../$Config/pg_regress_ecpg/pg_regress_ecpg",
135 "--psqldir=../../../$Config/psql",
136 "--dbname=regress1,connectdb",
137 "--create-role=connectuser,connectdb",
138 "--schedule=${schedule}_schedule",
139 "--encoding=SQL_ASCII",
141 "--temp-install=./tmp_chk",
142 "--top-builddir=\"$topdir\"");
143 push(@args, $maxconn) if $maxconn;
146 exit $status if $status;
151 chdir "../isolation";
152 copy("../../../$Config/isolationtester/isolationtester.exe",
153 "../../../$Config/pg_isolation_regress");
155 "../../../$Config/pg_isolation_regress/pg_isolation_regress",
156 "--psqldir=../../../$Config/psql",
158 "--schedule=./isolation_schedule");
159 push(@args, $maxconn) if $maxconn;
161 my $status = $? >> 8;
162 exit $status if $status;
169 foreach my $pl (glob("*"))
171 next unless -d "$pl/sql" && -d "$pl/expected";
172 my $lang = $pl eq 'tcl' ? 'pltcl' : $pl;
173 if ($lang eq 'plpython')
175 next unless -d "../../$Config/plpython2";
180 next unless -d "../../$Config/$lang";
182 my @lang_args = ("--load-extension=$lang");
184 my @tests = fetchTests();
185 if ($lang eq 'plperl')
188 # run both trusted and untrusted perl tests
189 push(@lang_args, "--load-extension=plperlu");
191 # assume we're using this perl to built postgres
192 # test if we can run two interpreters in one backend, and if so
193 # run the trusted/untrusted interaction tests
195 if ($Config{usemultiplicity} eq 'define')
197 push(@tests, 'plperl_plperlu');
201 "============================================================\n";
202 print "Checking $lang\n";
204 "../../../$Config/pg_regress/pg_regress",
205 "--psqldir=../../../$Config/psql",
206 "--dbname=pl_regression", @lang_args, @tests);
208 my $status = $? >> 8;
209 exit $status if $status;
218 chdir "../../../contrib";
220 foreach my $module (glob("*"))
222 # these configuration-based exclusions must match Install.pm
223 next if ($module eq "uuid-ossp" && !defined($config->{uuid}));
224 next if ($module eq "sslinfo" && !defined($config->{openssl}));
225 next if ($module eq "xml2" && !defined($config->{xml}));
226 next if ($module eq "sepgsql");
229 unless -d "$module/sql"
230 && -d "$module/expected"
231 && (-f "$module/GNUmakefile" || -f "$module/Makefile");
234 "============================================================\n";
235 print "Checking $module\n";
236 my @tests = fetchTests();
237 my @opts = fetchRegressOpts();
239 "../../$Config/pg_regress/pg_regress",
240 "--psqldir=../../$Config/psql",
241 "--dbname=contrib_regression", @opts, @tests);
243 my $status = $? >> 8;
247 exit $mstat if $mstat;
250 # Run "initdb", then reconfigure authentication.
254 system('initdb', '-N') == 0 and system(
255 "$topdir/$Config/pg_regress/pg_regress", '--config-auth',
264 # Much of this comes from the pg_upgrade test.sh script,
265 # but it only covers the --install case, and not the case
266 # where the old and new source or bin dirs are different.
267 # i.e. only this version to this version check. That's
268 # what pg_upgrade's "make check" does.
270 $ENV{PGHOST} = 'localhost';
271 $ENV{PGPORT} ||= 50432;
272 my $tmp_root = "$topdir/src/bin/pg_upgrade/tmp_check";
273 (mkdir $tmp_root || die $!) unless -d $tmp_root;
274 my $tmp_install = "$tmp_root/install";
275 print "Setting up temp install\n\n";
276 Install($tmp_install, "all", $config);
278 # Install does a chdir, so change back after that
280 my ($bindir, $libdir, $oldsrc, $newsrc) =
281 ("$tmp_install/bin", "$tmp_install/lib", $topdir, $topdir);
282 $ENV{PATH} = "$bindir;$ENV{PATH}";
283 my $data = "$tmp_root/data";
284 $ENV{PGDATA} = "$data.old";
285 my $logdir = "$topdir/src/bin/pg_upgrade/log";
286 (mkdir $logdir || die $!) unless -d $logdir;
287 print "\nRunning initdb on old cluster\n\n";
288 standard_initdb() or exit 1;
289 print "\nStarting old cluster\n\n";
290 system("pg_ctl start -l $logdir/postmaster1.log -w") == 0 or exit 1;
291 print "\nSetting up data for upgrading\n\n";
294 # now we can chdir into the source dir
295 chdir "$topdir/src/bin/pg_upgrade";
296 print "\nDumping old cluster\n\n";
297 system("pg_dumpall -f $tmp_root/dump1.sql") == 0 or exit 1;
298 print "\nStopping old cluster\n\n";
299 system("pg_ctl -m fast stop") == 0 or exit 1;
300 $ENV{PGDATA} = "$data";
301 print "\nSetting up new cluster\n\n";
302 standard_initdb() or exit 1;
303 print "\nRunning pg_upgrade\n\n";
304 system("pg_upgrade -d $data.old -D $data -b $bindir -B $bindir") == 0
306 print "\nStarting new cluster\n\n";
307 system("pg_ctl -l $logdir/postmaster2.log -w start") == 0 or exit 1;
308 print "\nSetting up stats on new cluster\n\n";
309 system(".\\analyze_new_cluster.bat") == 0 or exit 1;
310 print "\nDumping new cluster\n\n";
311 system("pg_dumpall -f $tmp_root/dump2.sql") == 0 or exit 1;
312 print "\nStopping new cluster\n\n";
313 system("pg_ctl -m fast stop") == 0 or exit 1;
314 print "\nDeleting old cluster\n\n";
315 system(".\\delete_old_cluster.bat") == 0 or exit 1;
316 print "\nComparing old and new cluster dumps\n\n";
318 system("diff -q $tmp_root/dump1.sql $tmp_root/dump2.sql");
326 print "dumps not identical!\n";
334 open($handle, "<GNUmakefile")
335 || open($handle, "<Makefile")
336 || die "Could not open Makefile";
343 if ($m =~ /^\s*REGRESS_OPTS\s*=(.*)/m)
346 # Substitute known Makefile variables, then ignore options that retain
347 # an unhandled variable reference. Ignore anything that isn't an
348 # option starting with "--".
350 s/\Q$(top_builddir)\E/\"$topdir\"/;
351 $_ !~ /\$\(/ && $_ =~ /^--/
354 if ($m =~ /^\s*ENCODING\s*=\s*(\S+)/m)
356 push @opts, "--encoding=$1";
358 if ($m =~ /^\s*NO_LOCALE\s*=\s*\S+/m)
360 push @opts, "--no-locale";
369 open($handle, "<GNUmakefile")
370 || open($handle, "<Makefile")
371 || die "Could not open Makefile";
378 if ($m =~ /^REGRESS\s*=\s*(.*)$/gm)
383 if ($m =~ /contrib\/pgcrypto/)
386 # pgcrypto is special since the tests depend on the
387 # configuration of the build
391 ? GetTests("OSSL_TESTS", $m)
392 : GetTests("INT_TESTS", $m);
395 ? GetTests("ZLIB_TST", $m)
396 : GetTests("ZLIB_OFF_TST", $m);
397 $t =~ s/\$\(CF_TESTS\)/$cftests/;
398 $t =~ s/\$\(CF_PGP_TESTS\)/$pgptests/;
402 return split(/\s+/, $t);
407 my $testname = shift;
409 if ($m =~ /^$testname\s*=\s*(.*)$/gm)
419 "Usage: vcregress.pl ",
420 "<check|installcheck|plcheck|contribcheck|isolationcheck|ecpgcheck|upgradecheck> [schedule]\n";