mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-03 15:55:46 +00:00
Write basic test for Python aa_find_mountpoint
Also exercises aa_is_enabled Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
This commit is contained in:
@@ -55,10 +55,27 @@ NO_VALUE_MAP = {
|
|||||||
'fsuid': int(ctypes.c_ulong(-1).value),
|
'fsuid': int(ctypes.c_ulong(-1).value),
|
||||||
'ouid': int(ctypes.c_ulong(-1).value),
|
'ouid': int(ctypes.c_ulong(-1).value),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class AAPythonBindingsTests(unittest.TestCase):
|
class AAPythonBindingsTests(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
# REPORT ALL THE OUTPUT
|
||||||
|
self.maxDiff = None
|
||||||
|
|
||||||
|
def test_enabled_and_find_mountpoint(self):
|
||||||
|
aa_enabled = libapparmor.aa_is_enabled()
|
||||||
|
self.assertIsInstance(aa_enabled, bool)
|
||||||
|
|
||||||
|
if not aa_enabled:
|
||||||
|
self.skipTest("AppArmor is not enabled")
|
||||||
|
|
||||||
|
mount_point = libapparmor.aa_find_mountpoint()
|
||||||
|
self.assertIsInstance(mount_point, str)
|
||||||
|
self.assertGreater(len(mount_point), 0, "mount point should not be empty")
|
||||||
|
self.assertTrue(os.path.isdir(mount_point))
|
||||||
|
|
||||||
|
|
||||||
|
class AALogParsePythonBindingsTests(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# REPORT ALL THE OUTPUT
|
# REPORT ALL THE OUTPUT
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
@@ -145,7 +162,7 @@ def main():
|
|||||||
def stub_test(self, testname=f):
|
def stub_test(self, testname=f):
|
||||||
self._runtest(testname)
|
self._runtest(testname)
|
||||||
stub_test.__doc__ = "test " + f
|
stub_test.__doc__ = "test " + f
|
||||||
setattr(AAPythonBindingsTests, 'test_' + f, stub_test)
|
setattr(AALogParsePythonBindingsTests, 'test_' + f, stub_test)
|
||||||
return unittest.main(verbosity=2)
|
return unittest.main(verbosity=2)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user