Przeglądaj źródła

support/testing/tests/core/test_selinux: new test for BR2_REFPOLICY_EXTRA_MODULES_DIRS

Add a test for the BR2_REFPOLICY_EXTRA_MODULES_DIRS functionality (which
allows to provide custom SELinux modules).

Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Antoine Tenart 4 lat temu
rodzic
commit
4fe09f4cab

+ 1 - 0
DEVELOPERS

@@ -255,6 +255,7 @@ F:	package/gnuplot/
 
 N:	Antoine Ténart <antoine.tenart@bootlin.com>
 F:	package/wf111/
+F:	support/testing/tests/core/test_selinux/
 F:	support/testing/tests/core/test_selinux.py
 F:	support/testing/tests/init/test_systemd_selinux/
 F:	support/testing/tests/init/test_systemd_selinux.py

+ 13 - 0
support/testing/tests/core/test_selinux.py

@@ -34,3 +34,16 @@ class TestSELinuxExtraModules(TestSELinuxInfra):
         out, ret = self.emulator.run("seinfo -t tor_t", 15)
         self.assertEqual(ret, 0)
         self.assertEqual(out[2].strip(), "tor_t")
+
+class TestSELinuxExtraModulesDirs(TestSELinuxInfra):
+    config = TestSELinuxInfra.config + \
+             """
+             BR2_REFPOLICY_EXTRA_MODULES_DIRS="{}"
+             """.format(infra.filepath("tests/core/test_selinux/extra_modules"))
+
+    def test_run(self):
+        TestSELinuxInfra.base_test_run(self)
+
+        out, ret = self.emulator.run("seinfo -t buildroot_test_t", 15)
+        self.assertEqual(ret, 0)
+        self.assertEqual(out[2].strip(), "buildroot_test_t")

+ 0 - 0
support/testing/tests/core/test_selinux/extra_modules/buildroot.fc


+ 1 - 0
support/testing/tests/core/test_selinux/extra_modules/buildroot.if

@@ -0,0 +1 @@
+## <summary>Buildroot rules</summary>

+ 3 - 0
support/testing/tests/core/test_selinux/extra_modules/buildroot.te

@@ -0,0 +1,3 @@
+policy_module(buildroot, 1.0.0)
+
+type buildroot_test_t;