1import infra.basetest 2from tests.init.base import InitSystemBase as InitSystemBase 3 4 5class InitSystemSystemdBase(InitSystemBase): 6 config = \ 7 """ 8 BR2_arm=y 9 BR2_cortex_a9=y 10 BR2_ARM_ENABLE_VFP=y 11 BR2_TOOLCHAIN_EXTERNAL=y 12 BR2_INIT_SYSTEMD=y 13 BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" 14 BR2_LINUX_KERNEL=y 15 BR2_LINUX_KERNEL_CUSTOM_VERSION=y 16 BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.204" 17 BR2_LINUX_KERNEL_DEFCONFIG="vexpress" 18 BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{}" 19 BR2_LINUX_KERNEL_DTS_SUPPORT=y 20 BR2_LINUX_KERNEL_INTREE_DTS_NAME="vexpress-v2p-ca9" 21 # BR2_TARGET_ROOTFS_TAR is not set 22 """.format(infra.filepath("conf/binfmt-misc-kernel-fragment.config")) 23 24 def check_init(self): 25 super(InitSystemSystemdBase, self).check_init("/lib/systemd/systemd") 26 27 # Test all units are OK 28 output, _ = self.emulator.run("systemctl --no-pager --failed --no-legend") 29 self.assertEqual(len(output), 0) 30 31 # Test we can reach the DBus daemon 32 self.assertRunOk("busctl --no-pager") 33 34 # Test we can read at least one line from the journal 35 output, _ = self.emulator.run("journalctl --no-pager --lines 1 --quiet") 36 self.assertEqual(len(output), 1) 37 38 39class TestInitSystemSystemdRoNetworkd(InitSystemSystemdBase): 40 config = InitSystemSystemdBase.config + \ 41 """ 42 BR2_SYSTEM_DHCP="eth0" 43 # BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set 44 BR2_ROOTFS_OVERLAY="{}" 45 BR2_TARGET_ROOTFS_SQUASHFS=y 46 """.format(infra.filepath("tests/init/systemd-factory")) 47 48 def test_run(self): 49 self.start_emulator("squashfs", "zImage", "vexpress-v2p-ca9") 50 self.check_init() 51 self.check_network("eth0") 52 53 # This one must be executed on the target, to check that 54 # the factory feature works as expected 55 out, exit_code = self.emulator.run("cat /var/foo/bar") 56 self.assertEqual(exit_code, 0) 57 self.assertEqual(out[0], "foobar") 58 59 60class TestInitSystemSystemdRwNetworkd(InitSystemSystemdBase): 61 config = InitSystemSystemdBase.config + \ 62 """ 63 BR2_SYSTEM_DHCP="eth0" 64 BR2_TARGET_ROOTFS_EXT2=y 65 """ 66 67 def test_run(self): 68 self.start_emulator("ext2", "zImage", "vexpress-v2p-ca9") 69 self.check_init() 70 self.check_network("eth0") 71 72 73class TestInitSystemSystemdRoIfupdown(InitSystemSystemdBase): 74 config = InitSystemSystemdBase.config + \ 75 """ 76 BR2_SYSTEM_DHCP="eth0" 77 # BR2_PACKAGE_SYSTEMD_NETWORKD is not set 78 # BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set 79 BR2_TARGET_ROOTFS_SQUASHFS=y 80 """ 81 82 def test_run(self): 83 self.start_emulator("squashfs", "zImage", "vexpress-v2p-ca9") 84 self.check_init() 85 self.check_network("eth0") 86 87 88class TestInitSystemSystemdRwIfupdown(InitSystemSystemdBase): 89 config = InitSystemSystemdBase.config + \ 90 """ 91 BR2_SYSTEM_DHCP="eth0" 92 # BR2_PACKAGE_SYSTEMD_NETWORKD is not set 93 BR2_TARGET_ROOTFS_EXT2=y 94 """ 95 96 def test_run(self): 97 self.start_emulator("ext2", "zImage", "vexpress-v2p-ca9") 98 self.check_init() 99 self.check_network("eth0") 100 101 102class TestInitSystemSystemdRoFull(InitSystemSystemdBase): 103 config = InitSystemSystemdBase.config + \ 104 """ 105 BR2_SYSTEM_DHCP="eth0" 106 # BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set 107 BR2_PACKAGE_SYSTEMD_JOURNAL_REMOTE=y 108 BR2_PACKAGE_SYSTEMD_BACKLIGHT=y 109 BR2_PACKAGE_SYSTEMD_BINFMT=y 110 BR2_PACKAGE_SYSTEMD_COREDUMP=y 111 BR2_PACKAGE_SYSTEMD_FIRSTBOOT=y 112 BR2_PACKAGE_SYSTEMD_HIBERNATE=y 113 BR2_PACKAGE_SYSTEMD_IMPORTD=y 114 BR2_PACKAGE_SYSTEMD_LOCALED=y 115 BR2_PACKAGE_SYSTEMD_LOGIND=y 116 BR2_PACKAGE_SYSTEMD_MACHINED=y 117 BR2_PACKAGE_SYSTEMD_POLKIT=y 118 BR2_PACKAGE_SYSTEMD_QUOTACHECK=y 119 BR2_PACKAGE_SYSTEMD_RANDOMSEED=y 120 BR2_PACKAGE_SYSTEMD_RFKILL=y 121 BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT=y 122 BR2_PACKAGE_SYSTEMD_SYSUSERS=y 123 BR2_PACKAGE_SYSTEMD_VCONSOLE=y 124 BR2_TARGET_ROOTFS_SQUASHFS=y 125 """ 126 127 def test_run(self): 128 self.start_emulator("squashfs", "zImage", "vexpress-v2p-ca9") 129 self.check_init() 130 self.check_network("eth0") 131 132 133class TestInitSystemSystemdRwFull(InitSystemSystemdBase): 134 config = InitSystemSystemdBase.config + \ 135 """ 136 BR2_SYSTEM_DHCP="eth0" 137 BR2_PACKAGE_SYSTEMD_JOURNAL_REMOTE=y 138 BR2_PACKAGE_SYSTEMD_BACKLIGHT=y 139 BR2_PACKAGE_SYSTEMD_BINFMT=y 140 BR2_PACKAGE_SYSTEMD_COREDUMP=y 141 BR2_PACKAGE_SYSTEMD_FIRSTBOOT=y 142 BR2_PACKAGE_SYSTEMD_HIBERNATE=y 143 BR2_PACKAGE_SYSTEMD_IMPORTD=y 144 BR2_PACKAGE_SYSTEMD_LOCALED=y 145 BR2_PACKAGE_SYSTEMD_LOGIND=y 146 BR2_PACKAGE_SYSTEMD_MACHINED=y 147 BR2_PACKAGE_SYSTEMD_POLKIT=y 148 BR2_PACKAGE_SYSTEMD_QUOTACHECK=y 149 BR2_PACKAGE_SYSTEMD_RANDOMSEED=y 150 BR2_PACKAGE_SYSTEMD_RFKILL=y 151 BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT=y 152 BR2_PACKAGE_SYSTEMD_SYSUSERS=y 153 BR2_PACKAGE_SYSTEMD_VCONSOLE=y 154 BR2_TARGET_ROOTFS_EXT2=y 155 """ 156 157 def test_run(self): 158 self.start_emulator("ext2", "zImage", "vexpress-v2p-ca9") 159 self.check_init() 160 self.check_network("eth0") 161