[apparmor] [patch 04/12] parser: add more convert_aaregex_to_pcre() unit tests

Steve Beattie steve at nxnw.org
Fri Dec 6 14:10:55 UTC 2013


On Thu, Dec 05, 2013 at 07:33:38PM -0800, Seth Arnold wrote:
> On Tue, Dec 03, 2013 at 12:12:20PM -0800, Steve Beattie wrote:
> > Signed-off-by: Steve Beattie <steve at nxnw.org>
> 
> Acked-by: Seth Arnold <seth.arnold at canonical.com>

Thanks.

> I think one more case would be useful, to check that /**/ works as
> expected:
> 
> 	MY_REGEX_TEST("/**/", "/[^/\\x00][^\\x00]*/", ePatternTailGlob);
> 
> Does that look right?

Correct except for the type returned, which will be ePatternRegex if I'm
not mistaken.

And, I think tests for both /*/ and /**/ would be useful. So here's a
patch:

Signed-off-by: Steve Beattie <steve at nxnw.org>
---
 parser/parser_regex.c |    2 ++
 1 file changed, 2 insertions(+)

Index: b/parser/parser_regex.c
===================================================================
--- a/parser/parser_regex.c
+++ b/parser/parser_regex.c
@@ -1390,9 +1390,11 @@ static int test_aaregex_to_pcre(void)
 	MY_REGEX_TEST("/*", "/[^/\\x00][^/\\x00]*", ePatternRegex);
 	MY_REGEX_TEST("/blort/*", "/blort/[^/\\x00][^/\\x00]*", ePatternRegex);
 	MY_REGEX_TEST("/*/blort", "/[^/\\x00][^/\\x00]*/blort", ePatternRegex);
+	MY_REGEX_TEST("/*/", "/[^/\\x00][^/\\x00]*/", ePatternRegex);
 	MY_REGEX_TEST("/**", "/[^/\\x00][^\\x00]*", ePatternTailGlob);
 	MY_REGEX_TEST("/blort/**", "/blort/[^/\\x00][^\\x00]*", ePatternTailGlob);
 	MY_REGEX_TEST("/**/blort", "/[^/\\x00][^\\x00]*/blort", ePatternRegex);
+	MY_REGEX_TEST("/**/", "/[^/\\x00][^\\x00]*/", ePatternRegex);
 
 	/* more complicated quoting */
 	MY_REGEX_FAIL_TEST("\\\\[");

-- 
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20131206/faccf4dc/attachment.pgp>


More information about the AppArmor mailing list