Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] support/testing: quickjs: new runtime test
@ 2026-08-16 14:59 Julien Olivain via buildroot
  2026-08-27 21:09 ` Julien Olivain via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: Julien Olivain via buildroot @ 2026-08-16 14:59 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain

Signed-off-by: Julien Olivain <ju.o@free.fr>
---
Patch tested in:
https://gitlab.com/jolivain/buildroot/-/jobs/15922186716
---
 DEVELOPERS                                    |  2 +
 support/testing/tests/package/test_quickjs.py | 52 +++++++++++++++++++
 .../rootfs-overlay/root/mandel.js             | 21 ++++++++
 3 files changed, 75 insertions(+)
 create mode 100644 support/testing/tests/package/test_quickjs.py
 create mode 100644 support/testing/tests/package/test_quickjs/rootfs-overlay/root/mandel.js

diff --git a/DEVELOPERS b/DEVELOPERS
index 98c9ee55d3..cb5348dc6f 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2028,6 +2028,8 @@ F:	support/testing/tests/package/test_python_pyqt5.py
 F:	support/testing/tests/package/test_python_pyqt5/
 F:	support/testing/tests/package/test_python_spake2.py
 F:	support/testing/tests/package/test_python_sympy.py
+F:	support/testing/tests/package/test_quickjs.py
+F:	support/testing/tests/package/test_quickjs/
 F:	support/testing/tests/package/test_rdma_core.py
 F:	support/testing/tests/package/test_rdma_core/
 F:	support/testing/tests/package/test_rrdtool.py
diff --git a/support/testing/tests/package/test_quickjs.py b/support/testing/tests/package/test_quickjs.py
new file mode 100644
index 0000000000..5d5354ab26
--- /dev/null
+++ b/support/testing/tests/package/test_quickjs.py
@@ -0,0 +1,52 @@
+import os
+
+import infra.basetest
+
+
+class TestQuickJS(infra.basetest.BRTest):
+    rootfs_overlay = \
+        infra.filepath("tests/package/test_quickjs/rootfs-overlay")
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        f"""
+        BR2_PACKAGE_QUICKJS=y
+        BR2_ROOTFS_OVERLAY="{rootfs_overlay}"
+        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="armv7",
+                           kernel="builtin",
+                           options=["-initrd", cpio_file])
+        self.emulator.login()
+
+        # We check can print a message from the command line.
+        msg = "Hello Buildroot!"
+        js_expr = f"console.log(\"{msg}\");"
+        cmd = f"qjs -e '{js_expr}'"
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        self.assertEqual(out[0], msg)
+
+        # We check we can exit with a specific code.
+        exit_code = 123
+        js_expr = f"std.exit({exit_code});"
+        cmd = f"qjs --std -e '{js_expr}'"
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, exit_code)
+        self.assertEqual(len(out), 0)
+
+        # We check we can do basic arithmetic.
+        val1 = 1234
+        val2 = 5678
+        js_expr = f"console.log({val1} * {val2});"
+        cmd = f"qjs -e '{js_expr}'"
+        out, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+        expected_result = val1 * val2
+        self.assertEqual(int(out[0]), expected_result)
+
+        # We check we can run a slightly more complex program and dump
+        # the memory usage.
+        self.assertRunOk("qjs -d --std mandel.js")
diff --git a/support/testing/tests/package/test_quickjs/rootfs-overlay/root/mandel.js b/support/testing/tests/package/test_quickjs/rootfs-overlay/root/mandel.js
new file mode 100644
index 0000000000..4004a26527
--- /dev/null
+++ b/support/testing/tests/package/test_quickjs/rootfs-overlay/root/mandel.js
@@ -0,0 +1,21 @@
+function mandel(file) {
+    points = ",.:-;!/>)|&IH%*Z";
+    for (y = -15; y <= 15; y++) {
+        for (x = 1; x <= 84; x++) {
+            i = 0;
+            r = 0;
+            for (k = 0; k <= 111; k++) {
+                j = (r*r) - (i*i) - 2 + (x/25);
+                i = 2 * r * i + (y/10);
+                if ((j*j + i*i) >= 11) {
+                    break;
+                }
+                r = j;
+            }
+            file.puts(points[k & 0xF]);
+        }
+        file.puts("\n");
+    }
+}
+
+mandel(std.out);
-- 
2.55.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: quickjs: new runtime test
  2026-08-16 14:59 [Buildroot] [PATCH 1/1] support/testing: quickjs: new runtime test Julien Olivain via buildroot
@ 2026-08-27 21:09 ` Julien Olivain via buildroot
  0 siblings, 0 replies; 2+ messages in thread
From: Julien Olivain via buildroot @ 2026-08-27 21:09 UTC (permalink / raw)
  To: Julien Olivain; +Cc: buildroot

On 16/08/2026 16:59, Julien Olivain via buildroot wrote:
> Signed-off-by: Julien Olivain <ju.o@free.fr>

Applied to master.
_______________________________________________
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:[~2026-08-27 21:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-16 14:59 [Buildroot] [PATCH 1/1] support/testing: quickjs: new runtime test Julien Olivain via buildroot
2026-08-27 21:09 ` Julien Olivain via buildroot

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