test_pixz.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import os
  2. import infra.basetest
  3. class TestPixz(infra.basetest.BRTest):
  4. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  5. """
  6. BR2_PACKAGE_PIXZ=y
  7. BR2_TARGET_ROOTFS_CPIO=y
  8. # BR2_TARGET_ROOTFS_TAR is not set
  9. """
  10. def test_run(self):
  11. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
  12. self.emulator.boot(arch="armv5",
  13. kernel="builtin",
  14. options=["-initrd", cpio_file])
  15. self.emulator.login()
  16. # Prepare input file with random data and zeroes.
  17. # We keep the size small (4 MB) for the sake of test time.
  18. cmd = "dd if=/dev/urandom of=orig bs=1M count=2 && " \
  19. "dd if=/dev/zero of=orig bs=1M count=2 seek=2"
  20. self.assertRunOk(cmd)
  21. # Compress.
  22. # We ask for 3 threads for good measure but with a very small file on a
  23. # uniprocessor qemu this is only a light validation.
  24. cmd = "cp -v orig compressed && pixz -p 3 compressed"
  25. self.assertRunOk(cmd, timeout=60)
  26. # Uncompress.
  27. cmd = "cp -v compressed.xz uncompressed.xz && pixz -d uncompressed.xz"
  28. self.assertRunOk(cmd)
  29. # Verify.
  30. # The ls is there for debugging.
  31. cmd = "ls -l && cmp orig uncompressed"
  32. self.assertRunOk(cmd)