All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] support/testing/tests/package/test_less.py: new runtime test
@ 2023-09-08 20:52 Julien Olivain
  2023-09-10 16:36 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: Julien Olivain @ 2023-09-08 20:52 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain

Signed-off-by: Julien Olivain <ju.o@free.fr>
---
Patch tested on top of branch master at commit d44a888 with commands:

    make check-package
    ...
    0 warnings generated

    support/testing/run-tests \
        -d dl -o output_folder \
        tests.package.test_less
    ...
    OK
---
 DEVELOPERS                                 |  1 +
 support/testing/tests/package/test_less.py | 57 ++++++++++++++++++++++
 2 files changed, 58 insertions(+)
 create mode 100644 support/testing/tests/package/test_less.py

diff --git a/DEVELOPERS b/DEVELOPERS
index 9b500f3701..14b9406507 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1768,6 +1768,7 @@ F:	support/testing/tests/package/test_hwloc.py
 F:	support/testing/tests/package/test_iperf3.py
 F:	support/testing/tests/package/test_kexec.py
 F:	support/testing/tests/package/test_kexec/
+F:	support/testing/tests/package/test_less.py
 F:	support/testing/tests/package/test_libjxl.py
 F:	support/testing/tests/package/test_lrzip.py
 F:	support/testing/tests/package/test_lzip.py
diff --git a/support/testing/tests/package/test_less.py b/support/testing/tests/package/test_less.py
new file mode 100644
index 0000000000..3d8c4fc94c
--- /dev/null
+++ b/support/testing/tests/package/test_less.py
@@ -0,0 +1,57 @@
+import os
+
+import infra.basetest
+
+
+class TestLess(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
+        BR2_PACKAGE_LESS=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()
+
+        # Check the program can execute. This command also checks that
+        # the "less" program is from the actual "less" package, rather
+        # than the Busybox implementation (the Busybox "less" applet
+        # does not recognize the "--version" option and would fail).
+        self.assertRunOk("less --version")
+
+        # We create a test file.
+        ref_txt = "Hello Buildroot!"
+        input_fname = "input.txt"
+        self.assertRunOk(f"echo \'{ref_txt}\' > {input_fname}")
+
+        # "less" is mainly an interactive user program and uses
+        # terminal control characters. This test checks a basic "less"
+        # invocation in which there is no user interaction. The
+        # program is expected to give back the input data.
+        output, exit_code = self.emulator.run(f"less -F {input_fname}")
+        self.assertEqual(exit_code, 0)
+        # "less" might insert a carriage-return ^M control character,
+        # which will be converted to a new-line (by the
+        # str.splitlines() in Emulator.run()). We check that our
+        # reference text line is in the output (rather than only
+        # testing output[0]).
+        self.assertIn(ref_txt, output)
+
+        # We redo about the same test, with "less" reading stdin this
+        # time. We also use the "less -o log" option to log the output
+        # into a file. We expect to see our reference text on stdout.
+        output_fname = "output.txt"
+        cmd = f"cat {input_fname} | less -F -o {output_fname}"
+        output, exit_code = self.emulator.run(cmd)
+        self.assertEqual(exit_code, 0)
+        self.assertIn(ref_txt, output)
+
+        # The output file content which logged the output is also
+        # expected to be the same as the input.
+        self.assertRunOk(f"cmp {input_fname} {output_fname}")
-- 
2.41.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [PATCH 1/1] support/testing/tests/package/test_less.py: new runtime test
  2023-09-08 20:52 [Buildroot] [PATCH 1/1] support/testing/tests/package/test_less.py: new runtime test Julien Olivain
@ 2023-09-10 16:36 ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-09-10 16:36 UTC (permalink / raw)
  To: Julien Olivain; +Cc: buildroot

On Fri,  8 Sep 2023 22:52:42 +0200
Julien Olivain <ju.o@free.fr> wrote:

> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
> Patch tested on top of branch master at commit d44a888 with commands:

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-10 16:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-08 20:52 [Buildroot] [PATCH 1/1] support/testing/tests/package/test_less.py: new runtime test Julien Olivain
2023-09-10 16:36 ` Thomas Petazzoni via buildroot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.