All of lore.kernel.org
 help / color / mirror / Atom feed
From: Angelo Compagnucci <angelo.compagnucci@gmail.com>
To: buildroot@buildroot.org
Cc: James Hilliard <james.hilliard1@gmail.com>,
	Roy Kollen Svendsen <roykollensvendsen@gmail.com>,
	Dylan Bespalko <dylan.bespalko@gmail.com>,
	Angelo Compagnucci <angelo.compagnucci@gmail.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: [Buildroot] [PATCH v5 5/5] support/testing: add python-matplotlib runtime test
Date: Mon, 16 Nov 2026 22:36:12 +0100	[thread overview]
Message-ID: <20261116213612.873856-6-angelo.compagnucci@gmail.com> (raw)
In-Reply-To: <20261116213612.873856-1-angelo.compagnucci@gmail.com>

The test uses the same configuration as the python-pyside6 test: Qt6
with the offscreen platform, on an Aarch64 machine. It checks two
backends of matplotlib:

- Agg, the default one, which draws to PNG and SVG files;
- QtAgg, the Qt backend, which must find the PySide6 bindings.

Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
---
Changes v4 -> v5:
  - New patch: a runtime test of matplotlib with Qt6, based on the
    python-pyside6 test. It was already in the second v4, sent by
    mistake

 DEVELOPERS                                    |  2 +
 .../tests/package/sample_python_matplotlib.py | 39 +++++++++++++++
 .../tests/package/test_python_matplotlib.py   | 48 +++++++++++++++++++
 3 files changed, 89 insertions(+)
 create mode 100644 support/testing/tests/package/sample_python_matplotlib.py
 create mode 100644 support/testing/tests/package/test_python_matplotlib.py

diff --git a/DEVELOPERS b/DEVELOPERS
index 14aac54303..5fb0c78b80 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -265,7 +265,9 @@ F:	package/sshguard/
 F:	package/sunwait/
 F:	package/sysdig/
 F:	package/uthash/
+F:	support/testing/tests/package/sample_python_matplotlib.py
 F:	support/testing/tests/package/sample_python_pyside6.py
+F:	support/testing/tests/package/test_python_matplotlib.py
 F:	support/testing/tests/package/test_python_pyside6.py
 
 N:	Andy Shevchenko <andy.shevchenko@gmail.com>
diff --git a/support/testing/tests/package/sample_python_matplotlib.py b/support/testing/tests/package/sample_python_matplotlib.py
new file mode 100644
index 0000000000..beb84da680
--- /dev/null
+++ b/support/testing/tests/package/sample_python_matplotlib.py
@@ -0,0 +1,39 @@
+import os
+
+import matplotlib
+
+
+def plot(name):
+    import matplotlib.pyplot as plt
+    fig, ax = plt.subplots()
+    ax.plot([1, 2, 3], [1, 4, 9])
+    fig.canvas.draw()
+    fig.savefig(name)
+    assert os.path.getsize(name) > 0
+    return fig
+
+
+def test_agg():
+    # The default backend, with no display
+    matplotlib.use("Agg")
+    fig = plot("/tmp/plot.png")
+    assert type(fig.canvas).__name__ == "FigureCanvasAgg"
+    plot("/tmp/plot.svg")
+
+
+def test_qtagg():
+    # Without DISPLAY, matplotlib takes the system for headless, and
+    # refuses the Qt backend. With a QApplication running, it accepts it.
+    from PySide6.QtWidgets import QApplication
+    app = QApplication([])
+    matplotlib.use("QtAgg")
+    from matplotlib.backends.qt_compat import QT_API
+    assert QT_API == "PySide6"
+    fig = plot("/tmp/plot-qt.png")
+    assert type(fig.canvas).__name__ == "FigureCanvasQTAgg"
+    QApplication.shutdown(app)
+
+
+if __name__ == "__main__":
+    test_agg()
+    test_qtagg()
diff --git a/support/testing/tests/package/test_python_matplotlib.py b/support/testing/tests/package/test_python_matplotlib.py
new file mode 100644
index 0000000000..de07c1975b
--- /dev/null
+++ b/support/testing/tests/package/test_python_matplotlib.py
@@ -0,0 +1,48 @@
+import os
+
+from tests.package.test_python import TestPythonPackageBase
+
+
+# gitlab-runner: 2xlarge
+class TestPythonPy3MatplotlibQt6(TestPythonPackageBase):
+    __test__ = True
+    # The same configuration as the python-pyside6 test:
+    # - Aarch64, to have more than 256 MB of memory;
+    # - an ext4 root filesystem on a virtio disk, not a cpio initrd.
+    #   The image is big, and this saves memory.
+    config = \
+        """
+        BR2_aarch64=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+        BR2_LINUX_KERNEL=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.81"
+        BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+        BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
+        BR2_PACKAGE_MESA3D=y
+        BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_SOFTPIPE=y
+        BR2_PACKAGE_MESA3D_OPENGL_EGL=y
+        BR2_PACKAGE_MESA3D_OPENGL_ES=y
+        BR2_PACKAGE_QT6=y
+        BR2_PACKAGE_QT6BASE_DEFAULT_QPA="offscreen"
+        BR2_PACKAGE_PYTHON3=y
+        BR2_PACKAGE_PYTHON_MATPLOTLIB=y
+        BR2_PACKAGE_PYTHON_MATPLOTLIB_QT=y
+        BR2_TARGET_ROOTFS_EXT2=y
+        BR2_TARGET_ROOTFS_EXT2_4=y
+        BR2_TARGET_ROOTFS_EXT2_SIZE="512M"
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+    sample_scripts = ["tests/package/sample_python_matplotlib.py"]
+    timeout = 60
+
+    def login(self):
+        drive = os.path.join(self.builddir, "images", "rootfs.ext4")
+        kern = os.path.join(self.builddir, "images", "Image")
+        self.emulator.boot(arch="aarch64",
+                           kernel=kern,
+                           kernel_cmdline=["root=/dev/vda console=ttyAMA0"],
+                           options=["-M", "virt", "-cpu", "cortex-a57", "-m", "512M",
+                                    "-drive", f"file={drive},if=virtio,format=raw"])
+        self.emulator.login()
-- 
2.53.0

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

      parent reply	other threads:[~2026-11-16 21:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-12  8:03 [Buildroot] [PATCH v3 1/1] added package/python-{shiboken6, pyside6}: new packages Dylan Bespalko
2024-08-14  6:02 ` Dylan Bespalko
2026-11-16 15:56 ` [Buildroot] [PATCH v4 0/3] package/python-pyside6: new package Angelo Compagnucci
2026-11-16 15:56   ` [Buildroot] [PATCH v4 1/3] package/python-shiboken6: " Angelo Compagnucci
2026-11-16 15:56   ` [Buildroot] [PATCH v4 2/3] package/python-pyside6: " Angelo Compagnucci
2026-11-16 15:56   ` [Buildroot] [PATCH v4 3/3] support/testing: add python-pyside6 runtime test Angelo Compagnucci
2026-11-16 21:29 ` [Buildroot] [PATCH v4 0/5] package/python-pyside6: new package Angelo Compagnucci
2026-11-16 21:29   ` [Buildroot] [PATCH v4 1/5] package/python-shiboken6: " Angelo Compagnucci
2026-11-16 21:29   ` [Buildroot] [PATCH v4 2/5] package/python-pyside6: " Angelo Compagnucci
2026-11-16 21:29   ` [Buildroot] [PATCH v4 3/5] support/testing: add python-pyside6 runtime test Angelo Compagnucci
2026-11-16 21:29   ` [Buildroot] [PATCH v4 4/5] package/python-matplotlib: add Qt6 support to the Qt display Angelo Compagnucci
2026-11-16 21:29   ` [Buildroot] [PATCH v4 5/5] support/testing: add python-matplotlib runtime test Angelo Compagnucci
2026-11-16 21:36   ` [Buildroot] [PATCH v5 0/5] package/python-pyside6: new package Angelo Compagnucci
2026-11-16 21:36     ` [Buildroot] [PATCH v5 1/5] package/python-shiboken6: " Angelo Compagnucci
2026-11-16 21:36     ` [Buildroot] [PATCH v5 2/5] package/python-pyside6: " Angelo Compagnucci
2026-11-16 21:36     ` [Buildroot] [PATCH v5 3/5] support/testing: add python-pyside6 runtime test Angelo Compagnucci
2026-11-16 21:36     ` [Buildroot] [PATCH v5 4/5] package/python-matplotlib: add Qt6 support to the Qt display Angelo Compagnucci
2026-11-16 21:36     ` Angelo Compagnucci [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261116213612.873856-6-angelo.compagnucci@gmail.com \
    --to=angelo.compagnucci@gmail.com \
    --cc=buildroot@buildroot.org \
    --cc=dylan.bespalko@gmail.com \
    --cc=james.hilliard1@gmail.com \
    --cc=roykollensvendsen@gmail.com \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.