aboutsummaryrefslogtreecommitdiff
path: root/support/testing/tests/core/test_selinux.py
blob: 10be30d7913dfa04f253de1a11a850fdc7905eac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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")