On Tue, 30 Sep 2003, Stas Bekman wrote:
> Barrie Slaymaker wrote:
> > On Sep 30 2003, Stas Bekman wrote:
> >
> >> Isn't IPC::Run3 based on IPC::Run? So if IPC::Run doesn't work...
> >
> > No, it's smaller, faster, lighter ;)
> >
> > It's "all new code", no select(). Uses File::Temp
> > temporary files to optionally queue up input for the
> > child, runs the child, optionally with any stdout and/or
> > stderr redirects to other temp files, then slurps the
> > results. Simple. Portable. Relatively efficient for
> > small to moderate amounts of data, especially when you
> > start comparing it to the things that IPC::Run does when
> > faced with the odd behaviors of Win32's anonymous pipe
> > and TCP socket APIs (you want the child to have pipe()s,
> > but you can't select() on pipes, and I don't know how to
> > take a pipe handle that Win32 gives me and do a blocking
> > poll on it a la select()--WaitForMultipleObjects() might
> > do it, but I'm no guru there).
>
> So may be we could try it. If Randy says that it works for
> him, we will happily move to use it instead ;)
And that does seem to work! A diff appears below (not tested
on linux) - in this, I also added a change to TestServer.pm
to print out a message on Win32 when shutting down the
server, as that's expected when checking that the server
successfully shut down in TestSmoke.pm.
=========================================================
Index: lib/Apache/TestSmoke.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestSmoke.pm,v
retrieving revision 1.23
diff -u -r1.23 TestSmoke.pm
--- lib/Apache/TestSmoke.pm 12 Sep 2003 02:47:41 -0000 1.23
+++ lib/Apache/TestSmoke.pm 1 Oct 2003 04:58:38 -0000
@@ -15,6 +15,7 @@
use FindBin;
use POSIX ();
use Symbol ();
+use IPC::Run3;
#use constant DEBUG => 1;
@@ -111,7 +112,7 @@
@{ $self->{tests} } = $self->get_tests($test_opts);
- $self->{base_command} = "./TEST";
+ $self->{base_command} = "$^X $FindBin::Bin/TEST";
# options common to all
$self->{base_command} .= " -verbose" if $self->{verbose};
@@ -473,16 +474,11 @@
# start server
{
my $command = $self->{start_command};
- open my $pipe, "$command 2>&1|" or die "cannot fork: $!";
- my $oldfh = select $pipe; $| = 1; select $oldfh;
- # XXX: check startup success?
my $started_ok = 0;
my $log = '';
- while (my $t = <$pipe>) {
- $started_ok = 1 if $t =~ /started/;
- $log .= $t;
- }
- close $pipe;
+ run3 $command, \undef, \$log, \$log;
+ print $log;
+ $started_ok = 1 if $log =~ /started/;
unless ($started_ok) {
error "failed to start server\n $log";
exit 1;
@@ -507,19 +503,12 @@
my $fill = "." x ($max_len - length $test_name);
$self->{total_tests_run}++;
- open my $pipe, "$command $test 2>&1|" or die "cannot fork: $!";
- my $oldfh = select $pipe; $| = 1; select $oldfh;
-
+ my $test_command = "$command $test";
my $ok = 0;
my $log = '';
- while (<$pipe>) {
- $log .= $_;
-
- $ok = 1 if /All tests successful/;
- }
- # it's normal for $command to exit with a failure status if tests
- # fail, so we don't die/report it
- close $pipe;
+ run3 $test_command, \undef, \$log, \$log;
+ print $log;
+ $ok = 1 if $log =~ /All tests successful/;
my @core_files_msg = $self->Apache::TestRun::scan_core_incremental;
@@ -594,16 +583,11 @@
# stop server
{
my $command = $self->{stop_command};
- open my $pipe, "$command 2>&1|" or die "cannot fork: $!";
- my $oldfh = select $pipe; $| = 1; select $oldfh;
- # XXX: check stopup success?
my $stopped_ok = 0;
my $log = '';
- while (my $t = <$pipe>) {
- $stopped_ok = 1 if $t =~ /shutdown/;
- $log .= $t;
- }
- close $pipe;
+ run3 $command, \undef, \$log, \$log;
+ print $log;
+ $stopped_ok = 1 if $log =~ /shutdown/;
unless ($stopped_ok) {
error "failed to stop server\n $log";
exit 1;
Index: lib/Apache/TestServer.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestServer.pm,v
retrieving revision 1.65
diff -u -r1.65 TestServer.pm
--- lib/Apache/TestServer.pm 18 Sep 2003 07:39:35 -0000 1.65
+++ lib/Apache/TestServer.pm 1 Oct 2003 04:58:39 -0000
@@ -317,12 +317,14 @@
if (Apache::TestConfig::WIN32) {
if ($self->{config}->{win32obj}) {
$self->{config}->{win32obj}->Kill(0);
+ warning "server $self->{name} shutdown";
return 1;
}
else {
require Win32::Process;
my $pid = $self->pid;
Win32::Process::KillProcess($pid, 0);
+ warning "server $self->{name} shutdown";
return 1;
}
}
==================================================================
--
best regards,
randy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]