Copy refint.so and autoinc.so into the src/test/regress directory during
[PostgreSQL.git] / src / tools / msvc / vcregress.pl
blobd6aa2ff0e34e82129bdd8e986b4cabd7fc7ca076
2 # -*-perl-*- hey - emacs - this is a perl file
4 # $PostgreSQL$
6 use strict;
8 our $config;
10 use Cwd;
11 use File::Copy;
13 my $startdir = getcwd();
15 chdir "../../.." if (-d "../../../src/tools/msvc");
17 # buildenv.pl is for specifying the build environment settings
18 # it should contian lines like:
19 # $ENV{PATH} = "c:/path/to/bison/bin;$ENV{PATH}";
21 if ( -e "src/tools/msvc/buildenv.pl")
23 require "src/tools/msvc/buildenv.pl";
26 my $what = shift || "";
27 if ($what =~ /^(check|installcheck|plcheck|contribcheck|ecpgcheck)$/i)
29 $what = uc $what;
31 else
33 usage();
36 # use a capital C here because config.pl has $config
37 my $Config = -e "release/postgres/postgres.exe" ? "Release" : "Debug";
39 copy("$Config/refint/refint.dll","src/test/regress");
40 copy("$Config/autoinc/autoinc.dll","src/test/regress");
41 copy("$Config/regress/regress.dll","src/test/regress");
43 $ENV{PATH} = "../../../$Config/libpq;../../$Config/libpq;$ENV{PATH}";
45 my $schedule = shift;
46 unless ($schedule)
48 $schedule = "serial";
49 $schedule = "parallel" if ($what eq 'CHECK' || $what =~ /PARALLEL/);
52 my $temp_port;
53 if (-e "src/tools/msvc/config.pl")
55 eval{
56 require "src/tools/msvc/config.pl";
57 $temp_port = $config->{'--with-pgport'};
60 $temp_port ||= 55432;
62 my $topdir = getcwd();
64 $ENV{PERL5LIB} = "$topdir/src/tools/msvc";
66 my $maxconn = "";
67 $maxconn = "--max_connections=$ENV{MAX_CONNECTIONS}"
68 if $ENV{MAX_CONNECTIONS};
70 my $temp_config = "";
71 $temp_config = "--temp-config=\"$ENV{TEMP_CONFIG}\""
72 if $ENV{TEMP_CONFIG};
74 chdir "src/test/regress";
76 my %command = (
77 CHECK => \&check,
78 PLCHECK => \&plcheck,
79 INSTALLCHECK => \&installcheck,
80 ECPGCHECK => \&ecpgcheck,
81 CONTRIBCHECK => \&contribcheck
84 my $proc = $command{$what};
86 exit 3 unless $proc;
88 &$proc();
90 exit 0;
92 ########################################################################
94 sub installcheck
96 my @args = (
97 "../../../$Config/pg_regress/pg_regress",
98 "--psqldir=../../../$Config/psql",
99 "--schedule=${schedule}_schedule",
100 "--multibyte=SQL_ASCII",
101 "--load-language=plpgsql",
102 "--no-locale"
104 push(@args,$maxconn) if $maxconn;
105 system(@args);
106 my $status = $? >>8;
107 exit $status if $status;
110 sub check
112 my @args = (
113 "../../../$Config/pg_regress/pg_regress",
114 "--psqldir=../../../$Config/psql",
115 "--schedule=${schedule}_schedule",
116 "--multibyte=SQL_ASCII",
117 "--load-language=plpgsql",
118 "--no-locale",
119 "--temp-install=./tmp_check",
120 "--top-builddir=\"$topdir\"",
121 "--temp-port=$temp_port"
123 push(@args,$maxconn) if $maxconn;
124 push(@args,$temp_config) if $temp_config;
125 system(@args);
126 my $status = $? >>8;
127 exit $status if $status;
130 sub ecpgcheck
132 chdir $startdir;
133 system("msbuild ecpg_regression.proj /p:config=$Config");
134 my $status = $? >>8;
135 exit $status if $status;
136 chdir "$topdir/src/interfaces/ecpg/test";
137 $schedule="ecpg";
138 my @args = (
139 "../../../../$Config/pg_regress_ecpg/pg_regress_ecpg",
140 "--psqldir=../../../$Config/psql",
141 "--dbname=regress1,connectdb",
142 "--create-role=connectuser,connectdb",
143 "--schedule=${schedule}_schedule",
144 "--multibyte=SQL_ASCII",
145 "--load-language=plpgsql",
146 "--no-locale",
147 "--temp-install=./tmp_chk",
148 "--top-builddir=\"$topdir\"",
149 "--temp-port=$temp_port"
151 push(@args,$maxconn) if $maxconn;
152 system(@args);
153 $status = $? >>8;
154 exit $status if $status;
157 sub plcheck
159 chdir "../../pl";
161 foreach my $pl (glob("*"))
163 next unless -d "$pl/sql" && -d "$pl/expected";
164 my $lang = $pl eq 'tcl' ? 'pltcl' : $pl;
165 next unless -d "../../$Config/$lang";
166 $lang = 'plpythonu' if $lang eq 'plpython';
167 chdir $pl;
168 print "============================================================\n";
169 print "Checking $lang\n";
170 my @tests = fetchTests();
171 my @args = (
172 "../../../$Config/pg_regress/pg_regress",
173 "--psqldir=../../../$Config/psql",
174 "--dbname=pl_regression","--load-language=$lang",@tests
176 system(@args);
177 my $status = $? >> 8;
178 exit $status if $status;
179 chdir "..";
182 chdir "../../..";
185 sub contribcheck
187 chdir "../../../contrib";
188 my $mstat = 0;
189 foreach my $module (glob("*"))
191 next unless -d "$module/sql" &&
192 -d "$module/expected" &&
193 (-f "$module/Makefile" || -f "$module/GNUmakefile");
194 chdir $module;
195 print "============================================================\n";
196 print "Checking $module\n";
197 my @tests = fetchTests();
198 my @args = (
199 "../../$Config/pg_regress/pg_regress",
200 "--psqldir=../../$Config/psql",
201 "--dbname=contrib_regression",@tests
203 system(@args);
204 my $status = $? >> 8;
205 $mstat ||= $status;
206 chdir "..";
208 exit $mstat if $mstat;
211 sub fetchTests
214 my $handle;
215 open($handle,"<Makefile")
216 || open($handle,"<GNUmakefile")
217 || die "Could not open Makefile";
218 local($/) = undef;
219 my $m = <$handle>;
220 close($handle);
221 my $t = "";
223 $m =~ s/\\[\r\n]*//gs;
224 if ($m =~ /^REGRESS\s*=\s*(.*)$/gm)
226 $t = $1;
227 $t =~ s/\s+/ /g;
229 if ($m =~ /contrib\/pgcrypto/)
232 # pgcrypto is special since the tests depend on the
233 # configuration of the build
235 my $cftests =
236 $config->{openssl}
237 ?GetTests("OSSL_TESTS",$m)
238 : GetTests("INT_TESTS",$m);
239 my $pgptests =
240 $config->{zlib}
241 ?GetTests("ZLIB_TST",$m)
242 : GetTests("ZLIB_OFF_TST",$m);
243 $t =~ s/\$\(CF_TESTS\)/$cftests/;
244 $t =~ s/\$\(CF_PGP_TESTS\)/$pgptests/;
248 return split(/\s+/,$t);
251 sub GetTests
253 my $testname = shift;
254 my $m = shift;
255 if ($m =~ /^$testname\s*=\s*(.*)$/gm)
257 return $1;
259 return "";
262 sub usage
264 print STDERR
265 "Usage: vcregress.pl ",
266 "<check|installcheck|plcheck|contribcheck|ecpgcheck> [schedule]\n" ;
267 exit(1);