~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to src/tools/msvc/vcregress.pl

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*-perl-*- hey - emacs - this is a perl file
 
2
 
 
3
# src/tools/msvc/vcregress.pl
 
4
 
 
5
use strict;
 
6
 
 
7
our $config;
 
8
 
 
9
use Cwd;
 
10
use File::Copy;
 
11
 
 
12
my $startdir = getcwd();
 
13
 
 
14
chdir "../../.." if (-d "../../../src/tools/msvc");
 
15
 
 
16
require 'src/tools/msvc/config_default.pl';
 
17
require 'src/tools/msvc/config.pl' if (-f 'src/tools/msvc/config.pl');
 
18
 
 
19
# buildenv.pl is for specifying the build environment settings
 
20
# it should contian lines like:
 
21
# $ENV{PATH} = "c:/path/to/bison/bin;$ENV{PATH}";
 
22
 
 
23
if ( -e "src/tools/msvc/buildenv.pl")
 
24
{
 
25
    require "src/tools/msvc/buildenv.pl";
 
26
}
 
27
 
 
28
my $what = shift || "";
 
29
if ($what =~ /^(check|installcheck|plcheck|contribcheck|ecpgcheck)$/i)
 
30
{
 
31
    $what = uc $what;
 
32
}
 
33
else
 
34
{
 
35
    usage();
 
36
}
 
37
 
 
38
# use a capital C here because config.pl has $config
 
39
my $Config = -e "release/postgres/postgres.exe" ? "Release" : "Debug";
 
40
 
 
41
copy("$Config/refint/refint.dll","src/test/regress");
 
42
copy("$Config/autoinc/autoinc.dll","src/test/regress");
 
43
copy("$Config/regress/regress.dll","src/test/regress");
 
44
copy("$Config/dummy_seclabel/dummy_seclabel.dll","src/test/regress");
 
45
 
 
46
$ENV{PATH} = "../../../$Config/libpq;../../$Config/libpq;$ENV{PATH}";
 
47
 
 
48
my $schedule = shift;
 
49
unless ($schedule)
 
50
{
 
51
    $schedule = "serial";
 
52
    $schedule = "parallel" if ($what eq 'CHECK' || $what =~ /PARALLEL/);
 
53
}
 
54
 
 
55
my $topdir = getcwd();
 
56
 
 
57
$ENV{PERL5LIB} = "$topdir/src/tools/msvc";
 
58
 
 
59
my $maxconn = "";
 
60
$maxconn = "--max_connections=$ENV{MAX_CONNECTIONS}"
 
61
  if $ENV{MAX_CONNECTIONS};
 
62
 
 
63
my $temp_config = "";
 
64
$temp_config = "--temp-config=\"$ENV{TEMP_CONFIG}\""
 
65
  if $ENV{TEMP_CONFIG};
 
66
 
 
67
chdir "src/test/regress";
 
68
 
 
69
my %command = (
 
70
    CHECK => \&check,
 
71
    PLCHECK => \&plcheck,
 
72
    INSTALLCHECK => \&installcheck,
 
73
    ECPGCHECK => \&ecpgcheck,
 
74
    CONTRIBCHECK => \&contribcheck
 
75
);
 
76
 
 
77
my $proc = $command{$what};
 
78
 
 
79
exit 3 unless $proc;
 
80
 
 
81
&$proc();
 
82
 
 
83
exit 0;
 
84
 
 
85
########################################################################
 
86
 
 
87
sub installcheck
 
88
{
 
89
    my @args = (
 
90
        "../../../$Config/pg_regress/pg_regress","--dlpath=.",
 
91
        "--psqldir=../../../$Config/psql","--schedule=${schedule}_schedule",
 
92
        "--encoding=SQL_ASCII","--no-locale"
 
93
    );
 
94
    push(@args,$maxconn) if $maxconn;
 
95
    system(@args);
 
96
    my $status = $? >>8;
 
97
    exit $status if $status;
 
98
}
 
99
 
 
100
sub check
 
101
{
 
102
    my @args = (
 
103
        "../../../$Config/pg_regress/pg_regress","--dlpath=.",
 
104
        "--psqldir=../../../$Config/psql","--schedule=${schedule}_schedule",
 
105
        "--encoding=SQL_ASCII","--no-locale",
 
106
        "--temp-install=./tmp_check","--top-builddir=\"$topdir\""
 
107
    );
 
108
    push(@args,$maxconn) if $maxconn;
 
109
    push(@args,$temp_config) if $temp_config;
 
110
    system(@args);
 
111
    my $status = $? >>8;
 
112
    exit $status if $status;
 
113
}
 
114
 
 
115
sub ecpgcheck
 
116
{
 
117
    chdir $startdir;
 
118
    system("msbuild ecpg_regression.proj /p:config=$Config");
 
119
    my $status = $? >>8;
 
120
    exit $status if $status;
 
121
    chdir "$topdir/src/interfaces/ecpg/test";
 
122
    $schedule="ecpg";
 
123
    my @args = (
 
124
        "../../../../$Config/pg_regress_ecpg/pg_regress_ecpg",
 
125
        "--psqldir=../../../$Config/psql",
 
126
        "--dbname=regress1,connectdb",
 
127
        "--create-role=connectuser,connectdb",
 
128
        "--schedule=${schedule}_schedule",
 
129
        "--encoding=SQL_ASCII",
 
130
        "--no-locale",
 
131
        "--temp-install=./tmp_chk",
 
132
        "--top-builddir=\"$topdir\""
 
133
    );
 
134
    push(@args,$maxconn) if $maxconn;
 
135
    system(@args);
 
136
    $status = $? >>8;
 
137
    exit $status if $status;
 
138
}
 
139
 
 
140
sub plcheck
 
141
{
 
142
    chdir "../../pl";
 
143
 
 
144
    foreach my $pl (glob("*"))
 
145
    {
 
146
        next unless -d "$pl/sql" && -d "$pl/expected";
 
147
        my $lang = $pl eq 'tcl' ? 'pltcl' : $pl;
 
148
        next unless -d "../../$Config/$lang";
 
149
        $lang = 'plpythonu' if $lang eq 'plpython';
 
150
        my @lang_args = ("--load-extension=$lang");
 
151
        chdir $pl;
 
152
        my @tests = fetchTests();
 
153
        if ($lang eq 'plperl')
 
154
        {
 
155
 
 
156
            # run both trusted and untrusted perl tests
 
157
            push(@lang_args, "--load-extension=plperlu");
 
158
 
 
159
            # assume we're using this perl to built postgres
 
160
            # test if we can run two interpreters in one backend, and if so
 
161
            # run the trusted/untrusted interaction tests
 
162
            use Config;
 
163
            if ($Config{usemultiplicity} eq 'define')
 
164
            {
 
165
                push(@tests,'plperl_plperlu');
 
166
            }
 
167
        }
 
168
        print "============================================================\n";
 
169
        print "Checking $lang\n";
 
170
        my @args = (
 
171
            "../../../$Config/pg_regress/pg_regress",
 
172
            "--psqldir=../../../$Config/psql",
 
173
            "--dbname=pl_regression",@lang_args,@tests
 
174
        );
 
175
        system(@args);
 
176
        my $status = $? >> 8;
 
177
        exit $status if $status;
 
178
        chdir "..";
 
179
    }
 
180
 
 
181
    chdir "../../..";
 
182
}
 
183
 
 
184
sub contribcheck
 
185
{
 
186
    chdir "../../../contrib";
 
187
    my $mstat = 0;
 
188
    foreach my $module (glob("*"))
 
189
    {
 
190
        next if ($module eq 'sepgsql');
 
191
        next if ($module eq 'xml2' && !$config->{xml});
 
192
        next
 
193
          unless -d "$module/sql"
 
194
              &&-d "$module/expected"
 
195
              &&(-f "$module/GNUmakefile" || -f "$module/Makefile");
 
196
        chdir $module;
 
197
        print "============================================================\n";
 
198
        print "Checking $module\n";
 
199
        my @tests = fetchTests();
 
200
        my @opts = fetchRegressOpts();
 
201
        my @args = (
 
202
            "../../$Config/pg_regress/pg_regress",
 
203
            "--psqldir=../../$Config/psql",
 
204
            "--dbname=contrib_regression",@opts,@tests
 
205
        );
 
206
        system(@args);
 
207
        my $status = $? >> 8;
 
208
        $mstat ||= $status;
 
209
        chdir "..";
 
210
    }
 
211
    exit $mstat if $mstat;
 
212
}
 
213
 
 
214
sub fetchRegressOpts
 
215
{
 
216
    my $handle;
 
217
    open($handle,"<GNUmakefile")
 
218
      || open($handle,"<Makefile")
 
219
      || die "Could not open Makefile";
 
220
    local($/) = undef;
 
221
    my $m = <$handle>;
 
222
    close($handle);
 
223
    my @opts;
 
224
    if ($m =~ /^\s*REGRESS_OPTS\s*=(.*)/m)
 
225
    {
 
226
 
 
227
        # ignore options that use makefile variables - can't handle those
 
228
        # ignore anything that isn't an option staring with --
 
229
        @opts = grep { $_ !~ /\$\(/ && $_ =~ /^--/ } split(/\s+/,$1);
 
230
    }
 
231
    if ($m =~ /^\s*ENCODING\s*=\s*(\S+)/m)
 
232
    {
 
233
        push @opts, "--encoding=$1";
 
234
    }
 
235
    if ($m =~ /^\s*NO_LOCALE\s*=\s*\S+/m)
 
236
    {
 
237
        push @opts, "--no-locale";
 
238
    }
 
239
    return @opts;
 
240
}
 
241
 
 
242
sub fetchTests
 
243
{
 
244
 
 
245
    my $handle;
 
246
    open($handle,"<GNUmakefile")
 
247
      || open($handle,"<Makefile")
 
248
      || die "Could not open Makefile";
 
249
    local($/) = undef;
 
250
    my $m = <$handle>;
 
251
    close($handle);
 
252
    my $t = "";
 
253
 
 
254
    $m =~ s/\\[\r\n]*//gs;
 
255
    if ($m =~ /^REGRESS\s*=\s*(.*)$/gm)
 
256
    {
 
257
        $t = $1;
 
258
        $t =~ s/\s+/ /g;
 
259
 
 
260
        if ($m =~ /contrib\/pgcrypto/)
 
261
        {
 
262
 
 
263
            # pgcrypto is special since the tests depend on the
 
264
            # configuration of the build
 
265
 
 
266
            my $cftests =
 
267
              $config->{openssl}
 
268
              ?GetTests("OSSL_TESTS",$m)
 
269
              : GetTests("INT_TESTS",$m);
 
270
            my $pgptests =
 
271
              $config->{zlib}
 
272
              ?GetTests("ZLIB_TST",$m)
 
273
              : GetTests("ZLIB_OFF_TST",$m);
 
274
            $t =~ s/\$\(CF_TESTS\)/$cftests/;
 
275
            $t =~ s/\$\(CF_PGP_TESTS\)/$pgptests/;
 
276
        }
 
277
    }
 
278
 
 
279
    return split(/\s+/,$t);
 
280
}
 
281
 
 
282
sub GetTests
 
283
{
 
284
    my $testname = shift;
 
285
    my $m = shift;
 
286
    if ($m =~ /^$testname\s*=\s*(.*)$/gm)
 
287
    {
 
288
        return $1;
 
289
    }
 
290
    return "";
 
291
}
 
292
 
 
293
sub usage
 
294
{
 
295
    print STDERR
 
296
      "Usage: vcregress.pl ",
 
297
      "<check|installcheck|plcheck|contribcheck|ecpgcheck> [schedule]\n";
 
298
    exit(1);
 
299
}