Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Angelo Compagnucci <angelo.compagnucci@gmail.com>
To: buildroot@buildroot.org
Cc: Zoltan Gyarmati <mr.zoltan.gyarmati@gmail.com>,
	Christian Hitz <christian@klarinett.li>,
	Bernd Kuhls <bernd@kuhls.net>,
	Roy Kollen Svendsen <roykollensvendsen@gmail.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Baxiche Su <baxiche@gmail.com>
Subject: [Buildroot] [PATCH 3/4] support/testing: add qt6 runtime test
Date: Sun, 22 Nov 2026 21:21:53 +0100	[thread overview]
Message-ID: <20261122202154.3606582-4-angelo.compagnucci@gmail.com> (raw)
In-Reply-To: <20261122202154.3606582-1-angelo.compagnucci@gmail.com>

Run a QML file with the qml tool of qt6declarative. It checks:

- the JavaScript engine of QtQml;
- the creation of a Qt Quick object;
- XML parsing with XmlListModel, done by QXmlStreamReader of qtbase;
- a Canvas drawing from an SVG path string with Context2D.path;
- an SVG image, loaded by the image plugin of qt6svg;
- a WebSocket echo over the loopback interface (qt6websockets);
- a distance between two coordinates (qt6positioning);
- an SCXML state machine (qt6scxml);
- keyframe interpolation (qt6quicktimeline).

The test uses the software renderer of Qt Quick and the offscreen
platform, so it needs neither OpenGL nor a display. It runs on the
armv5 kernel of the test infrastructure, so no kernel is built.

Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
---
 DEVELOPERS                                    |   2 +
 support/testing/tests/package/test_qt6.py     |  43 +++++
 .../test_qt6/rootfs-overlay/root/test_qt6.qml | 166 ++++++++++++++++++
 .../rootfs-overlay/root/test_qt6.scxml        |   9 +
 .../test_qt6/rootfs-overlay/root/test_qt6.svg |   3 +
 .../test_qt6/rootfs-overlay/root/test_qt6.xml |   5 +
 6 files changed, 228 insertions(+)
 create mode 100644 support/testing/tests/package/test_qt6.py
 create mode 100644 support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.qml
 create mode 100644 support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.scxml
 create mode 100644 support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.svg
 create mode 100644 support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.xml

diff --git a/DEVELOPERS b/DEVELOPERS
index 1d2960f9b3..cea68e8fe9 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -265,6 +265,8 @@ F:	package/sshguard/
 F:	package/sunwait/
 F:	package/sysdig/
 F:	package/uthash/
+F:	support/testing/tests/package/test_qt6.py
+F:	support/testing/tests/package/test_qt6/
 
 N:	Andy Shevchenko <andy.shevchenko@gmail.com>
 F:	package/fb-test-app/
diff --git a/support/testing/tests/package/test_qt6.py b/support/testing/tests/package/test_qt6.py
new file mode 100644
index 0000000000..4a4287cf96
--- /dev/null
+++ b/support/testing/tests/package/test_qt6.py
@@ -0,0 +1,43 @@
+import os
+
+import infra.basetest
+
+
+class TestQt6(infra.basetest.BRTest):
+    # The QML file runs with the qml tool of qt6declarative. It uses
+    # the software renderer of Qt Quick and the offscreen platform, so
+    # no OpenGL and no display are needed.
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        f"""
+        BR2_PACKAGE_QT6=y
+        BR2_PACKAGE_QT6BASE_GUI=y
+        BR2_PACKAGE_QT6BASE_DEFAULT_QPA="offscreen"
+        BR2_PACKAGE_QT6DECLARATIVE=y
+        BR2_PACKAGE_QT6DECLARATIVE_QML_TOOL=y
+        BR2_PACKAGE_QT6DECLARATIVE_QUICK=y
+        BR2_PACKAGE_QT6POSITIONING=y
+        BR2_PACKAGE_QT6QUICKTIMELINE=y
+        BR2_PACKAGE_QT6SCXML=y
+        BR2_PACKAGE_QT6SVG=y
+        BR2_PACKAGE_QT6WEBSOCKETS=y
+        BR2_ROOTFS_OVERLAY="{infra.filepath("tests/package/test_qt6/rootfs-overlay")}"
+        BR2_TARGET_ROOTFS_EXT2=y
+        BR2_TARGET_ROOTFS_EXT2_4=y
+        BR2_TARGET_ROOTFS_EXT2_SIZE="256M"
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+
+    def test_run(self):
+        ext2_file = os.path.join(self.builddir, "images", "rootfs.ext2")
+        self.emulator.boot(arch="armv5",
+                           kernel="builtin",
+                           options=["-drive", f"file={ext2_file},if=scsi,format=raw"],
+                           kernel_cmdline=["rootwait", "root=/dev/sda"])
+        self.emulator.login()
+
+        cmd = "QT_QUICK_BACKEND=software qml /root/test_qt6.qml"
+        output, exit_code = self.emulator.run(cmd, timeout=120)
+        for check in ["js", "quick", "positioning", "timeline", "xmllistmodel",
+                      "canvas", "svg", "websockets", "scxml"]:
+            self.assertIn(f"qml: PASS {check}", output)
+        self.assertEqual(exit_code, 0, output)
diff --git a/support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.qml b/support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.qml
new file mode 100644
index 0000000000..9c51f2fe30
--- /dev/null
+++ b/support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.qml
@@ -0,0 +1,166 @@
+import QtQuick
+import QtQuick.Timeline
+import QtQml.XmlListModel
+import QtPositioning
+import QtScxml
+import QtWebSockets
+
+// Each check prints "PASS <name>" or "FAIL <name>". The qml tool exits
+// with 1 when a check fails, with 0 when all of them pass.
+Window {
+    id: root
+    width: 64
+    height: 64
+    visible: true
+
+    // The asynchronous checks still running
+    property var pending: ["xmllistmodel", "canvas", "svg", "websockets", "scxml"]
+    property bool failed: false
+
+    function check(name, ok) {
+        console.log((ok ? "PASS " : "FAIL ") + name)
+        if (!ok)
+            failed = true
+    }
+
+    // End an asynchronous check: only its first result counts
+    function finish(name, ok) {
+        var i = pending.indexOf(name)
+        if (i < 0)
+            return
+        pending.splice(i, 1)
+        check(name, ok)
+        if (pending.length === 0)
+            Qt.exit(failed ? 1 : 0)
+    }
+
+    Component.onCompleted: {
+        // The JavaScript engine of QtQml
+        check("js", JSON.stringify({ a: [1, 2] }) === '{"a":[1,2]}')
+
+        // An object created by QtQuick
+        var rect = Qt.createQmlObject("import QtQuick; Rectangle { width: 10 }", root)
+        check("quick", rect.width === 10)
+
+        // QtPositioning: one degree of longitude on the equator
+        var distance = QtPositioning.coordinate(0, 0).distanceTo(QtPositioning.coordinate(0, 1))
+        check("positioning", Math.abs(distance - 111195) < 200)
+
+        // QtQuick.Timeline: the value half way between two keyframes
+        timeline.currentFrame = 50
+        check("timeline", Math.abs(animated.value - 5) < 0.001)
+    }
+
+    // XML parsing, done by QXmlStreamReader of qtbase
+    XmlListModel {
+        source: Qt.resolvedUrl("test_qt6.xml")
+        query: "/items/item"
+        XmlListModelRole { name: "name"; elementName: "name" }
+        onStatusChanged: {
+            if (status === XmlListModel.Ready || status === XmlListModel.Error) {
+                root.finish("xmllistmodel", status === XmlListModel.Ready && count === 2)
+            }
+        }
+    }
+
+    // A triangle drawn from an SVG path string with Context2D.path
+    Canvas {
+        anchors.fill: parent
+        onPaint: {
+            var ctx = getContext("2d")
+            ctx.fillStyle = "#ff0000"
+            ctx.path = "M 0 0 L 32 32 L 0 32 Z"
+            ctx.fill()
+            var inside = ctx.getImageData(5, 20, 1, 1).data
+            var outside = ctx.getImageData(20, 5, 1, 1).data
+            root.finish("canvas", inside[0] === 255 && inside[3] === 255 && outside[3] === 0)
+        }
+    }
+
+    // An SVG image, loaded by the image plugin of qtsvg
+    Image {
+        source: Qt.resolvedUrl("test_qt6.svg")
+        onStatusChanged: {
+            if (status === Image.Ready || status === Image.Error) {
+                root.finish("svg", status === Image.Ready && implicitWidth === 32 && implicitHeight === 16)
+            }
+        }
+    }
+
+    // A WebSocket echo over the loopback interface
+    WebSocketServer {
+        id: server
+        host: "127.0.0.1"
+        listen: true
+        onClientConnected: function(socket) {
+            socket.onTextMessageReceived.connect(function(message) {
+                socket.sendTextMessage(message)
+            })
+        }
+    }
+
+    WebSocket {
+        id: client
+        url: server.url
+        active: server.url != ""
+        onStatusChanged: function() {
+            if (client.status === WebSocket.Open)
+                client.sendTextMessage("ping")
+            else if (client.status === WebSocket.Error)
+                root.finish("websockets", false)
+        }
+        onTextMessageReceived: function(message) {
+            root.finish("websockets", message === "ping")
+        }
+    }
+
+    // An SCXML state machine: start in "off", go to "on" on "toggle"
+    property int scxmlStep: 0
+
+    function scxmlStable() {
+        var machine = scxml.stateMachine
+        scxmlStep += 1
+        if (scxmlStep === 1 && machine.isActive("off"))
+            machine.submitEvent("toggle")
+        else
+            finish("scxml", scxmlStep === 2 && machine.isActive("on"))
+    }
+
+    StateMachineLoader {
+        id: scxml
+        source: Qt.resolvedUrl("test_qt6.scxml")
+        onStateMachineChanged: {
+            if (stateMachine) {
+                stateMachine.reachedStableState.connect(root.scxmlStable)
+                stateMachine.start()
+            }
+        }
+    }
+
+    Item {
+        id: animated
+        property real value: 0
+    }
+
+    Timeline {
+        id: timeline
+        startFrame: 0
+        endFrame: 100
+        enabled: true
+        KeyframeGroup {
+            target: animated
+            property: "value"
+            Keyframe { frame: 0; value: 0 }
+            Keyframe { frame: 100; value: 10 }
+        }
+    }
+
+    Timer {
+        interval: 90000
+        running: true
+        onTriggered: {
+            root.check("timeout", false)
+            Qt.exit(1)
+        }
+    }
+}
diff --git a/support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.scxml b/support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.scxml
new file mode 100644
index 0000000000..3982adb993
--- /dev/null
+++ b/support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.scxml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="Switch" initial="off">
+  <state id="off">
+    <transition event="toggle" target="on"/>
+  </state>
+  <state id="on">
+    <transition event="toggle" target="off"/>
+  </state>
+</scxml>
diff --git a/support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.svg b/support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.svg
new file mode 100644
index 0000000000..fabb35b6f0
--- /dev/null
+++ b/support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="32" height="16">
+  <rect width="32" height="16" fill="blue"/>
+</svg>
diff --git a/support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.xml b/support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.xml
new file mode 100644
index 0000000000..6db6e4140e
--- /dev/null
+++ b/support/testing/tests/package/test_qt6/rootfs-overlay/root/test_qt6.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<items>
+  <item><name>one</name></item>
+  <item><name>two</name></item>
+</items>
-- 
2.53.0

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

  parent reply	other threads:[~2026-11-22 20:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22 20:21 [Buildroot] [PATCH 0/4] package/qt6: security bump to 6.12.0, with a runtime test Angelo Compagnucci
2026-11-22 20:21 ` [Buildroot] [PATCH 1/4] package/qt6/qt6positioning: select network for QML Angelo Compagnucci
2026-11-22 20:21 ` [Buildroot] [PATCH 2/4] package/qt6/qt6declarative: add an option for the qml tool Angelo Compagnucci
2026-11-22 20:21 ` Angelo Compagnucci [this message]
2026-11-22 20:21 ` [Buildroot] [PATCH 4/4] package/qt6: security bump version to 6.12.0 Angelo Compagnucci

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=20261122202154.3606582-4-angelo.compagnucci@gmail.com \
    --to=angelo.compagnucci@gmail.com \
    --cc=baxiche@gmail.com \
    --cc=bernd@kuhls.net \
    --cc=buildroot@buildroot.org \
    --cc=christian@klarinett.li \
    --cc=mr.zoltan.gyarmati@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox