From patchwork Mon Sep 28 14:54:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Tenart X-Patchwork-Id: 1372690 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C0QXx3w8rz9sS8 for ; Tue, 29 Sep 2020 00:54:55 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1D3C58560C; Mon, 28 Sep 2020 14:54:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m737VaQSZnYc; Mon, 28 Sep 2020 14:54:51 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7208684961; Mon, 28 Sep 2020 14:54:51 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 856571BF3A9 for ; Mon, 28 Sep 2020 14:54:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 7CF0386F61 for ; Mon, 28 Sep 2020 14:54:47 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZxK+cM6WM-01 for ; Mon, 28 Sep 2020 14:54:46 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by hemlock.osuosl.org (Postfix) with ESMTPS id EEA7C86EC8 for ; Mon, 28 Sep 2020 14:54:45 +0000 (UTC) Received: from localhost (lfbn-tou-1-1075-236.w90-76.abo.wanadoo.fr [90.76.143.236]) (Authenticated sender: antoine.tenart@bootlin.com) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 187C0100006; Mon, 28 Sep 2020 14:54:43 +0000 (UTC) From: Antoine Tenart To: buildroot@buildroot.org Date: Mon, 28 Sep 2020 16:54:21 +0200 Message-Id: <20200928145425.2109095-4-antoine.tenart@bootlin.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200928145425.2109095-1-antoine.tenart@bootlin.com> References: <20200928145425.2109095-1-antoine.tenart@bootlin.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH 3/7] support/testing: add a test for BR2_REFPOLICY_EXTRA_MODULES X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: matthew.weber@rockwellcollins.com, thomas.petazzoni@bootlin.com Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" 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 --- support/testing/tests/core/test_selinux.py | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 support/testing/tests/core/test_selinux.py diff --git a/support/testing/tests/core/test_selinux.py b/support/testing/tests/core/test_selinux.py new file mode 100644 index 000000000000..10be30d7913d --- /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")