2013-08-05 18:55:34 +05:30
|
|
|
import unittest
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.append('../')
|
|
|
|
import apparmor.common
|
2013-08-10 12:46:22 +05:30
|
|
|
import apparmor.config
|
2013-08-05 18:55:34 +05:30
|
|
|
|
|
|
|
class Test(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
def test_RegexParser(self):
|
2013-08-10 12:46:22 +05:30
|
|
|
tests=apparmor.config.Config('ini')
|
|
|
|
tests.CONF_DIR = '.'
|
|
|
|
regex_tests = tests.read_config('regex_tests.ini')
|
|
|
|
for regex in regex_tests.sections():
|
|
|
|
parsed_regex = re.compile(apparmor.common.convert_regexp(regex))
|
|
|
|
for regex_testcase in regex_tests.options(regex):
|
2013-08-11 15:22:07 +05:30
|
|
|
self.assertEqual(bool(parsed_regex.search(regex_testcase)), eval(regex_tests[regex][regex_testcase]), 'Incorrectly Parsed regex: %s' %regex)
|
2013-09-22 22:51:30 +05:30
|
|
|
|
2013-08-10 12:46:22 +05:30
|
|
|
#def test_readkey(self):
|
|
|
|
# print("Please press the Y button on the keyboard.")
|
|
|
|
# self.assertEqual(apparmor.common.readkey().lower(), 'y', 'Error reading key from shell!')
|
2013-09-22 22:51:30 +05:30
|
|
|
|
2013-08-05 18:55:34 +05:30
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
#import sys;sys.argv = ['', 'Test.test_RegexParser']
|
|
|
|
unittest.main()
|