test_ubi.py 1.4 KB

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