From e70f491b7eb2df47be7f9fe919704b5e32b626e5 Mon Sep 17 00:00:00 2001 From: Eilís 'pidge' Ní Fhlannagáin Date: Thu, 7 Dec 2023 12:45:33 +0000 Subject: usergrouptests.py: Add test for switching between static-ids MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test is related to https://bugzilla.yoctoproject.org/show_bug.cgi?id=12107 At the moment it doesn't seem to be able to actually replicate this issue in the bug, which tells me it's likely fixed. (From OE-Core rev: 2b3fa9981252d41d3f23592715657fe810f834ad) Signed-off-by: Eilís 'pidge' Ní Fhlannagáin Signed-off-by: Richard Purdie --- meta/lib/oeqa/selftest/cases/usergrouptests.py | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'meta/lib/oeqa/selftest') diff --git a/meta/lib/oeqa/selftest/cases/usergrouptests.py b/meta/lib/oeqa/selftest/cases/usergrouptests.py index 586d4bc0ee..f6a40b21e7 100644 --- a/meta/lib/oeqa/selftest/cases/usergrouptests.py +++ b/meta/lib/oeqa/selftest/cases/usergrouptests.py @@ -4,8 +4,11 @@ # SPDX-License-Identifier: MIT # +import os +import shutil from oeqa.selftest.case import OESelftestTestCase from oeqa.utils.commands import bitbake +from oeqa.utils.commands import bitbake, get_bb_var, get_test_layer class UserGroupTests(OESelftestTestCase): def test_group_from_dep_package(self): @@ -20,3 +23,33 @@ class UserGroupTests(OESelftestTestCase): self.logger.info("Building useraddbadtask") # fails due to bug #14961 self.assertTrue(bitbake(' useraddbadtask -C fetch')) + + def test_static_useradd_from_dynamic(self): + metaselftestpath = get_test_layer() + self.logger.info("Building core-image-minimal to generate passwd/group file") + bitbake(' core-image-minimal') + self.logger.info("Setting up useradd-staticids") + repropassdir = os.path.join(metaselftestpath, "conf/include") + os.makedirs(repropassdir) + etcdir=os.path.join(os.path.join(os.path.join(get_bb_var("TMPDIR"), "work"), \ + os.path.join(get_bb_var("MACHINE").replace("-","_")+"-poky-linux", "core-image-minimal/1.0/rootfs/etc"))) + shutil.copy(os.path.join(etcdir, "passwd"), os.path.join(repropassdir, "reproducable-passwd")) + shutil.copy(os.path.join(etcdir, "group"), os.path.join(repropassdir, "reproducable-group")) + # Copy the original local.conf + shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/local.conf'), os.path.join(os.environ.get('BUILDDIR'), 'conf/local.conf.orig')) + + self.write_config("USERADDEXTENSION = \"useradd-staticids\"") + self.write_config("USERADD_ERROR_DYNAMIC ??= \"error\"") + self.write_config("USERADD_UID_TABLES += \"conf/include/reproducible-passwd\"") + self.write_config("USERADD_GID_TABLES += \"conf/include/reproducible-group\"") + self.logger.info("Rebuild with staticids") + bitbake(' core-image-minimal') + shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/local.conf.orig'), os.path.join(os.environ.get('BUILDDIR'), 'conf/local.conf')) + self.logger.info("Rebuild without staticids") + bitbake(' core-image-minimal') + self.write_config("USERADDEXTENSION = \"useradd-staticids\"") + self.write_config("USERADD_ERROR_DYNAMIC ??= \"error\"") + self.write_config("USERADD_UID_TABLES += \"files/static-passwd\"") + self.write_config("USERADD_GID_TABLES += \"files/static-group\"") + self.logger.info("Rebuild with other staticids") + self.assertTrue(bitbake(' core-image-minimal')) -- cgit v1.2.3-54-g00ecf