Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Angelo Compagnucci <angelo.compagnucci@gmail.com>
To: buildroot@buildroot.org
Cc: Chris Packham <judge.packham@gmail.com>,
	Julien Olivain <ju.o@free.fr>,
	Abilio Marques <abiliojr@gmail.com>,
	"Yann E . MORIN" <yann.morin@orange.com>
Subject: [Buildroot] [PATCH v3 2/2] support/testing: add micropython manifest test
Date: Sat, 21 Nov 2026 23:38:24 +0100	[thread overview]
Message-ID: <20261121223824.420727-2-angelo.compagnucci@gmail.com> (raw)
In-Reply-To: <20261121223824.420727-1-angelo.compagnucci@gmail.com>

Test BR2_PACKAGE_MICROPYTHON_MANIFEST with a manifest that freezes:

- a module next to the manifest;
- a micropython-lib module (base64);
- the default modules of the unix port, kept with include().

micropython-lib is not installed in the image, so the modules can only
be imported from the frozen bytecode.

Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
---
Changes v2 -> v3:
  - new patch

 .../testing/tests/package/test_micropython.py | 33 +++++++++++++++++++
 .../test_micropython/manifest/frozen_hello.py |  1 +
 .../test_micropython/manifest/manifest.py     |  6 ++++
 3 files changed, 40 insertions(+)
 create mode 100644 support/testing/tests/package/test_micropython/manifest/frozen_hello.py
 create mode 100644 support/testing/tests/package/test_micropython/manifest/manifest.py

diff --git a/support/testing/tests/package/test_micropython.py b/support/testing/tests/package/test_micropython.py
index cc0e5854c8..fc061345f3 100644
--- a/support/testing/tests/package/test_micropython.py
+++ b/support/testing/tests/package/test_micropython.py
@@ -77,3 +77,36 @@ class TestMicroPython(infra.basetest.BRTest):
         out, ret = self.emulator.run(f"/root/zcat.py {gz_filename}")
         self.assertEqual(ret, 0)
         self.assertEqual(out[0], msg)
+
+
+class TestMicroPythonManifest(infra.basetest.BRTest):
+    # micropython-lib is not installed: the modules can only be frozen
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        f"""
+        BR2_PACKAGE_MICROPYTHON=y
+        BR2_PACKAGE_MICROPYTHON_MANIFEST="{infra.filepath("tests/package/test_micropython/manifest/manifest.py")}"
+        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()
+
+        # A module next to the manifest
+        out, ret = self.emulator.run(
+            'micropython -c "import frozen_hello; print(frozen_hello.MSG)"')
+        self.assertEqual(ret, 0)
+        self.assertEqual(out[0], "Hello from a frozen module")
+
+        # A micropython-lib module
+        out, ret = self.emulator.run(
+            'micropython -c "import base64; print(base64.b64encode(b\'br\'))"')
+        self.assertEqual(ret, 0)
+        self.assertEqual(out[0], "b'YnI='")
+
+        # A module of the default manifest, kept by include()
+        self.assertRunOk('micropython -c "import asyncio"')
diff --git a/support/testing/tests/package/test_micropython/manifest/frozen_hello.py b/support/testing/tests/package/test_micropython/manifest/frozen_hello.py
new file mode 100644
index 0000000000..3f6516857a
--- /dev/null
+++ b/support/testing/tests/package/test_micropython/manifest/frozen_hello.py
@@ -0,0 +1 @@
+MSG = "Hello from a frozen module"
diff --git a/support/testing/tests/package/test_micropython/manifest/manifest.py b/support/testing/tests/package/test_micropython/manifest/manifest.py
new file mode 100644
index 0000000000..0bd5911fe5
--- /dev/null
+++ b/support/testing/tests/package/test_micropython/manifest/manifest.py
@@ -0,0 +1,6 @@
+# Keep the frozen modules of the default unix manifest
+include("$(PORT_DIR)/variants/standard/manifest.py")
+# A module next to this manifest
+module("frozen_hello.py")
+# A micropython-lib module
+require("base64")
-- 
2.53.0

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

      reply	other threads:[~2026-11-21 22:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-12  2:12 [Buildroot] [PATCH v2 1/1] package/micropython: add support for manifest.py in the configuration Abilio Marques
2026-11-21 22:38 ` [Buildroot] [PATCH v3 1/2] " Angelo Compagnucci
2026-11-21 22:38   ` 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=20261121223824.420727-2-angelo.compagnucci@gmail.com \
    --to=angelo.compagnucci@gmail.com \
    --cc=abiliojr@gmail.com \
    --cc=buildroot@buildroot.org \
    --cc=ju.o@free.fr \
    --cc=judge.packham@gmail.com \
    --cc=yann.morin@orange.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