apparmor/utils/test/test-unix_parse.py
Steve Beattie 365b6d603c utils tests: restructure Unix Parse tests
This patch abstracts out parse tests into a super class to inherit from
and converts the af_unix parse tests to use the super class.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-09-03 18:24:57 -07:00

39 lines
1.3 KiB
Python

#! /usr/bin/env python
# ------------------------------------------------------------------
#
# Copyright (C) 2014 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# ------------------------------------------------------------------
import apparmor.aa as aa
import unittest
from common_test import AAParseTest, setup_regex_tests
class AAParseUnixTest(AAParseTest):
def setUp(self):
self.parse_function = aa.parse_unix_rule
tests = [
('unix,', 'unix base keyword'),
('unix r,', 'unix r rule'),
('unix w,', 'unix w rule'),
('unix rw,', 'unix rw rule'),
('unix send,', 'unix send rule'),
('unix receive,', 'unix receive rule'),
('unix (r),', 'unix (r) rule'),
('unix (w),', 'unix (w) rule'),
('unix (rw),', 'unix (rw) rule'),
('unix (send),', 'unix (send) rule'),
('unix (receive),', 'unix (receive) rule'),
('unix (connect, receive, send) type=stream peer=(label=unconfined,addr="@/tmp/.X11-unix/X[0-9]*"),',
'complex unix rule'),
]
if __name__ == '__main__':
setup_regex_tests(AAParseUnixTest)
unittest.main(verbosity=2)