On Sat, 2017-01-14 at 15:40 +0100, Nicolas Iooss wrote: > 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 > 945bc8853b62 ("sandbox: make test not fail on systems without > SELinux"). Thanks, applied. > > Signed-off-by: Nicolas Iooss <nicolas.iooss@xxxxxxx> > --- > python/semanage/test-semanage.py | 2 +- > python/sepolicy/test_sepolicy.py | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/python/semanage/test-semanage.py b/python/semanage/test- > semanage.py > index 12ffc98afd6e..c8f6ec231fc2 100644 > --- a/python/semanage/test-semanage.py > +++ b/python/semanage/test-semanage.py > @@ -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: > diff --git a/python/sepolicy/test_sepolicy.py > b/python/sepolicy/test_sepolicy.py > index 61dfb4550830..304e56f60a7c 100644 > --- a/python/sepolicy/test_sepolicy.py > +++ b/python/sepolicy/test_sepolicy.py > @@ -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") _______________________________________________ Selinux mailing list Selinux@xxxxxxxxxxxxx To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx. To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.