1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
#AUTHOR: Peter Tillemans <pti@MAIL.NET4ALL.BE>
use Cwd;
use File::Copy;
use File::Find;
use Win32::Process;
use Win32;
use Config;
use File::Basename 'dirname';
#
# Config part
#
$apache = "apache";
SEARCH: {
for my $drive ('c'..'g') {
for my $p ("program files\\apache", "apache") {
last SEARCH if -e ($fullapache = "$drive:\\$p\\apache.exe");
}
}
}
unless (-e $fullapache) {
require ExtUtils::MakeMaker;
ExtUtils::MakeMaker->import('prompt');
$fullapache = prompt("Where is your apache.exe located ?", $fullapache);
}
die "Can't find apache.exe!" unless -e $fullapache;
my $ap_path = dirname $fullapache;
$ENV{PATH} = join ";", $ap_path, $ENV{PATH};
$fullperl = $Config{perlpath};
print "Running tests with:\n";
print " perl=$fullperl\n apache=$fullapache\n";
$port = 8529;
sub ErrorReport {
print Win32::FormatMessage( Win32::GetLastError() );
}
#
# prepare config files
#
chdir "t/conf";
copy("httpd.conf-win32", "httpd.conf");# PTI: unless -f httpd.conf;
chdir "../net";
#copy("config.pl.win32", "config.pl");# PTI: unless -f config.pl;
chdir "../..";
#source or binary distribution
for (qw(src/modules/ApacheModulePerl/Release
src/modules/ApacheModulePerl/Debug
win32/modules))
{
my $dll = "$_/ApacheModulePerl.dll";
next unless -e $dll;
copy $dll, "t/modules/ApacheModulePerl.dll";
last;
}
#
# create some bogus files and a place to dump the logfiles
#
mkdir("/tmp","755") unless -d "/tmp";
for my $d (qw(logs conf)) {
mkdir("t/$d","755") unless -d "t/$d";
}
for my $f (qw(srm.conf access.conf mime.types)) {
local *FH;
open FH, ">t/conf/$f"; close FH;
}
# change the paths so everybody agrees on which files to use
#
$pwd = cwd();
# this is to make sure apache knows which files to take : apparently apache uner Win32
# change directories to the installation directory so "./t" references do not work
system "$fullperl -p -i.bak -e \"s#\\./t#$pwd/t#\" t/conf/httpd.conf";
#
# start ourselves a server to pound on
#
Win32::Process::Create($HttpdObj,
$fullapache,
"$apache -X -d $pwd/t",
0,
NORMAL_PRIORITY_CLASS,
".") || die ErrorReport();
print "httpd listening on port $port\n";
print "will write error_log to: t/logs/mod_perl_error_log\n";
print "letting apache warm up...\n";
sleep 2;
print "done\n";
#
# Ok, start pounding
#
system "$fullperl t/TEST @ARGV";
# stop server again
$HttpdObj->Kill(-1);
# remove traces
print "letting apache cool down...\n";
sleep 2;
find(\&cleanup, '/tmp/');
sub cleanup {/^(mod_perl|CGItemp)/ && unlink($_)}
|