50e398e2d9
Add four new tests for systemd (rw and ro in each case): - use dbus-broker instead of the original dbus - use the original dbus, with dbus-broker installed The first two extend the existing IfUpDown test cases by just enabling dbus-broker; the second ones extend this further, by explicitly enabling the original dbus. For one of the tests, we overload the test_run() function to test that the dbus-broker daemon is indeed running as root. We need not replicate that check in the other dbus-broker-only test, and it does not make sense to test that in tests that have the original dbus enabled. Presence of the original dbus and dbus-broker on the same system is valid: the original dbus is used as the default system bus daemon. We do not test switching between the two at runtime, though as this is really too corner-case specific. We just test to ensure the original dbus system bus daemon is not impacted by the presence of dbus-broker. Note: the 'full' test-case enables all systemd options, and some of them do pull the original dbus package, so we can't use that to test the integration of dbus-broker; instead, we extend the ifupdown case, which does not enable the original dbus. The default external toolchain for cortex-A9 is the old ARM toolchain which has kernel headers 4.10 Since dbus-broker needs toolchain headers >= 4.17, it can't be selected with this toolchain. Switch the systemd tests to the Bootlin toolchains instead. We switch all of them to make things easier. Note that we will need to take care in the future that the headers version used in the bootlin toolchain doesn't get bigger than the kernel that is used. The kernel is currently 5.10, the headers in the bleeding edge bootlin toolchain are 5.4. Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> Cc: Norbert Lange <nolange79@gmail.com> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
193 lines
6.0 KiB
Python
193 lines
6.0 KiB
Python
import infra.basetest
|
|
from tests.init.base import InitSystemBase as InitSystemBase
|
|
|
|
|
|
class InitSystemSystemdBase(InitSystemBase):
|
|
config = \
|
|
"""
|
|
BR2_arm=y
|
|
BR2_cortex_a9=y
|
|
BR2_ARM_ENABLE_VFP=y
|
|
BR2_TOOLCHAIN_EXTERNAL=y
|
|
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
|
|
BR2_INIT_SYSTEMD=y
|
|
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
|
|
# BR2_TARGET_ROOTFS_TAR is not set
|
|
"""
|
|
|
|
def check_systemd(self, fs):
|
|
self.start_emulator(fs)
|
|
self.check_init("/lib/systemd/systemd")
|
|
|
|
# Test all units are OK
|
|
output, _ = self.emulator.run("systemctl --no-pager --failed --no-legend")
|
|
self.assertEqual(len(output), 0)
|
|
|
|
# Test we can reach the DBus daemon
|
|
self.assertRunOk("busctl --no-pager")
|
|
|
|
# Test we can read at least one line from the journal
|
|
output, _ = self.emulator.run("journalctl --no-pager --lines 1 --quiet")
|
|
self.assertEqual(len(output), 1)
|
|
|
|
# Check the network is up
|
|
self.check_network("eth0")
|
|
|
|
|
|
class TestInitSystemSystemdRoNetworkd(InitSystemSystemdBase):
|
|
config = InitSystemSystemdBase.config + \
|
|
"""
|
|
BR2_SYSTEM_DHCP="eth0"
|
|
# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
|
|
BR2_ROOTFS_OVERLAY="{}"
|
|
BR2_TARGET_ROOTFS_SQUASHFS=y
|
|
""".format(infra.filepath("tests/init/systemd-factory"))
|
|
|
|
def test_run(self):
|
|
self.check_systemd("squashfs")
|
|
|
|
# This one must be executed on the target, to check that
|
|
# the factory feature works as expected
|
|
out, exit_code = self.emulator.run("cat /var/foo/bar")
|
|
self.assertEqual(exit_code, 0)
|
|
self.assertEqual(out[0], "foobar")
|
|
|
|
|
|
class TestInitSystemSystemdRwNetworkd(InitSystemSystemdBase):
|
|
config = InitSystemSystemdBase.config + \
|
|
"""
|
|
BR2_SYSTEM_DHCP="eth0"
|
|
BR2_TARGET_ROOTFS_EXT2=y
|
|
"""
|
|
|
|
def test_run(self):
|
|
self.check_systemd("ext2")
|
|
|
|
|
|
class TestInitSystemSystemdRoIfupdown(InitSystemSystemdBase):
|
|
config = InitSystemSystemdBase.config + \
|
|
"""
|
|
BR2_SYSTEM_DHCP="eth0"
|
|
# BR2_PACKAGE_SYSTEMD_NETWORKD is not set
|
|
# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
|
|
BR2_TARGET_ROOTFS_SQUASHFS=y
|
|
"""
|
|
|
|
def test_run(self):
|
|
self.check_systemd("squashfs")
|
|
|
|
|
|
class TestInitSystemSystemdRoIfupdownDbusbroker(TestInitSystemSystemdRoIfupdown):
|
|
config = TestInitSystemSystemdRoIfupdown.config + \
|
|
"""
|
|
BR2_PACKAGE_DBUS_BROKER=y
|
|
"""
|
|
|
|
def test_run(self):
|
|
# Parent class' test_run() method does exactly that, no more:
|
|
self.check_systemd("squashfs")
|
|
|
|
# Check that the dbus-broker daemon is running as non-root
|
|
cmd = "find /proc/$(pidof dbus-broker) -maxdepth 1 -name exe -user dbus"
|
|
out, _ = self.emulator.run(cmd)
|
|
self.assertEqual(len(out), 1)
|
|
|
|
|
|
class TestInitSystemSystemdRoIfupdownDbusbrokerDbus(TestInitSystemSystemdRoIfupdownDbusbroker):
|
|
config = TestInitSystemSystemdRoIfupdownDbusbroker.config + \
|
|
"""
|
|
BR2_PACKAGE_DBUS=y
|
|
"""
|
|
|
|
|
|
class TestInitSystemSystemdRwIfupdown(InitSystemSystemdBase):
|
|
config = InitSystemSystemdBase.config + \
|
|
"""
|
|
BR2_SYSTEM_DHCP="eth0"
|
|
# BR2_PACKAGE_SYSTEMD_NETWORKD is not set
|
|
BR2_TARGET_ROOTFS_EXT2=y
|
|
"""
|
|
|
|
def test_run(self):
|
|
self.check_systemd("ext2")
|
|
|
|
|
|
class TestInitSystemSystemdRwIfupdownDbusbroker(TestInitSystemSystemdRwIfupdown):
|
|
config = TestInitSystemSystemdRwIfupdown.config + \
|
|
"""
|
|
BR2_PACKAGE_DBUS_BROKER=y
|
|
"""
|
|
|
|
def test_run(self):
|
|
# Parent class' test_run() method does exactly that, no more:
|
|
self.check_systemd("ext2")
|
|
|
|
# Check that the dbus-broker daemon is running as non-root
|
|
cmd = "find /proc/$(pidof dbus-broker) -maxdepth 1 -name exe -user dbus"
|
|
out, _ = self.emulator.run(cmd)
|
|
self.assertEqual(len(out), 1)
|
|
|
|
|
|
class TestInitSystemSystemdRwIfupdownDbusbrokerDbus(TestInitSystemSystemdRwIfupdownDbusbroker):
|
|
config = TestInitSystemSystemdRwIfupdownDbusbroker.config + \
|
|
"""
|
|
BR2_PACKAGE_DBUS=y
|
|
"""
|
|
|
|
|
|
class TestInitSystemSystemdRoFull(InitSystemSystemdBase):
|
|
config = InitSystemSystemdBase.config + \
|
|
"""
|
|
BR2_SYSTEM_DHCP="eth0"
|
|
# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
|
|
BR2_PACKAGE_SYSTEMD_JOURNAL_REMOTE=y
|
|
BR2_PACKAGE_SYSTEMD_BACKLIGHT=y
|
|
BR2_PACKAGE_SYSTEMD_BINFMT=y
|
|
BR2_PACKAGE_SYSTEMD_COREDUMP=y
|
|
BR2_PACKAGE_SYSTEMD_FIRSTBOOT=y
|
|
BR2_PACKAGE_SYSTEMD_HIBERNATE=y
|
|
BR2_PACKAGE_SYSTEMD_IMPORTD=y
|
|
BR2_PACKAGE_SYSTEMD_LOCALED=y
|
|
BR2_PACKAGE_SYSTEMD_LOGIND=y
|
|
BR2_PACKAGE_SYSTEMD_MACHINED=y
|
|
BR2_PACKAGE_SYSTEMD_POLKIT=y
|
|
BR2_PACKAGE_SYSTEMD_QUOTACHECK=y
|
|
BR2_PACKAGE_SYSTEMD_RANDOMSEED=y
|
|
BR2_PACKAGE_SYSTEMD_RFKILL=y
|
|
BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT=y
|
|
BR2_PACKAGE_SYSTEMD_SYSUSERS=y
|
|
BR2_PACKAGE_SYSTEMD_VCONSOLE=y
|
|
BR2_TARGET_ROOTFS_SQUASHFS=y
|
|
"""
|
|
|
|
def test_run(self):
|
|
self.check_systemd("squashfs")
|
|
|
|
|
|
class TestInitSystemSystemdRwFull(InitSystemSystemdBase):
|
|
config = InitSystemSystemdBase.config + \
|
|
"""
|
|
BR2_SYSTEM_DHCP="eth0"
|
|
BR2_PACKAGE_SYSTEMD_JOURNAL_REMOTE=y
|
|
BR2_PACKAGE_SYSTEMD_BACKLIGHT=y
|
|
BR2_PACKAGE_SYSTEMD_BINFMT=y
|
|
BR2_PACKAGE_SYSTEMD_COREDUMP=y
|
|
BR2_PACKAGE_SYSTEMD_FIRSTBOOT=y
|
|
BR2_PACKAGE_SYSTEMD_HIBERNATE=y
|
|
BR2_PACKAGE_SYSTEMD_IMPORTD=y
|
|
BR2_PACKAGE_SYSTEMD_LOCALED=y
|
|
BR2_PACKAGE_SYSTEMD_LOGIND=y
|
|
BR2_PACKAGE_SYSTEMD_MACHINED=y
|
|
BR2_PACKAGE_SYSTEMD_POLKIT=y
|
|
BR2_PACKAGE_SYSTEMD_QUOTACHECK=y
|
|
BR2_PACKAGE_SYSTEMD_RANDOMSEED=y
|
|
BR2_PACKAGE_SYSTEMD_RFKILL=y
|
|
BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT=y
|
|
BR2_PACKAGE_SYSTEMD_SYSUSERS=y
|
|
BR2_PACKAGE_SYSTEMD_VCONSOLE=y
|
|
BR2_TARGET_ROOTFS_EXT2=y
|
|
"""
|
|
|
|
def test_run(self):
|
|
self.check_systemd("ext2")
|