support/testing/tests/core/test_selinux: new test for BR2_REFPOLICY_EXTRA_MODULES_DIRS
authorAntoine Tenart <antoine.tenart@bootlin.com>
Mon, 28 Sep 2020 14:54:22 +0000 (16:54 +0200)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Tue, 6 Oct 2020 13:30:12 +0000 (15:30 +0200)
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>
DEVELOPERS
support/testing/tests/core/test_selinux.py
support/testing/tests/core/test_selinux/extra_modules/buildroot.fc [new file with mode: 0644]
support/testing/tests/core/test_selinux/extra_modules/buildroot.if [new file with mode: 0644]
support/testing/tests/core/test_selinux/extra_modules/buildroot.te [new file with mode: 0644]

index ba961746701151e87317b744e12672efd36bf2e3..53b476501b7635469e6eb8b2ae85ede00a6806a1 100644 (file)
@@ -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
index 10be30d7913dfa04f253de1a11a850fdc7905eac..9e189d6114df3eb41d082147eed0417731757061 100644 (file)
@@ -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")
diff --git a/support/testing/tests/core/test_selinux/extra_modules/buildroot.fc b/support/testing/tests/core/test_selinux/extra_modules/buildroot.fc
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/support/testing/tests/core/test_selinux/extra_modules/buildroot.if b/support/testing/tests/core/test_selinux/extra_modules/buildroot.if
new file mode 100644 (file)
index 0000000..acf797e
--- /dev/null
@@ -0,0 +1 @@
+## <summary>Buildroot rules</summary>
diff --git a/support/testing/tests/core/test_selinux/extra_modules/buildroot.te b/support/testing/tests/core/test_selinux/extra_modules/buildroot.te
new file mode 100644 (file)
index 0000000..266bc03
--- /dev/null
@@ -0,0 +1,3 @@
+policy_module(buildroot, 1.0.0)
+
+type buildroot_test_t;