aboutsummaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorGravatar Antoine Tenart <antoine.tenart@bootlin.com>2020-09-28 16:54:21 +0200
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2020-10-06 15:30:12 +0200
commite383f2835f4ee765be3b57d164cda4a63662bd31 (patch)
treee5f3bda76fcd5ef5ef331a0d2577e6c576fa7ab5 /support
parent31901a5afd9f60e45991753ef74395eed01cd189 (diff)
downloadbuildroot-e383f2835f4ee765be3b57d164cda4a63662bd31.tar.gz
buildroot-e383f2835f4ee765be3b57d164cda4a63662bd31.tar.bz2
support/testing/tests/core/test_selinux.py: new test for BR2_REFPOLICY_EXTRA_MODULES
This patch adds a test for the BR2_REFPOLICY_EXTRA_MODULES functionality (which allows to select extra modules within the SELinux refpolicy using Kconfig). Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Diffstat (limited to 'support')
-rw-r--r--support/testing/tests/core/test_selinux.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/support/testing/tests/core/test_selinux.py b/support/testing/tests/core/test_selinux.py
new file mode 100644
index 0000000000..10be30d791
--- /dev/null
+++ b/support/testing/tests/core/test_selinux.py
@@ -0,0 +1,36 @@
+import os
+
+import infra.basetest
+
+
+class TestSELinuxInfra(infra.basetest.BRTest):
+ config = infra.basetest.BASIC_TOOLCHAIN_CONFIG +\
+ """
+ BR2_PACKAGE_REFPOLICY=y
+ BR2_PACKAGE_PYTHON3=y
+ BR2_PACKAGE_SETOOLS=y
+ BR2_TARGET_ROOTFS_CPIO=y
+ """
+
+ def base_test_run(self):
+ cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
+ self.emulator.boot(arch="armv5", kernel="builtin",
+ options=["-initrd", cpio_file])
+ self.emulator.login()
+
+class TestSELinuxExtraModules(TestSELinuxInfra):
+ config = TestSELinuxInfra.config + \
+ """
+ BR2_REFPOLICY_EXTRA_MODULES="ntp tor"
+ """
+
+ def test_run(self):
+ TestSELinuxInfra.base_test_run(self)
+
+ out, ret = self.emulator.run("seinfo -t ntpd_t", 15)
+ self.assertEqual(ret, 0)
+ self.assertEqual(out[2].strip(), "ntpd_t")
+
+ out, ret = self.emulator.run("seinfo -t tor_t", 15)
+ self.assertEqual(ret, 0)
+ self.assertEqual(out[2].strip(), "tor_t")