summaryrefslogtreecommitdiff
path: root/solenv
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-09-20 11:01:44 +0200
committerStephan Bergmann <sbergman@redhat.com>2013-09-20 15:38:02 +0200
commitaeee571501df4d3b1d91e10d61b434f0ecac4d6a (patch)
tree09c1339165b805c05bff1fe8dec10bb369c03af2 /solenv
parent89d911a2775118dbf5e4cd337e4ede4284b6f717 (diff)
Use tempfile instead of stdin in exectest.pl
...so it can easily be reused to test unoidl-write, too. Change-Id: I4992850b44faaa152bcf1d281f2787824d6ad036
Diffstat (limited to 'solenv')
-rw-r--r--solenv/bin/exectest.pl52
1 files changed, 32 insertions, 20 deletions
diff --git a/solenv/bin/exectest.pl b/solenv/bin/exectest.pl
index 2cd9fb6e1be8..bd9b5f373cdc 100644
--- a/solenv/bin/exectest.pl
+++ b/solenv/bin/exectest.pl
@@ -23,8 +23,11 @@ sub encode($)
return $arg
}
-$#ARGV >= 1 or die "Usage: $0 <input file> <command> <arguments...>";
-open INPUT, $ARGV[0] or die "cannot open $ARGV[0]: $!";
+$#ARGV >= 2
+ or die "Usage: $0 <input file> <temp file> <command> <arguments...>";
+open INPUT, '<', $ARGV[0] or die "cannot open $ARGV[0]: $!";
+shift @ARGV;
+$temp = $ARGV[0];
shift @ARGV;
$failed = 0;
$open = 0;
@@ -35,7 +38,31 @@ while (1) {
{
if ($open)
{
- close PIPE;
+ close OUTPUT;
+ my $prog = '';
+ my $assigns = 1;
+ for ($i = 0; $i != scalar(@ARGV); ++$i)
+ {
+ $prog .= ' ' unless $i == 0;
+ if ($assigns && $ARGV[$i] =~ /^([A-Za-z_][A-Za-z0-9_]+)=(.*)$/)
+ {
+ $prog .= $1 . "='" . encode($2) . "'";
+ }
+ else
+ {
+ if ($ARGV[$i] =~ /^{}$/)
+ {
+ $prog .= "'" . encode($temp) . "'";
+ }
+ else
+ {
+ $prog .= "'" . encode($ARGV[$i]) . "'";
+ }
+ $assigns = 0;
+ }
+ }
+ system("$prog");
+ unlink $temp;
if ($? % 256 == 0)
{
$exit = $? / 256;
@@ -60,27 +87,12 @@ while (1) {
last if $eof;
$expect = $1;
$title = $2;
- my $prog = '';
- my $assigns = 1;
- for ($i = 0; $i != scalar(@ARGV); ++$i)
- {
- $prog .= ' ' unless $i == 0;
- if ($assigns && $ARGV[$i] =~ /^([A-Za-z_][A-Za-z0-9_]+)=(.*)$/)
- {
- $prog .= $1 . "='" . encode($2) . "'";
- }
- else
- {
- $prog .= "'" . encode($ARGV[$i]) . "'";
- $assigns = 0;
- }
- }
- open PIPE, "| $prog" or die "cannot start process: $!";
+ open OUTPUT, '>', $temp or die "cannot open $temp: $!";
$open = 1;
}
elsif ($open)
{
- print PIPE $in or die "cannot write to pipe: $!";
+ print OUTPUT $in or die "cannot write to $temp: $!";
}
}
exit(0);