aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2017-11-12 11:48:02 -0500
committerBrian Cully <bjc@kublai.com>2017-11-12 11:48:47 -0500
commit3f8f46c8b10d060ec4ba7f3be91ff3cb6e903e01 (patch)
treec8fd64851982188eb722a99956db46e49409996f
parent01fde2b197c3d33d33b8814cdb677f8f262044a0 (diff)
downloadxmpt-3f8f46c8b10d060ec4ba7f3be91ff3cb6e903e01.tar.gz
xmpt-3f8f46c8b10d060ec4ba7f3be91ff3cb6e903e01.zip
Remove child handling, replace with pipe signal handling.
We don't actually care about the child, really, just ability to read and write, so SIGPIPE is more appropriate. Currently, ignore SIGPIPE during write operations, to support just spamming input for protocol dump testing. This should be a flag in the future, but for now, as long as there's a match step with a thunk, it'll get caught there.
-rwxr-xr-xxmpt20
1 files changed, 12 insertions, 8 deletions
diff --git a/xmpt b/xmpt
index 37af263..9ab7f7d 100755
--- a/xmpt
+++ b/xmpt
@@ -27,12 +27,9 @@ usage(0) if $help;
my %conf = read_conf($configpath);
my @plans = load_plans($testplanpath, $templatepath);
-my $curstep;
-local $SIG{CHLD} = sub {
- my $suffix = "before test plan started.";
- $suffix = "in $curstep step." if $curstep;
- die "Command '@ARGV' terminated $suffix\n"
-};
+# Ignore SIGPIPE at the top level, since it only matters when reading
+# or writing to the subprocess.
+local $SIG{PIPE} = sub {};
my ($inh, $outh) = (\*STDIN, \*STDOUT);
my $pid;
@@ -160,8 +157,7 @@ sub eval_in {
eval {
foreach my $plan (@plans) {
- $curstep = $plan->{name};
- print STDERR "=> Executing $curstep step.\n" if $verbose;
+ print STDERR "=> Executing $plan->{name} step.\n" if $verbose;
do_send($plan->{name}, @{$plan->{send}});
do_recv($plan->{name}, @{$plan->{expect}}) if $plan->{expect};
}
@@ -177,6 +173,11 @@ sub do_send {
chomp $l;
print STDERR "SEND: $l\n" unless $l =~ /^\s*$/;
}
+
+ # TODO: make write SIGPIPE configurable, but for now just ignore it.
+ local $SIG{PIPE} = sub {
+ print STDERR "Warning: SIGPIPE received from '@ARGV' while writing in $name step.\n"
+ };
print $evalpkg::out $s;
}
@@ -208,6 +209,9 @@ sub do_recv {
chomp $b;
die "Timed out waiting for match in $name step. Current read buffer:\n$b\n";
};
+ local $SIG{PIPE} = sub {
+ die "SIGPIPE received from '@ARGV' while matching in $name step.\n";
+ };
alarm $timeout;
my @matches;
while (1) {