test_ubi.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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=0x7ff80
  9. BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE=0x1
  10. BR2_TARGET_ROOTFS_UBI=y
  11. BR2_TARGET_ROOTFS_UBI_PEBSIZE=0x80000
  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 = subprocess.check_output(["file", img],
  21. cwd=self.builddir,
  22. env={"LANG": "C"})
  23. out = out.splitlines()
  24. subprocess.call(["truncate", "-s 128M", img])
  25. self.emulator.boot(arch="armv7",
  26. kernel="builtin",
  27. kernel_cmdline=["root=ubi0:rootfs",
  28. "ubi.mtd=0",
  29. "rootfstype=ubifs"],
  30. options=["-drive", "file={},if=pflash".format(img)])
  31. self.emulator.login()
  32. cmd = "mount | grep 'ubi0:rootfs on / type ubifs'"
  33. _, exit_code = self.emulator.run(cmd)
  34. self.assertEqual(exit_code, 0)