blob: a331ca9f2c4a27bdd446ef1a54335a5274172906 [file] [log] [blame]
Patrick Williams169d7bc2024-01-05 11:33:25 -06001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7import os
8import shutil
9from oeqa.selftest.case import OESelftestTestCase
10from oeqa.utils.commands import bitbake
11from oeqa.utils.commands import bitbake, get_bb_var, get_test_layer
12
13class UserGroupTests(OESelftestTestCase):
14 def test_group_from_dep_package(self):
15 self.logger.info("Building creategroup2")
16 bitbake(' creategroup2 creategroup1')
17 bitbake(' creategroup2 creategroup1 -c clean')
18 self.logger.info("Packaging creategroup2")
19 self.assertTrue(bitbake(' creategroup2 -c package'))
20
21 def test_add_task_between_p_sysroot_and_package(self):
22 # Test for YOCTO #14961
23 self.assertTrue(bitbake('useraddbadtask -C fetch'))
24
25 def test_static_useradd_from_dynamic(self):
26 metaselftestpath = get_test_layer()
27 self.logger.info("Building core-image-minimal to generate passwd/group file")
28 bitbake(' core-image-minimal')
29 self.logger.info("Setting up useradd-staticids")
30 repropassdir = os.path.join(metaselftestpath, "conf/include")
31 os.makedirs(repropassdir)
32 etcdir=os.path.join(os.path.join(os.path.join(get_bb_var("TMPDIR"), "work"), \
33 os.path.join(get_bb_var("MACHINE").replace("-","_")+"-poky-linux", "core-image-minimal/1.0/rootfs/etc")))
34 shutil.copy(os.path.join(etcdir, "passwd"), os.path.join(repropassdir, "reproducable-passwd"))
35 shutil.copy(os.path.join(etcdir, "group"), os.path.join(repropassdir, "reproducable-group"))
36 # Copy the original local.conf
37 shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/local.conf'), os.path.join(os.environ.get('BUILDDIR'), 'conf/local.conf.orig'))
38
39 self.write_config("USERADDEXTENSION = \"useradd-staticids\"")
40 self.write_config("USERADD_ERROR_DYNAMIC ??= \"error\"")
41 self.write_config("USERADD_UID_TABLES += \"conf/include/reproducible-passwd\"")
42 self.write_config("USERADD_GID_TABLES += \"conf/include/reproducible-group\"")
43 self.logger.info("Rebuild with staticids")
44 bitbake(' core-image-minimal')
45 shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/local.conf.orig'), os.path.join(os.environ.get('BUILDDIR'), 'conf/local.conf'))
46 self.logger.info("Rebuild without staticids")
47 bitbake(' core-image-minimal')
48 self.write_config("USERADDEXTENSION = \"useradd-staticids\"")
49 self.write_config("USERADD_ERROR_DYNAMIC ??= \"error\"")
50 self.write_config("USERADD_UID_TABLES += \"files/static-passwd\"")
51 self.write_config("USERADD_GID_TABLES += \"files/static-group\"")
52 self.logger.info("Rebuild with other staticids")
53 self.assertTrue(bitbake(' core-image-minimal'))