|
| 1 | + |
| 2 | +# -*-perl-*- hey - emacs - this is a perl file |
| 3 | + |
| 4 | +# $PostgreSQL: pgsql/src/tools/msvc/vcregress.pl,v 1.1 2007/09/23 21:52:56 adunstan 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/defint.dll","contrib/spi"); |
| 40 | +copy("$Config/autoinc/autoinc.dll","contrib/spi"); |
| 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 | + "--psqldir=../../../$Config/psql", |
| 99 | + "--schedule=${schedule}_schedule", |
| 100 | + "--multibyte=SQL_ASCII", |
| 101 | + "--load-language=plpgsql", |
| 102 | + "--no-locale" |
| 103 | + ); |
| 104 | + push(@args,$maxconn) if $maxconn; |
| 105 | + system(@args); |
| 106 | + my $status = $? >>8; |
| 107 | + exit $status if $status; |
| 108 | +} |
| 109 | + |
| 110 | +sub check |
| 111 | +{ |
| 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" |
| 122 | + ); |
| 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; |
| 128 | +} |
| 129 | + |
| 130 | +sub ecpgcheck |
| 131 | +{ |
| 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 | + "--createrole=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" |
| 150 | + ); |
| 151 | + push(@args,$maxconn) if $maxconn; |
| 152 | + system(@args); |
| 153 | + $status = $? >>8; |
| 154 | + exit $status if $status; |
| 155 | +} |
| 156 | + |
| 157 | +sub plcheck |
| 158 | +{ |
| 159 | + chdir "../../pl"; |
| 160 | + |
| 161 | + foreach my $pl (glob("*")) |
| 162 | + { |
| 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 |
| 175 | + ); |
| 176 | + system(@args); |
| 177 | + my $status = $? >> 8; |
| 178 | + exit $status if $status; |
| 179 | + chdir ".."; |
| 180 | + } |
| 181 | + |
| 182 | + chdir "../../.."; |
| 183 | +} |
| 184 | + |
| 185 | +sub contribcheck |
| 186 | +{ |
| 187 | + chdir "../../../contrib"; |
| 188 | + my $mstat = 0; |
| 189 | + foreach my $module (glob("*")) |
| 190 | + { |
| 191 | + next unless -d "$module/sql" && -d "$module/expected" && -f "Makefile"; |
| 192 | + chdir $module; |
| 193 | + print "============================================================\n"; |
| 194 | + print "Checking $module\n"; |
| 195 | + my @tests = fetchTests(); |
| 196 | + my @args = ( |
| 197 | + "../../$Config/pg_regress/pg_regress", |
| 198 | + "--psqldir=../../$Config/psql", |
| 199 | + "--dbname=contrib_regression",@tests |
| 200 | + ); |
| 201 | + system(@args); |
| 202 | + my $status = $? >> 8; |
| 203 | + $mstat ||= $status; |
| 204 | + chdir ".."; |
| 205 | + } |
| 206 | + exit $mstat if $mstat; |
| 207 | +} |
| 208 | + |
| 209 | +sub fetchTests |
| 210 | +{ |
| 211 | + |
| 212 | + my $handle; |
| 213 | + open($handle,"<Makefile") |
| 214 | + || open($handle,"<GNUMakefile") |
| 215 | + || die "Could not open Makefile"; |
| 216 | + local($/) = undef; |
| 217 | + my $m = <$handle>; |
| 218 | + close($handle); |
| 219 | + my $t = ""; |
| 220 | + |
| 221 | + $m =~ s/\\[\r\n]*//gs; |
| 222 | + if ($m =~ /^REGRESS\s*=\s*(.*)$/gm) |
| 223 | + { |
| 224 | + $t = $1; |
| 225 | + $t =~ s/\s+/ /g; |
| 226 | + |
| 227 | + if ($m =~ /contrib\/pgcrypto/) |
| 228 | + { |
| 229 | + |
| 230 | + # pgcrypto is special since the tests depend on the |
| 231 | + # configuration of the build |
| 232 | + |
| 233 | + my $cftests = |
| 234 | + $config->{openssl} |
| 235 | + ?GetTests("OSSL_TESTS",$m) |
| 236 | + : GetTests("INT_TESTS",$m); |
| 237 | + my $pgptests = |
| 238 | + $config->{zlib} |
| 239 | + ?GetTests("ZLIB_TST",$m) |
| 240 | + : GetTests("ZLIB_OFF_TST",$m); |
| 241 | + $t =~ s/\$\(CF_TESTS\)/$cftests/; |
| 242 | + $t =~ s/\$\(CF_PGP_TESTS\)/$pgptests/; |
| 243 | + } |
| 244 | + } |
| 245 | + |
| 246 | + return split(/\s+/,$t); |
| 247 | +} |
| 248 | + |
| 249 | +sub GetTests |
| 250 | +{ |
| 251 | + my $testname = shift; |
| 252 | + my $m = shift; |
| 253 | + if ($m =~ /^$testname\s*=\s*(.*)$/gm) |
| 254 | + { |
| 255 | + return $1; |
| 256 | + } |
| 257 | + return ""; |
| 258 | +} |
| 259 | + |
| 260 | +sub usage |
| 261 | +{ |
| 262 | + print STDERR |
| 263 | + "Usage: vcregress.pl ", |
| 264 | + "<check|installcheck|plcheck|contribcheck|ecpgcheck> [schedule]\n" ; |
| 265 | + exit(1); |
| 266 | +} |
0 commit comments