Re: [apparmor] [patch 2/3] two fixes to the parsers simple test driver

2012-11-05 Thread John Johansen
On 10/26/2012 10:59 AM, Steve Beattie wrote:
> This patch fixes two issue with the simple test driver. The first is
> that child exec that actually ran the parser was located inside the
> eval statement. This meant that if the exec failed for some reason
> (like the parser didn't exist), the child wouldn't actually die,
> but would pop out of the eval and continue running through the loop
> of test profiles (while the parent process does the same). This meant
> that if the script ran on the full testsuite with a misconfiguration,
> it would explode creating O(n^2) processes, where n is the number of
> testcase files -- with over 25k testcases, that's a lot. The fis is to
> lift the child exec outside the eval{}, then an exec() failure causes
> the child process to die correctly.
> 
> The second fix is that several of the testcases were added with the
> DESCRIPTION field added in lower case (i.e. #=Description blah blah).
> This fix makes the regex that pulls out the description not be
> case-sensitive.
> 
> ---

Acked-by: John Johansen 


-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor


[apparmor] [patch 2/3] two fixes to the parsers simple test driver

2012-10-26 Thread Steve Beattie
This patch fixes two issue with the simple test driver. The first is
that child exec that actually ran the parser was located inside the
eval statement. This meant that if the exec failed for some reason
(like the parser didn't exist), the child wouldn't actually die,
but would pop out of the eval and continue running through the loop
of test profiles (while the parent process does the same). This meant
that if the script ran on the full testsuite with a misconfiguration,
it would explode creating O(n^2) processes, where n is the number of
testcase files -- with over 25k testcases, that's a lot. The fis is to
lift the child exec outside the eval{}, then an exec() failure causes
the child process to die correctly.

The second fix is that several of the testcases were added with the
DESCRIPTION field added in lower case (i.e. #=Description blah blah).
This fix makes the regex that pulls out the description not be
case-sensitive.

---
 parser/tst/simple.pl |   22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

Index: b/parser/tst/simple.pl
===
--- a/parser/tst/simple.pl
+++ b/parser/tst/simple.pl
@@ -74,6 +74,16 @@ sub test_profile {
   my $result = 0;
   my $child;
 
+  $child = open(PARSER, "|-");
+  if ($child == 0) {
+# child
+open(STDOUT, ">/dev/null") or die "Failed to redirect STDOUT";
+open(STDERR, ">/dev/null") or die "Failed to redirect STDERR";
+exec("$config{'parser'}", "-S", "-I", "$config{'includedir'}") or die 
"Bail out! couldn't open parser";
+# noreturn
+  }
+
+  # parent
   eval {
 local $SIG{ALRM} = sub {
   $result = 1;
@@ -83,19 +93,9 @@ sub test_profile {
 
 alarm $config{'timeout'};
 
-$child = open(PARSER, "|-");
-if ($child == 0) {
-  # child
-  open(STDOUT, ">/dev/null") or die "Failed to redirect STDOUT";
-  open(STDERR, ">/dev/null") or die "Failed to redirect STDERR";
-  exec("$config{'parser'}", "-S", "-I", "$config{'includedir'}") or die 
"Bail out! couldn't open parser";
-  # noreturn
-}
-
-# parent
 open(PROFILE, $profile) or die "Bail out! couldn't open profile $profile";
 while () {
-  if (/^#=DESCRIPTION\s*(.*)/) {
+  if (/^#=DESCRIPTION\s*(.*)/i) {
 $description = $1;
   } elsif (/^#=EXRESULT\s*(\w+)/) {
 if ($1 eq "PASS") {


-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor