test_squashfs.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import os
  2. import subprocess
  3. import infra.basetest
  4. class TestSquashfs(infra.basetest.BRTest):
  5. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  6. """
  7. BR2_TARGET_ROOTFS_SQUASHFS=y
  8. # BR2_TARGET_ROOTFS_SQUASHFS4_GZIP is not set
  9. BR2_TARGET_ROOTFS_SQUASHFS4_LZ4=y
  10. # BR2_TARGET_ROOTFS_TAR is not set
  11. """
  12. def test_run(self):
  13. unsquashfs_cmd = ["host/bin/unsquashfs", "-s", "images/rootfs.squashfs"]
  14. out = subprocess.check_output(unsquashfs_cmd,
  15. cwd=self.builddir,
  16. env={"LANG": "C"})
  17. out = out.splitlines()
  18. self.assertEqual(out[0],
  19. "Found a valid SQUASHFS 4:0 superblock on images/rootfs.squashfs.")
  20. self.assertEqual(out[3], "Compression lz4")
  21. img = os.path.join(self.builddir, "images", "rootfs.squashfs")
  22. subprocess.call(["truncate", "-s", "%1M", img])
  23. self.emulator.boot(arch="armv7",
  24. kernel="builtin",
  25. kernel_cmdline=["root=/dev/mmcblk0",
  26. "rootfstype=squashfs"],
  27. options=["-drive", "file={},if=sd,format=raw".format(img)])
  28. self.emulator.login()
  29. cmd = "mount | grep '/dev/root on / type squashfs'"
  30. _, exit_code = self.emulator.run(cmd)
  31. self.assertEqual(exit_code, 0)