mirror of
https://github.com/SELinuxProject/selinux
synced 2025-02-02 02:41:49 +00:00
semanage, sepolicy: make tests not fail on systems without SELinux
selinux.security_getenforce() triggers an exception when running tests
on systems without SELinux. In order to skip tests which need SELinux in
enforcing mode, test selinux.is_selinux_enabled() too, like commit
945bc8853b
("sandbox: make test not fail on systems without SELinux").
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
5b0ad2f00e
commit
baee7238b8
@ -276,7 +276,7 @@ def gen_semanage_test_args(parser):
|
||||
if __name__ == "__main__":
|
||||
import selinux
|
||||
semanage_test_list = [x for x in dir(SemanageTests) if x.startswith("test_")]
|
||||
if selinux.security_getenforce() == 1:
|
||||
if selinux.is_selinux_enabled() and selinux.security_getenforce() == 1:
|
||||
parser = argparse.ArgumentParser(description='Semanage unit test script')
|
||||
gen_semanage_test_args(parser)
|
||||
try:
|
||||
|
@ -115,7 +115,7 @@ class SepolicyTests(unittest.TestCase):
|
||||
|
||||
if __name__ == "__main__":
|
||||
import selinux
|
||||
if selinux.security_getenforce() == 1:
|
||||
if selinux.is_selinux_enabled() and selinux.security_getenforce() == 1:
|
||||
unittest.main()
|
||||
else:
|
||||
print("SELinux must be in enforcing mode for this test")
|
||||
|
Loading…
Reference in New Issue
Block a user