kumquat-buildroot/support/testing/tests/fs/test_ubi.py

39 lines
1.4 KiB
Python
Raw Normal View History

import subprocess
import os
import infra.basetest
class TestUbi(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
BR2_TARGET_ROOTFS_UBIFS=y
support/testing: update logical eraseblock and physical eraseblock size for qemu >= 2.9 The current ubi/ubifs test (test_ubi.py) rely on a Qemu bug present in 2.8.0 that was fixed in Qemu 2.9.0 [1]. The ubi/ubifs settings is updated to run with Qemu >= 2.9.0 using the new multiple chip handling. If needed, the old behavior can be enabled using the pflash01 property "old-multiple-chip-handling" [2]. The issue was not detected until now since we are sill using an old qemu (2.8 from Debian stretch) for testing in gitlab (using the Buildroot Docker image used by gitlab-ci.yml). First the logical eraseblock size (LEB) must be updated to the value 0x3ff80 reported by the kernel when using qemu >= 2.9.0. UBIFS (ubi0:0): Mounting in unauthenticated mode UBIFS error (ubi0:0 pid 1): ubifs_read_superblock: LEB size mismatch: 524160 in superblock, 262016 real UBIFS error (ubi0:0 pid 1): ubifs_read_superblock: bad superblock, error 1 But the system is still failing to boot: UBIFS error (ubi0:0 pid 1): ubifs_scan: garbage UBIFS error (ubi0:0 pid 1): ubifs_recover_master_node: failed to recover master node ubifs is reading garbage since Qemu >= 2.9.0 report a sector length per device divided by the number of devices (see commit [1]). The kernel detect two flash devices (dmesg): Concatenating MTD devices: (0): "40000000.flash" (1): "40000000.flash" into device "40000000.flash" Divide the physical eraseblock (PEB) size by two. Tested with qemu 2.9.0, 5.1.0. Fixes: https://gitlab.com/kubu93/buildroot/-/jobs/1543100932 [1] https://git.qemu.org/?p=qemu.git;a=commitdiff;h=feb0b1aa11f14ee71660aba46b46387d1f923c9e [2] http://lists.busybox.net/pipermail/buildroot/2021-September/622069.html Signed-off-by: Romain Naour <romain.naour@gmail.com> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2021-09-12 16:11:39 +02:00
BR2_TARGET_ROOTFS_UBIFS_LEBSIZE=0x3ff80
BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE=0x1
BR2_TARGET_ROOTFS_UBI=y
support/testing: update logical eraseblock and physical eraseblock size for qemu >= 2.9 The current ubi/ubifs test (test_ubi.py) rely on a Qemu bug present in 2.8.0 that was fixed in Qemu 2.9.0 [1]. The ubi/ubifs settings is updated to run with Qemu >= 2.9.0 using the new multiple chip handling. If needed, the old behavior can be enabled using the pflash01 property "old-multiple-chip-handling" [2]. The issue was not detected until now since we are sill using an old qemu (2.8 from Debian stretch) for testing in gitlab (using the Buildroot Docker image used by gitlab-ci.yml). First the logical eraseblock size (LEB) must be updated to the value 0x3ff80 reported by the kernel when using qemu >= 2.9.0. UBIFS (ubi0:0): Mounting in unauthenticated mode UBIFS error (ubi0:0 pid 1): ubifs_read_superblock: LEB size mismatch: 524160 in superblock, 262016 real UBIFS error (ubi0:0 pid 1): ubifs_read_superblock: bad superblock, error 1 But the system is still failing to boot: UBIFS error (ubi0:0 pid 1): ubifs_scan: garbage UBIFS error (ubi0:0 pid 1): ubifs_recover_master_node: failed to recover master node ubifs is reading garbage since Qemu >= 2.9.0 report a sector length per device divided by the number of devices (see commit [1]). The kernel detect two flash devices (dmesg): Concatenating MTD devices: (0): "40000000.flash" (1): "40000000.flash" into device "40000000.flash" Divide the physical eraseblock (PEB) size by two. Tested with qemu 2.9.0, 5.1.0. Fixes: https://gitlab.com/kubu93/buildroot/-/jobs/1543100932 [1] https://git.qemu.org/?p=qemu.git;a=commitdiff;h=feb0b1aa11f14ee71660aba46b46387d1f923c9e [2] http://lists.busybox.net/pipermail/buildroot/2021-September/622069.html Signed-off-by: Romain Naour <romain.naour@gmail.com> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2021-09-12 16:11:39 +02:00
BR2_TARGET_ROOTFS_UBI_PEBSIZE=0x40000
BR2_TARGET_ROOTFS_UBI_SUBSIZE=1
BR2_TARGET_ROOTFS_UBI_USE_CUSTOM_CONFIG=y
BR2_TARGET_ROOTFS_UBI_CUSTOM_CONFIG_FILE="{}"
""".format(
infra.filepath("tests/fs/test_ubi/ubinize_qemu_pflash_cfi01.cfg"))
def test_run(self):
img = os.path.join(self.builddir, "images", "rootfs.ubi")
out = infra.run_cmd_on_host(self.builddir, ["file", img])
out = out.splitlines()
self.assertIn("UBI image, version 1", out[0])
subprocess.call(["truncate", "-s 64M", img])
self.emulator.boot(arch="armv7",
kernel="builtin",
kernel_cmdline=["root=ubi0:rootfs",
"ubi.mtd=0",
"rootfstype=ubifs"],
options=["-drive", "file={},if=pflash,format=raw".format(img)])
self.emulator.login()
cmd = "mount | grep 'ubi0:rootfs on / type ubifs'"
_, exit_code = self.emulator.run(cmd)
self.assertEqual(exit_code, 0)