usergrouptests.py 2.9 KB

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