Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] support/testing: add gnuplot runtime test
@ 2024-03-24 18:30 Julien Olivain
  2024-05-10 12:03 ` Thomas Petazzoni via buildroot
  2024-06-08  6:39 ` Peter Korsgaard
  0 siblings, 2 replies; 3+ messages in thread
From: Julien Olivain @ 2024-03-24 18:30 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain

Signed-off-by: Julien Olivain <ju.o@free.fr>
---
 DEVELOPERS                                    |  2 +
 support/testing/tests/package/test_gnuplot.py | 73 +++++++++++++++++++
 .../rootfs-overlay/root/gnuplot-test.plot     |  4 +
 3 files changed, 79 insertions(+)
 create mode 100644 support/testing/tests/package/test_gnuplot.py
 create mode 100644 support/testing/tests/package/test_gnuplot/rootfs-overlay/root/gnuplot-test.plot

diff --git a/DEVELOPERS b/DEVELOPERS
index cb2132e67ae..42f6a5e802d 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1792,6 +1792,8 @@ F:	support/testing/tests/package/test_ghostscript/
 F:	support/testing/tests/package/test_glslsandbox_player.py
 F:	support/testing/tests/package/test_glslsandbox_player/
 F:	support/testing/tests/package/test_gnupg2.py
+F:	support/testing/tests/package/test_gnuplot.py
+F:	support/testing/tests/package/test_gnuplot/
 F:	support/testing/tests/package/test_gnuradio.py
 F:	support/testing/tests/package/test_gnuradio/
 F:	support/testing/tests/package/test_gzip.py
diff --git a/support/testing/tests/package/test_gnuplot.py b/support/testing/tests/package/test_gnuplot.py
new file mode 100644
index 00000000000..a2255405373
--- /dev/null
+++ b/support/testing/tests/package/test_gnuplot.py
@@ -0,0 +1,73 @@
+import os
+
+import infra.basetest
+
+
+class TestGnuplot(infra.basetest.BRTest):
+    rootfs_overlay = \
+        infra.filepath("tests/package/test_gnuplot/rootfs-overlay")
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        f"""
+        BR2_PACKAGE_GNUPLOT=y
+        BR2_ROOTFS_OVERLAY="{rootfs_overlay}"
+        BR2_TARGET_ROOTFS_CPIO=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+
+    def gen_gnuplot_cmd(self, gpcmd):
+        return f"gnuplot -e '{gpcmd}'"
+
+    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()
+
+        # We check the program can run.
+        self.assertRunOk("gnuplot --version")
+
+        # When the locale is C, Gnuplot print the warning:
+        # "line 0: warning: iconv failed to convert degree sign"
+        # We set the locale to avoid this warning.
+        self.assertRunOk('export LC_ALL="en_US.UTF-8"')
+
+        # We check Gnuplot can print a string.
+        string = "Hello Buildroot !"
+        cmd = self.gen_gnuplot_cmd(f'print "{string}"')
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        self.assertEqual(out[0], string)
+
+        # We check Gnuplot can do a simple arithmetic operation.
+        op1 = 123
+        op2 = 456
+        expected_result = op1 * op2
+        cmd = self.gen_gnuplot_cmd(f"print {op1} * {op2}")
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        self.assertEqual(int(out[0]), expected_result)
+
+        # We check Gnuplot can return a specific exit code.
+        exit_code = 123
+        cmd = self.gen_gnuplot_cmd(f"exit status {exit_code}")
+        _, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, exit_code)
+
+        # We render a simple plot on the terminal.
+        gpcmd = "set term dumb; set grid; plot [-5:5] x**2;"
+        cmd = self.gen_gnuplot_cmd(gpcmd)
+        self.assertRunOk(cmd)
+
+        # We check a Gnuplot script executes correctly.
+        cmd = "gnuplot /root/gnuplot-test.plot"
+        self.assertRunOk(cmd)
+
+        # Our Gnuplot script is supposed to have generated a text
+        # output of the plot. We check this file contains the plot
+        # title set in the script.
+        exp_str = "Buildroot Test Plot"
+        cmd = f"grep -Fo '{exp_str}' /root/gnuplot-test.txt"
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        self.assertEqual(out[0], exp_str)
diff --git a/support/testing/tests/package/test_gnuplot/rootfs-overlay/root/gnuplot-test.plot b/support/testing/tests/package/test_gnuplot/rootfs-overlay/root/gnuplot-test.plot
new file mode 100644
index 00000000000..04046be04b3
--- /dev/null
+++ b/support/testing/tests/package/test_gnuplot/rootfs-overlay/root/gnuplot-test.plot
@@ -0,0 +1,4 @@
+set term dumb
+set output "gnuplot-test.txt"
+set title "Buildroot Test Plot"
+plot sin(x)
-- 
2.44.0

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

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

* Re: [Buildroot] [PATCH 1/1] support/testing: add gnuplot runtime test
  2024-03-24 18:30 [Buildroot] [PATCH 1/1] support/testing: add gnuplot runtime test Julien Olivain
@ 2024-05-10 12:03 ` Thomas Petazzoni via buildroot
  2024-06-08  6:39 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-05-10 12:03 UTC (permalink / raw)
  To: Julien Olivain; +Cc: buildroot

On Sun, 24 Mar 2024 19:30:38 +0100
Julien Olivain <ju.o@free.fr> wrote:

> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
>  DEVELOPERS                                    |  2 +
>  support/testing/tests/package/test_gnuplot.py | 73 +++++++++++++++++++
>  .../rootfs-overlay/root/gnuplot-test.plot     |  4 +
>  3 files changed, 79 insertions(+)
>  create mode 100644 support/testing/tests/package/test_gnuplot.py
>  create mode 100644 support/testing/tests/package/test_gnuplot/rootfs-overlay/root/gnuplot-test.plot

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] 3+ messages in thread

* Re: [Buildroot] [PATCH 1/1] support/testing: add gnuplot runtime test
  2024-03-24 18:30 [Buildroot] [PATCH 1/1] support/testing: add gnuplot runtime test Julien Olivain
  2024-05-10 12:03 ` Thomas Petazzoni via buildroot
@ 2024-06-08  6:39 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2024-06-08  6:39 UTC (permalink / raw)
  To: Julien Olivain; +Cc: buildroot

>>>>> "Julien" == Julien Olivain <ju.o@free.fr> writes:

 > Signed-off-by: Julien Olivain <ju.o@free.fr>

Committed to 2024.02.x, thanks.

-- 
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

end of thread, other threads:[~2024-06-08  6:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-24 18:30 [Buildroot] [PATCH 1/1] support/testing: add gnuplot runtime test Julien Olivain
2024-05-10 12:03 ` Thomas Petazzoni via buildroot
2024-06-08  6:39 ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox