]> granicus.if.org Git - postgresql/blob - src/tools/msvc/vcregress.pl
954e23e5ce114ee3e57b17287c55d10961978a35
[postgresql] / src / tools / msvc / vcregress.pl
1
2 # -*-perl-*- hey - emacs - this is a perl file
3
4 # $PostgreSQL: pgsql/src/tools/msvc/vcregress.pl,v 1.8 2008/10/06 02:55:20 tgl Exp $
5
6 use strict;
7
8 our $config;
9
10 use Cwd;
11 use File::Copy;
12
13 my $startdir = getcwd();
14
15 chdir "../../.." if (-d "../../../src/tools/msvc");
16
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}";
20
21 if ( -e "src/tools/msvc/buildenv.pl")
22 {
23     require "src/tools/msvc/buildenv.pl";
24 }
25
26 my $what = shift || "";
27 if ($what =~ /^(check|installcheck|plcheck|contribcheck|ecpgcheck)$/i)
28 {
29     $what = uc $what;
30 }
31 else
32 {
33     usage();
34 }
35
36 # use a capital C here because config.pl has $config
37 my $Config = -e "release/postgres/postgres.exe" ? "Release" : "Debug";
38
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");
42
43 $ENV{PATH} = "../../../$Config/libpq;../../$Config/libpq;$ENV{PATH}";
44
45 my $schedule = shift;
46 unless ($schedule)
47 {
48         $schedule = "serial";
49         $schedule = "parallel" if ($what eq 'CHECK' || $what =~ /PARALLEL/);
50 }
51
52 my $temp_port;
53 if (-e "src/tools/msvc/config.pl")
54 {
55     eval{
56         require "src/tools/msvc/config.pl";
57         $temp_port = $config->{'--with-pgport'};
58       }
59 }
60 $temp_port ||= 55432;
61
62 my $topdir = getcwd();
63
64 $ENV{PERL5LIB} = "$topdir/src/tools/msvc";
65
66 my $maxconn = "";
67 $maxconn = "--max_connections=$ENV{MAX_CONNECTIONS}"
68   if $ENV{MAX_CONNECTIONS};
69
70 my $temp_config = "";
71 $temp_config = "--temp-config=\"$ENV{TEMP_CONFIG}\""
72         if $ENV{TEMP_CONFIG};
73
74 chdir "src/test/regress";
75
76 my %command = (
77     CHECK => \&check,
78     PLCHECK => \&plcheck,
79     INSTALLCHECK => \&installcheck,
80     ECPGCHECK => \&ecpgcheck,
81     CONTRIBCHECK => \&contribcheck
82 );
83
84 my $proc = $command{$what};
85
86 exit 3 unless $proc;
87
88 &$proc();
89
90 exit 0;
91
92 ########################################################################
93
94 sub installcheck
95 {
96     my @args = (
97         "../../../$Config/pg_regress/pg_regress",
98         "--dlpath=.",
99         "--psqldir=../../../$Config/psql",
100         "--schedule=${schedule}_schedule",
101         "--multibyte=SQL_ASCII",
102         "--load-language=plpgsql",
103         "--no-locale"
104     );
105     push(@args,$maxconn) if $maxconn;
106     system(@args);
107     my $status = $? >>8;
108     exit $status if $status;
109 }
110
111 sub check
112 {
113     my @args = (
114         "../../../$Config/pg_regress/pg_regress",
115         "--dlpath=.",
116         "--psqldir=../../../$Config/psql",
117         "--schedule=${schedule}_schedule",
118         "--multibyte=SQL_ASCII",
119         "--load-language=plpgsql",
120         "--no-locale",
121         "--temp-install=./tmp_check",
122         "--top-builddir=\"$topdir\"",
123         "--temp-port=$temp_port"
124     );
125     push(@args,$maxconn) if $maxconn;
126         push(@args,$temp_config) if $temp_config;
127     system(@args);
128     my $status = $? >>8;
129     exit $status if $status;
130 }
131
132 sub ecpgcheck
133 {
134     chdir $startdir;
135     system("msbuild ecpg_regression.proj /p:config=$Config");
136     my $status = $? >>8;
137     exit $status if $status;
138     chdir "$topdir/src/interfaces/ecpg/test";
139     $schedule="ecpg";
140     my @args = (
141         "../../../../$Config/pg_regress_ecpg/pg_regress_ecpg",
142         "--psqldir=../../../$Config/psql",
143         "--dbname=regress1,connectdb",
144         "--create-role=connectuser,connectdb",
145         "--schedule=${schedule}_schedule",
146         "--multibyte=SQL_ASCII",
147         "--load-language=plpgsql",
148         "--no-locale",
149         "--temp-install=./tmp_chk",
150         "--top-builddir=\"$topdir\"",
151         "--temp-port=$temp_port"
152     );
153     push(@args,$maxconn) if $maxconn;
154     system(@args);
155     $status = $? >>8;
156     exit $status if $status;
157 }
158
159 sub plcheck
160 {
161     chdir "../../pl";
162
163     foreach my $pl (glob("*"))
164     {
165         next unless -d "$pl/sql" && -d "$pl/expected";
166         my $lang = $pl eq 'tcl' ? 'pltcl' : $pl;
167         next unless -d "../../$Config/$lang";
168         $lang = 'plpythonu' if $lang eq 'plpython';
169         chdir $pl;
170                 print "============================================================\n";
171         print "Checking $lang\n";
172         my @tests = fetchTests();
173         my @args = (
174             "../../../$Config/pg_regress/pg_regress",
175             "--psqldir=../../../$Config/psql",
176             "--dbname=pl_regression","--load-language=$lang",@tests
177         );
178         system(@args);
179         my $status = $? >> 8;
180         exit $status if $status;
181         chdir "..";
182     }
183
184     chdir "../../..";
185 }
186
187 sub contribcheck
188 {
189     chdir "../../../contrib";
190     my $mstat = 0;
191     foreach my $module (glob("*"))
192     {
193         next unless -d "$module/sql" && 
194                         -d "$module/expected" && 
195                         (-f "$module/Makefile" || -f "$module/GNUmakefile");
196         chdir $module;
197                 print "============================================================\n";
198         print "Checking $module\n";
199         my @tests = fetchTests();
200         my @args = (
201             "../../$Config/pg_regress/pg_regress",
202             "--psqldir=../../$Config/psql",
203             "--dbname=contrib_regression",@tests
204         );
205         system(@args);
206         my $status = $? >> 8;
207         $mstat ||= $status;
208         chdir "..";
209     }
210     exit $mstat if $mstat;
211 }
212
213 sub fetchTests
214 {
215
216     my $handle;
217     open($handle,"<Makefile")
218       || open($handle,"<GNUmakefile")
219       || die "Could not open Makefile";
220     local($/) = undef;
221     my $m = <$handle>;
222     close($handle);
223     my $t = "";
224
225     $m =~ s/\\[\r\n]*//gs;
226     if ($m =~ /^REGRESS\s*=\s*(.*)$/gm)
227     {
228         $t = $1;
229         $t =~ s/\s+/ /g;
230
231         if ($m =~ /contrib\/pgcrypto/)
232         {
233
234             # pgcrypto is special since the tests depend on the
235             # configuration of the build
236
237             my $cftests =
238               $config->{openssl}
239               ?GetTests("OSSL_TESTS",$m)
240               : GetTests("INT_TESTS",$m);
241             my $pgptests =
242               $config->{zlib}
243               ?GetTests("ZLIB_TST",$m)
244               : GetTests("ZLIB_OFF_TST",$m);
245             $t =~ s/\$\(CF_TESTS\)/$cftests/;
246             $t =~ s/\$\(CF_PGP_TESTS\)/$pgptests/;
247         }
248     }
249
250     return split(/\s+/,$t);
251 }
252
253 sub GetTests
254 {
255     my $testname = shift;
256     my $m = shift;
257     if ($m =~ /^$testname\s*=\s*(.*)$/gm)
258     {
259         return $1;
260     }
261     return "";
262 }
263
264 sub usage
265 {
266     print STDERR
267                 "Usage: vcregress.pl ",
268                 "<check|installcheck|plcheck|contribcheck|ecpgcheck> [schedule]\n" ;
269         exit(1);
270 }