The CPIO filesystem generated by the test_firewalld test is too large, and doesn't fit as an initramfs in the 256MB of RAM available in the versatilepb machine. This causes a "Initramfs unpacking failed: write error" when booting, and many files being missing from the root filesystem, ultimately causing the test to fail. The test_firewalld test initially started to fail following a systemd update [1][3]: [BRTEST# systemctl is-active firewalld failed But really started to crash at boot following a python 3.14 update [2][4]: Run /init as init process /init: exec: line 15: /sbin/init: not found Also, update TestFirewalldSysVInit to use ext2 instead of cpio. [1]926e0504d0[2]a0a6abc8b1Fixes: [3] https://gitlab.com/buildroot.org/buildroot/-/jobs/12944797059 [4] https://gitlab.com/buildroot.org/buildroot/-/jobs/11856840940 Signed-off-by: Romain Naour <romain.naour@smile.fr> Signed-off-by: Julien Olivain <ju.o@free.fr>
107 lines
4.1 KiB
Python
107 lines
4.1 KiB
Python
"""Test firewalld for both systemd and sysvinit."""
|
|
import os
|
|
import time
|
|
import infra.basetest
|
|
|
|
|
|
class TestFirewalldSystemd(infra.basetest.BRTest):
|
|
"""Build the kernel as firewalld requires several the nftable options."""
|
|
|
|
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_LINUX_KERNEL=y
|
|
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
|
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.61"
|
|
BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
|
|
BR2_LINUX_KERNEL_DTS_SUPPORT=y
|
|
BR2_LINUX_KERNEL_INTREE_DTS_NAME="vexpress-v2p-ca9"
|
|
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
|
|
BR2_PACKAGE_PYTHON3=y
|
|
BR2_PACKAGE_FIREWALLD=y
|
|
BR2_TARGET_ROOTFS_EXT2=y
|
|
BR2_TARGET_ROOTFS_EXT2_SIZE="512M"
|
|
# BR2_TARGET_ROOTFS_TAR is not set
|
|
"""
|
|
|
|
def test_run(self):
|
|
ext2_file = os.path.join(self.builddir, "images", "rootfs.ext2")
|
|
kernel_file = os.path.join(self.builddir, "images", "zImage")
|
|
dtb_file = os.path.join(self.builddir, "images", "vexpress-v2p-ca9.dtb")
|
|
self.emulator.boot(arch="armv7",
|
|
kernel=kernel_file,
|
|
kernel_cmdline=["console=ttyAMA0,115200",
|
|
"rootwait", "root=/dev/mmcblk0"],
|
|
options=[
|
|
'-drive', f'file={ext2_file},if=sd,format=raw',
|
|
"-dtb", dtb_file,
|
|
"-M", "vexpress-a9"
|
|
])
|
|
# It takes quite some time for the system to boot with firewalld,
|
|
self.emulator.login(timeout=120)
|
|
|
|
# It may take some time for firewalld to finish startup.
|
|
# Give it at least 15 seconds.
|
|
is_active = False
|
|
for i in range(15):
|
|
output, _ = self.emulator.run("systemctl is-active firewalld")
|
|
if output[0] == "active":
|
|
is_active = True
|
|
break
|
|
time.sleep(1)
|
|
if not is_active:
|
|
self.fail("firewalld failed to activate!")
|
|
|
|
cmd = "firewall-cmd --state"
|
|
output, exit_code = self.emulator.run(cmd, timeout=10)
|
|
self.assertIn("running", output[0])
|
|
self.assertEqual(exit_code, 0)
|
|
|
|
|
|
class TestFirewalldSysVInit(infra.basetest.BRTest):
|
|
"""Build the kernel as firewalld requires several nftable options."""
|
|
|
|
config = """
|
|
BR2_arm=y
|
|
BR2_cortex_a9=y
|
|
BR2_ARM_ENABLE_VFP=y
|
|
BR2_TOOLCHAIN_EXTERNAL=y
|
|
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
|
|
BR2_LINUX_KERNEL=y
|
|
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
|
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.61"
|
|
BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
|
|
BR2_LINUX_KERNEL_DTS_SUPPORT=y
|
|
BR2_LINUX_KERNEL_INTREE_DTS_NAME="vexpress-v2p-ca9"
|
|
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
|
|
BR2_PACKAGE_PYTHON3=y
|
|
BR2_PACKAGE_FIREWALLD=y
|
|
BR2_TARGET_ROOTFS_EXT2=y
|
|
BR2_TARGET_ROOTFS_EXT2_SIZE="512M"
|
|
# BR2_TARGET_ROOTFS_TAR is not set
|
|
"""
|
|
|
|
def test_run(self):
|
|
ext2_file = os.path.join(self.builddir, "images", "rootfs.ext2")
|
|
kernel_file = os.path.join(self.builddir, "images", "zImage")
|
|
dtb_file = os.path.join(self.builddir, "images", "vexpress-v2p-ca9.dtb")
|
|
self.emulator.boot(arch="armv7",
|
|
kernel=kernel_file,
|
|
kernel_cmdline=["console=ttyAMA0,115200",
|
|
"rootwait", "root=/dev/mmcblk0"],
|
|
options=[
|
|
'-drive', f'file={ext2_file},if=sd,format=raw',
|
|
"-dtb", dtb_file,
|
|
"-M", "vexpress-a9"
|
|
])
|
|
# It takes quite some time for the system to boot with firewalld.
|
|
self.emulator.login(timeout=120)
|
|
cmd = "firewall-cmd --state"
|
|
output, exit_code = self.emulator.run(cmd, timeout=10)
|
|
self.assertIn("running", output[0])
|
|
self.assertEqual(exit_code, 0)
|