test_ubi.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. """
  14. # TODO: if you boot Qemu twice on the same UBI image, it fails to
  15. # attach the image the second time, with "ubi0 error:
  16. # ubi_read_volume_table: the layout volume was not found".
  17. # To be investigated.
  18. def test_run(self):
  19. img = os.path.join(self.builddir, "images", "rootfs.ubi")
  20. out = infra.run_cmd_on_host(self.builddir, ["file", img])
  21. out = out.splitlines()
  22. self.assertIn("UBI image, version 1", out[0])
  23. subprocess.call(["truncate", "-s 64M", img])
  24. self.emulator.boot(arch="armv7",
  25. kernel="builtin",
  26. kernel_cmdline=["root=ubi0:rootfs",
  27. "ubi.mtd=0",
  28. "rootfstype=ubifs"],
  29. options=["-drive", "file={},if=pflash,format=raw".format(img)])
  30. self.emulator.login()
  31. cmd = "mount | grep 'ubi0:rootfs on / type ubifs'"
  32. _, exit_code = self.emulator.run(cmd)
  33. self.assertEqual(exit_code, 0)