Commit 46ae49a3 authored by Tyler Hicks's avatar Tyler Hicks

parser: Detect core dumps during parser tests

If a parser test case causes the parser to produce a core dump, the
simple.pl test runner incorrectly treats the test as a success.

This patch treats tests that cause core dumps as failures, even when the
tests are marked as #=TODO. The only way to ignore tests that fail in
this manner is with #=DISABLED.

Note that this patch changes the meaning of the $result variable.
Previously, it held a true or false status returned when closing the
apparmor_parser pipe. Now, it holds the exit status of apparmor_parser.
Signed-off-by: Tyler Hicks's avatarTyler Hicks <tyhicks@canonical.com>
Acked-by: Steve Beattie's avatarSteve Beattie <steve@nxnw.org>
parent 93198cc7
......@@ -65,6 +65,6 @@ The simple script looks for a few special comments in the profile,
- #=DISABLED -- skips the test, and marks it as a failed TODO task.
Useful if the particular testcase causes the parser to infinite
loop.
loop or dump core.
Otherwise, the profile is passed on as-is to the subdomain parser.
......@@ -71,7 +71,9 @@ sub test_profile {
my $expass = 1;
my $istodo = 0;
my $isdisabled = 0;
my $result = 0;
my $result = 1;
my $signal = 0;
my $coredump = 0;
my $child;
$child = open(PARSER, "|-");
......@@ -86,7 +88,6 @@ sub test_profile {
# parent
eval {
local $SIG{ALRM} = sub {
$result = 1;
kill PIPE => $child;
$description = "$description - TESTCASE TIMED OUT";
};
......@@ -114,7 +115,10 @@ sub test_profile {
}
}
$result = close(PARSER);
close(PARSER) or ($! and die "Bail out! couldn't close parser pipe");
$result = $? >> 8;
$signal = $? & 127;
$coredump = $signal ? $? & 128 : 0;
alarm 0;
};
......@@ -124,13 +128,15 @@ sub test_profile {
local $TODO = "Disabled testcase.";
ok(0, "TODO: $profile: $description");
}
} elsif ($coredump) {
ok(0, "$profile: Produced core dump (signal $signal): $description");
} elsif ($istodo) {
TODO: {
local $TODO = "Unfixed testcase.";
ok($expass ? $result : !$result, "TODO: $profile: $description");
ok($expass ? !$result : $result, "TODO: $profile: $description");
}
} else {
ok($expass ? $result : !$result, "$profile: $description");
ok($expass ? !$result : $result, "$profile: $description");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment