test_lrzsz.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import os
  2. import infra.basetest
  3. class TestLrzsz(infra.basetest.BRTest):
  4. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  5. """
  6. BR2_PACKAGE_LRZSZ=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. fifo = "/tmp/return-fifo"
  17. data_fname = "data"
  18. data_path = f"/tmp/{data_fname}"
  19. # We check a program can execute.
  20. self.assertRunOk("sz --version")
  21. # We create a data file, to be transferred.
  22. cmd = f"dd if=/dev/urandom of={data_path} bs=1M count=1"
  23. self.assertRunOk(cmd)
  24. # We create a fifo, used as a return fifo.
  25. self.assertRunOk(f"mkfifo {fifo}")
  26. # We transfer the test data using ZMODEM over the pipe and our
  27. # return fifo.
  28. self.assertRunOk(f"sz {data_path} < {fifo} | rz > {fifo}")
  29. # The rz command is supposed to have created the received file
  30. # in the current directory. We expect the received data to be
  31. # the same as the original input file.
  32. self.assertRunOk(f"cmp {data_path} {data_fname}")