1import subprocess 2import os 3 4import infra.basetest 5 6 7class TestUbi(infra.basetest.BRTest): 8 config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ 9 """ 10 BR2_TARGET_ROOTFS_UBIFS=y 11 BR2_TARGET_ROOTFS_UBIFS_LEBSIZE=0x3ff80 12 BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE=0x1 13 BR2_TARGET_ROOTFS_UBI=y 14 BR2_TARGET_ROOTFS_UBI_PEBSIZE=0x40000 15 BR2_TARGET_ROOTFS_UBI_SUBSIZE=1 16 BR2_TARGET_ROOTFS_UBI_USE_CUSTOM_CONFIG=y 17 BR2_TARGET_ROOTFS_UBI_CUSTOM_CONFIG_FILE="{}" 18 """.format( 19 infra.filepath("tests/fs/test_ubi/ubinize_qemu_pflash_cfi01.cfg")) 20 21 def test_run(self): 22 img = os.path.join(self.builddir, "images", "rootfs.ubi") 23 out = infra.run_cmd_on_host(self.builddir, ["file", img]) 24 out = out.splitlines() 25 self.assertIn("UBI image, version 1", out[0]) 26 27 subprocess.call(["truncate", "-s 64M", img]) 28 29 self.emulator.boot(arch="armv7", 30 kernel="builtin", 31 kernel_cmdline=["root=ubi0:rootfs", 32 "ubi.mtd=0", 33 "rootfstype=ubifs"], 34 options=["-drive", "file={},if=pflash,format=raw".format(img)]) 35 self.emulator.login() 36 cmd = "mount | grep 'ubi0:rootfs on / type ubifs'" 37 _, exit_code = self.emulator.run(cmd) 38 self.assertEqual(exit_code, 0) 39