aboutsummaryrefslogtreecommitdiffstats
path: root/qtest
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2008-06-30 16:48:16 +0200
committerJay Berkenbilt <ejb@ql.org>2008-06-30 16:48:16 +0200
commit212ca68f4f7ce36cbca0090a371edc0a762df5e5 (patch)
tree26d1678765e08686ae68778896e5ebc16335672c /qtest
parent31dbfc0ef9338911bd5c9d6a2e607611ba4449bc (diff)
downloadqpdf-212ca68f4f7ce36cbca0090a371edc0a762df5e5.tar.zst
2.0.2
git-svn-id: svn+q:///qpdf/trunk@634 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'qtest')
-rwxr-xr-xqtest/bin/qtest-driver2
-rw-r--r--qtest/module/TestDriver.pm100
2 files changed, 79 insertions, 23 deletions
diff --git a/qtest/bin/qtest-driver b/qtest/bin/qtest-driver
index 1af99291..723a3e3f 100755
--- a/qtest/bin/qtest-driver
+++ b/qtest/bin/qtest-driver
@@ -33,7 +33,7 @@ require TestDriver;
if ((@ARGV == 1) && ($ARGV[0] eq '--version'))
{
- print "$whoami version 1.1\n";
+ print "$whoami version 1.2\n";
exit 0;
}
if ((@ARGV == 1) && ($ARGV[0] eq '--print-path'))
diff --git a/qtest/module/TestDriver.pm b/qtest/module/TestDriver.pm
index 6e1fa313..ea421702 100644
--- a/qtest/module/TestDriver.pm
+++ b/qtest/module/TestDriver.pm
@@ -139,7 +139,10 @@ sub get_tty_features
no strict;
local $^W = 0;
local *X;
- require 'sys/ioctl.ph';
+ {
+ local $SIG{'__WARN__'} = sub {};
+ require 'sys/ioctl.ph';
+ }
if ((defined &TIOCGWINSZ) && open(X, "+</dev/tty"))
{
my $winsize = "";
@@ -671,6 +674,8 @@ sub runtest
my $pid = undef;
my $pid_killer = new TestDriver::PidKiller(\$pid);
my $in = new IO::Handle;
+ my $use_tempfile = ($^O eq 'MSWin32');
+ my $tempout_status = undef;
if (defined $in_string)
{
&QTC::TC("testdriver", "TestDriver input string");
@@ -687,11 +692,30 @@ sub runtest
}
elsif (defined $in_command)
{
- $pid = open($in, "-|");
- croak +__PACKAGE__, "->runtest: fork failed: $!\n" unless defined $pid;
+ my $tempfilename = "$tempdir/tempout";
+ my $tempfile = undef;
+ if ($use_tempfile)
+ {
+ $tempfile = new IO::File(">$tempfilename") or
+ die +(+__PACKAGE__,
+ "->runtest: unable to create $tempfilename: $!\n");
+ $pid = fork;
+ croak +__PACKAGE__, "->runtest: fork failed: $!\n"
+ unless defined $pid;
+ }
+ else
+ {
+ $pid = open($in, "-|");
+ croak +__PACKAGE__, "->runtest: fork failed: $!\n"
+ unless defined $pid;
+ }
if ($pid == 0)
{
# child
+ if (defined $tempfile)
+ {
+ open(STDOUT, ">&", $tempfile);
+ }
open(STDERR, ">&STDOUT");
open(STDIN, '<', \ "");
if (ref($in_command) eq 'ARRAY')
@@ -711,6 +735,19 @@ sub runtest
$in_command, "\n");
}
}
+ else
+ {
+ if (defined $tempfile)
+ {
+ waitpid($pid, 0);
+ $tempout_status = $?;
+ $pid = undef;
+ open($in, "<$tempfilename") or
+ croak +(+__PACKAGE__,
+ "->runtest: unable to read from" .
+ " input file $tempfilename: $!\n");
+ }
+ }
}
else
{
@@ -768,22 +805,25 @@ sub runtest
last if defined $exit_status;
}
$in->close();
+ if (defined $tempout_status)
+ {
+ $exit_status = $tempout_status;
+ }
if (defined $in_command)
{
if (! defined $exit_status)
{
$exit_status = $?;
}
- if (($exit_status > 0) && ($exit_status < 256))
+ if (WIFSIGNALED($exit_status))
{
&QTC::TC("testdriver", "TestDriver exit status signal");
- $exit_status &= 127; # clear core dump flag
- $exit_status = "SIG:$exit_status";
+ $exit_status = "SIG:" . WTERMSIG($exit_status);
}
- else
+ elsif (WIFEXITED($exit_status))
{
&QTC::TC("testdriver", "TestDriver exit status number");
- $exit_status >>= 8;
+ $exit_status = WEXITSTATUS($exit_status);
}
}
$? = 0;
@@ -1533,28 +1573,44 @@ sub rmrf
sub safe_pipe
{
my ($cmd, $outfile) = @_;
- my $pid = open(C, "-|");
my $result = 0;
- if ($pid)
+ if ($^O eq 'MSWin32')
{
- # parent
- my $out = new IO::File(">$outfile") or
- die +__PACKAGE__, ": can't open $outfile: $!\n";
- binmode C;
- while (<C>)
+ my @cmd = @$cmd;
+ my $cmd_str = shift(@cmd);
+ while (@cmd)
{
- $out->print($_);
+ my $arg = shift(@cmd);
+ $cmd_str .= " \"$arg\"";
}
- close(C);
- $result = $?;
- $out->close();
+ $cmd_str .= " > $outfile 2>&1";
+ $result = system($cmd_str);
}
else
{
- # child
- open(STDERR, ">&STDOUT");
- exec(@$cmd) || die +__PACKAGE__, ": $cmd->[0] failed: $!\n";
+ my $pid = open(C, "-|");
+
+ if ($pid)
+ {
+ # parent
+ my $out = new IO::File(">$outfile") or
+ die +__PACKAGE__, ": can't open $outfile: $!\n";
+ binmode C;
+ while (<C>)
+ {
+ $out->print($_);
+ }
+ close(C);
+ $result = $?;
+ $out->close();
+ }
+ else
+ {
+ # child
+ open(STDERR, ">&STDOUT");
+ exec(@$cmd) || die +__PACKAGE__, ": $cmd->[0] failed: $!\n";
+ }
}
$result;