[PATCH 2/3] selftest-users: Convoluted selftest for USERADD_DEPENDS

Eilís 'pidge' Ní Fhlannagáin
2024-02-22T14:54:18Z

This adds a test for 13904's fix by creating a convoluted set of recipes
with USERADD_DEPENDS in non-alpha order.

Signed-off-by: Eilís 'pidge' Ní Fhlannagáin <pidge@baylibre.com>
---
.../selftest-users/acreategroup.bb | 32 ++++++++++++++++
.../selftest-users/bcreategroup.bb | 37 +++++++++++++++++++
.../selftest-users/ccreategroup.bb | 34 +++++++++++++++++
.../selftest-users/dcreategroup.bb | 33 +++++++++++++++++
.../lib/oeqa/selftest/cases/usergrouptests.py | 4 ++
5 files changed, 140 insertions(+)
create mode 100644 meta-selftest/recipes-test/selftest-users/acreategroup.bb
create mode 100644 meta-selftest/recipes-test/selftest-users/bcreategroup.bb
create mode 100644 meta-selftest/recipes-test/selftest-users/ccreategroup.bb
create mode 100644 meta-selftest/recipes-test/selftest-users/dcreategroup.bb

diff --git a/meta-selftest/recipes-test/selftest-users/acreategroup.bb b/meta-selftest/recipes-test/selftest-users/acreategroup.bb
new file mode 100644
index 0000000000..66ed5695a2
--- /dev/null
+++ b/meta-selftest/recipes-test/selftest-users/acreategroup.bb
@@ -0,0 +1,32 @@
+SUMMARY = "creategroup_a"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+LICENSE = "MIT"
+
+S = "${WORKDIR}"
+
+EXCLUDE_FROM_WORLD="1"
+
+inherit useradd allarch
+
+USERADD_PACKAGES = "${PN}"
+USERADD_PARAM:${PN} = "-u 5560 --gid a_group a_user"
+GROUPADD_PARAM:${PN} = "-r a_group"
+
+TESTDIR = "${D}${sysconfdir}/creategroup"
+
+do_install() {
+ install -d ${TESTDIR}
+ install -d ${TESTDIR}/dir
+ touch ${TESTDIR}/file
+ ln -s ./file ${TESTDIR}/symlink
+ install -d ${TESTDIR}/fifotest
+ mkfifo ${TESTDIR}/fifotest/fifo
+
+ chown a_user:a_group ${TESTDIR}/file
+ chown -R a_user:a_group ${TESTDIR}/dir
+ chown -h a_user:a_group ${TESTDIR}/symlink
+ chown -R a_user:a_group ${TESTDIR}/fifotest
+}
+
+FILES:${PN} = "${sysconfdir}/creategroup/*"
diff --git a/meta-selftest/recipes-test/selftest-users/bcreategroup.bb b/meta-selftest/recipes-test/selftest-users/bcreategroup.bb
new file mode 100644
index 0000000000..c4844dd0da
--- /dev/null
+++ b/meta-selftest/recipes-test/selftest-users/bcreategroup.bb
@@ -0,0 +1,37 @@
+SUMMARY = "creategroup_b"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+LICENSE = "MIT"
+
+# This recipe requires a and c. C requires A. Reverse alpha.
+
+USERADD_DEPENDS = "acreategroup ccreategroup"
+
+S = "${WORKDIR}"
+
+EXCLUDE_FROM_WORLD="1"
+
+inherit useradd allarch
+
+USERADD_PACKAGES = "${PN}"
+USERADD_PARAM:${PN} = "-u 5561 -g b_group -G a_group,c_group b_user "
+GROUPADD_PARAM:${PN} = "-r b_group"
+
+TESTDIR = "${D}${sysconfdir}/creategroup"
+
+do_install() {
+ install -d ${TESTDIR}
+ install -d ${TESTDIR}/dir
+ touch ${TESTDIR}/file
+ ln -s ./file ${TESTDIR}/symlink
+ install -d ${TESTDIR}/fifotest
+ mkfifo ${TESTDIR}/fifotest/fifo
+
+ chown a_user:a_group ${TESTDIR}/file
+ chown -R c_user:c_group ${TESTDIR}/dir
+ chown -h a_user:a_group ${TESTDIR}/symlink
+ chown -R b_user:b_group ${TESTDIR}/fifotest
+}
+
+FILES:${PN} = "${sysconfdir}/creategroup/*"
+
diff --git a/meta-selftest/recipes-test/selftest-users/ccreategroup.bb b/meta-selftest/recipes-test/selftest-users/ccreategroup.bb
new file mode 100644
index 0000000000..021b1ebbf7
--- /dev/null
+++ b/meta-selftest/recipes-test/selftest-users/ccreategroup.bb
@@ -0,0 +1,34 @@
+SUMMARY = "creategroup_c"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+LICENSE = "MIT"
+
+USERADD_DEPENDS = "acreategroup"
+
+S = "${WORKDIR}"
+
+EXCLUDE_FROM_WORLD="1"
+
+inherit useradd allarch
+
+USERADD_PACKAGES = "${PN}"
+USERADD_PARAM:${PN} = "-u 5563 --gid c_group -G a_group c_user"
+GROUPADD_PARAM:${PN} = "-r c_group"
+
+TESTDIR = "${D}${sysconfdir}/creategroup"
+
+do_install() {
+ install -d ${TESTDIR}
+ install -d ${TESTDIR}/dir
+ touch ${TESTDIR}/file
+ ln -s ./file ${TESTDIR}/symlink
+ install -d ${TESTDIR}/fifotest
+ mkfifo ${TESTDIR}/fifotest/fifo
+
+ chown c_user:c_group ${TESTDIR}/file
+ chown -R c_user:c_group ${TESTDIR}/dir
+ chown -h c_user:c_group ${TESTDIR}/symlink
+ chown -R c_user:c_group ${TESTDIR}/fifotest
+}
+
+FILES:${PN} = "${sysconfdir}/creategroup/*"
diff --git a/meta-selftest/recipes-test/selftest-users/dcreategroup.bb b/meta-selftest/recipes-test/selftest-users/dcreategroup.bb
new file mode 100644
index 0000000000..b96ca92a16
--- /dev/null
+++ b/meta-selftest/recipes-test/selftest-users/dcreategroup.bb
@@ -0,0 +1,33 @@
+SUMMARY = "creategroup_d"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+LICENSE = "MIT"
+
+USERADD_DEPENDS = "bcreategroup"
+
+S = "${WORKDIR}"
+
+EXCLUDE_FROM_WORLD="1"
+
+inherit useradd allarch
+
+USERADD_PACKAGES = "${PN}"
+USERADD_PARAM:${PN} = "-u 5564 -g d_group -G b_group d_user "
+GROUPADD_PARAM:${PN} = "-r d_group"
+
+TESTDIR = "${D}${sysconfdir}/creategroup"
+
+do_install() {
+ install -d ${TESTDIR}
+ install -d ${TESTDIR}/dir
+ touch ${TESTDIR}/file
+ ln -s ./file ${TESTDIR}/symlink
+ install -d ${TESTDIR}/fifotest
+ mkfifo ${TESTDIR}/fifotest/fifo
+
+ chown d_user:d_group ${TESTDIR}/file
+ chown -R d_user:b_group ${TESTDIR}/dir
+ chown -h d_user:d_group ${TESTDIR}/symlink
+ chown -R d_user:b_group ${TESTDIR}/fifotest
+}
+
diff --git a/meta/lib/oeqa/selftest/cases/usergrouptests.py b/meta/lib/oeqa/selftest/cases/usergrouptests.py
index a331ca9f2c..3c59b0f290 100644
--- a/meta/lib/oeqa/selftest/cases/usergrouptests.py
+++ b/meta/lib/oeqa/selftest/cases/usergrouptests.py
@@ -22,6 +22,10 @@ class UserGroupTests(OESelftestTestCase):
# Test for YOCTO #14961
self.assertTrue(bitbake('useraddbadtask -C fetch'))

+ def test_postinst_order(self):
+ self.logger.info("Building dcreategroup")
+ self.assertTrue(bitbake(' dcreategroup'))
+
def test_static_useradd_from_dynamic(self):
metaselftestpath = get_test_layer()
self.logger.info("Building core-image-minimal to generate passwd/group file")
--
2.34.1