From 59a0b5c9fd736cf133b26956e5a93f7f9f2b294e Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Tue, 23 Apr 2024 00:06:32 +0200 Subject: [PATCH] support/testing: add lrzsz runtime test Signed-off-by: Julien Olivain Signed-off-by: Thomas Petazzoni (cherry picked from commit dd45ac10d96b9a93be22a13dd3a4ac7973025008) Signed-off-by: Peter Korsgaard --- DEVELOPERS | 1 + support/testing/tests/package/test_lrzsz.py | 42 +++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 support/testing/tests/package/test_lrzsz.py diff --git a/DEVELOPERS b/DEVELOPERS index 853d8d6c90..bba212def5 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1810,6 +1810,7 @@ F: support/testing/tests/package/test_libjxl.py F: support/testing/tests/package/test_links.py F: support/testing/tests/package/test_links/ F: support/testing/tests/package/test_lrzip.py +F: support/testing/tests/package/test_lrzsz.py F: support/testing/tests/package/test_ltrace.py F: support/testing/tests/package/test_lvm2.py F: support/testing/tests/package/test_lzip.py diff --git a/support/testing/tests/package/test_lrzsz.py b/support/testing/tests/package/test_lrzsz.py new file mode 100644 index 0000000000..23b4cdc531 --- /dev/null +++ b/support/testing/tests/package/test_lrzsz.py @@ -0,0 +1,42 @@ +import os + +import infra.basetest + + +class TestLrzsz(infra.basetest.BRTest): + config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ + """ + BR2_PACKAGE_LRZSZ=y + BR2_TARGET_ROOTFS_CPIO=y + # BR2_TARGET_ROOTFS_TAR is not set + """ + + def test_run(self): + cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot(arch="armv5", + kernel="builtin", + options=["-initrd", cpio_file]) + self.emulator.login() + + fifo = "/tmp/return-fifo" + data_fname = "data" + data_path = f"/tmp/{data_fname}" + + # We check a program can execute. + self.assertRunOk("sz --version") + + # We create a data file, to be transferred. + cmd = f"dd if=/dev/urandom of={data_path} bs=1M count=1" + self.assertRunOk(cmd) + + # We create a fifo, used as a return fifo. + self.assertRunOk(f"mkfifo {fifo}") + + # We transfer the test data using ZMODEM over the pipe and our + # return fifo. + self.assertRunOk(f"sz {data_path} < {fifo} | rz > {fifo}") + + # The rz command is supposed to have created the received file + # in the current directory. We expect the received data to be + # the same as the original input file. + self.assertRunOk(f"cmp {data_path} {data_fname}")