test_squashfs.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  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 = infra.run_cmd_on_host(self.builddir, unsquashfs_cmd)
  15. out = out.splitlines()
  16. self.assertEqual(out[0],
  17. "Found a valid SQUASHFS 4:0 superblock on images/rootfs.squashfs.")
  18. self.assertEqual(out[3], "Compression lz4")
  19. img = os.path.join(self.builddir, "images", "rootfs.squashfs")
  20. subprocess.call(["truncate", "-s", "%1M", img])
  21. self.emulator.boot(arch="armv7",
  22. kernel="builtin",
  23. kernel_cmdline=["root=/dev/mmcblk0",
  24. "rootfstype=squashfs"],
  25. options=["-drive", "file={},if=sd,format=raw".format(img)])
  26. self.emulator.login()
  27. cmd = "mount | grep '/dev/root on / type squashfs'"
  28. _, exit_code = self.emulator.run(cmd)
  29. self.assertEqual(exit_code, 0)