mirror of
https://github.com/SELinuxProject/selinux
synced 2024-12-22 05:59:58 +00:00
sandbox: make test not fail on systems without SELinux
On systems without SELinux (eg. some continuous integration environments), "make test" fails with: Traceback (most recent call last): File "test_sandbox.py", line 110, in <module> if selinux.security_getenforce() == 1: FileNotFoundError: [Errno 2] No such file or directory This is exception is thrown because the selinuxfs file system is not mounted. Detect such configurations using selinux.is_selinux_enabled() and skip the test when SELinux is disabled accordingly. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
4129eb499d
commit
945bc8853b
@ -107,7 +107,7 @@ class SandboxTests(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