All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2] support/testing: add FLAT stack size test case
@ 2026-09-12  9:24 Fengwei Tan
  2026-09-16 20:45 ` Thomas Petazzoni via buildroot
  2026-09-25 14:47 ` Raphaël Mélotte via buildroot
  0 siblings, 2 replies; 3+ messages in thread
From: Fengwei Tan @ 2026-09-12  9:24 UTC (permalink / raw)
  To: buildroot; +Cc: Fengwei Tan, Thomas Petazzoni

Add an infrastructure test case to verify that the per-package
<PKG>_FLAT_STACKSIZE variable correctly configures the stack size in the
generated FLAT binary header.

Signed-off-by: Fengwei Tan <tfx2001@outlook.com>
---
As we discussed in [1], this patch adds a simple test case to verify
that $(PKG)_FLAT_STACKSIZE works as expected.

I have also pushed this patch to GitLab CI, and the test job passed
successfully [2].

[1] https://lore.kernel.org/buildroot/SY8P300MB0041233A165784A8729859B2F8A32@SY8P300MB0041.AUSP300.PROD.OUTLOOK.COM/
[2] https://gitlab.com/tfx2001/buildroot/-/jobs/16053520032

Changes in v2:
- No code changes. Settled on the FLAT header inspection approach as a
  lightweight solution, since no feedback was received on the RFC version
- Link to RFC: https://lore.kernel.org/buildroot/SY8P300MB0041166E9B5D56A3796BD3D6F8A12@SY8P300MB0041.AUSP300.PROD.OUTLOOK.COM/
---
 DEVELOPERS                                         |  3 +++
 .../core/br2-external/flat-stacksize/Config.in     |  1 +
 .../core/br2-external/flat-stacksize/external.desc |  1 +
 .../core/br2-external/flat-stacksize/external.mk   |  1 +
 .../package/flat-stacksize-test/Config.in          |  7 ++++++
 .../package/flat-stacksize-test/Makefile           | 15 ++++++++++++
 .../flat-stacksize-test/flat-stacksize-test.mk     | 22 ++++++++++++++++++
 .../package/flat-stacksize-test/main.c             |  3 +++
 support/testing/tests/core/test_flat_stacksize.py  | 27 ++++++++++++++++++++++
 9 files changed, 80 insertions(+)

diff --git a/DEVELOPERS b/DEVELOPERS
index 97eb2d9cac..ed59f11309 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1124,6 +1124,9 @@ F:	configs/freescale_imx6ullevk_defconfig
 N:	Falco Hyfing <hyfinglists@gmail.com>
 F:	package/python-pymodbus/
 
+N:	Fengwei Tan <tfx2001@outlook.com>
+F:	support/testing/tests/core/test_flat_stacksize.py
+
 N:	Fiona Klute <fiona.klute@gmx.de>
 F:	package/*/S*
 F:	package/panel-mipi-dbi-firmware/
diff --git a/support/testing/tests/core/br2-external/flat-stacksize/Config.in b/support/testing/tests/core/br2-external/flat-stacksize/Config.in
new file mode 100644
index 0000000000..cdb4e9f057
--- /dev/null
+++ b/support/testing/tests/core/br2-external/flat-stacksize/Config.in
@@ -0,0 +1 @@
+source "$BR2_EXTERNAL_FLAT_STACKSIZE_PATH/package/flat-stacksize-test/Config.in"
diff --git a/support/testing/tests/core/br2-external/flat-stacksize/external.desc b/support/testing/tests/core/br2-external/flat-stacksize/external.desc
new file mode 100644
index 0000000000..f9c1a745e0
--- /dev/null
+++ b/support/testing/tests/core/br2-external/flat-stacksize/external.desc
@@ -0,0 +1 @@
+name: FLAT_STACKSIZE
diff --git a/support/testing/tests/core/br2-external/flat-stacksize/external.mk b/support/testing/tests/core/br2-external/flat-stacksize/external.mk
new file mode 100644
index 0000000000..82900bf036
--- /dev/null
+++ b/support/testing/tests/core/br2-external/flat-stacksize/external.mk
@@ -0,0 +1 @@
+include $(sort $(wildcard $(BR2_EXTERNAL_FLAT_STACKSIZE_PATH)/package/*/*.mk))
diff --git a/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/Config.in b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/Config.in
new file mode 100644
index 0000000000..67cf9964f5
--- /dev/null
+++ b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/Config.in
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_FLAT_STACKSIZE_TEST
+	bool "flat-stacksize-test"
+	depends on BR2_BINFMT_FLAT && !BR2_USE_MMU
+	help
+	  Package for testing the $(PKG)_FLAT_STACKSIZE variable, which
+	  defines the stack size of an application built into the
+	  FLAT binary format.
diff --git a/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/Makefile b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/Makefile
new file mode 100644
index 0000000000..dc7681bf56
--- /dev/null
+++ b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/Makefile
@@ -0,0 +1,15 @@
+O ?= $(CURDIR)
+
+CANONICAL_O := $(shell mkdir -p $(O) >/dev/null 2>&1)$(realpath $(O))
+
+TARGET := $(CANONICAL_O)/flat_stacksize_test
+
+all: $(TARGET)
+
+$(TARGET): main.c
+	$(CC) $(CFLAGS) -o $@ main.c
+
+clean:
+	rm -f $(TARGET)
+
+.PHONY: all clean
diff --git a/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/flat-stacksize-test.mk b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/flat-stacksize-test.mk
new file mode 100644
index 0000000000..64695ad2dc
--- /dev/null
+++ b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/flat-stacksize-test.mk
@@ -0,0 +1,22 @@
+################################################################################
+#
+# flat-stacksize-test
+#
+################################################################################
+
+# Define a stack size that is different from the default FLAT
+# stack size (4096 bytes).
+FLAT_STACKSIZE_TEST_FLAT_STACKSIZE = 8192
+
+define FLAT_STACKSIZE_TEST_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) \
+		-C $(FLAT_STACKSIZE_TEST_PKGDIR) O=$(@D) \
+		$(TARGET_CONFIGURE_OPTS)
+endef
+
+define FLAT_STACKSIZE_TEST_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/flat_stacksize_test \
+		$(TARGET_DIR)/usr/bin/flat_stacksize_test
+endef
+
+$(eval $(generic-package))
diff --git a/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/main.c b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/main.c
new file mode 100644
index 0000000000..9b6bdc2ec2
--- /dev/null
+++ b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/main.c
@@ -0,0 +1,3 @@
+int main(void) {
+    return 0;
+}
diff --git a/support/testing/tests/core/test_flat_stacksize.py b/support/testing/tests/core/test_flat_stacksize.py
new file mode 100644
index 0000000000..ab41fadbc8
--- /dev/null
+++ b/support/testing/tests/core/test_flat_stacksize.py
@@ -0,0 +1,27 @@
+import os
+
+import infra.basetest
+
+
+class TestFlatStackSize(infra.basetest.BRTest):
+    br2_external = [infra.filepath("tests/core/br2-external/flat-stacksize")]
+    config = """
+        BR2_arm=y
+        BR2_cortex_m4=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV7M_UCLIBC_STABLE=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        BR2_PACKAGE_FLAT_STACKSIZE_TEST=y
+        """
+
+    def test_run(self):
+        binary = os.path.join(
+            self.builddir, "target", "usr", "bin", "flat_stacksize_test"
+        )
+        self.assertTrue(os.path.exists(binary))
+
+        # Check the FLAT binary header really carries the stack size
+        # declared by the package (8192 = 0x2000).
+        out = infra.run_cmd_on_host(self.builddir, ["arm-linux-flthdr", binary])
+        self.assertIn("Stack Size:   0x2000\n", out)

---
base-commit: 9a1c11c9971b454b3b38c4eb111ac5e42a15cf1c
change-id: 20260912-flat-stacksize-test-793fe88e43bb

Best regards,
--  
Fengwei Tan <tfx2001@outlook.com>

_______________________________________________
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 v2] support/testing: add FLAT stack size test case
  2026-09-12  9:24 [Buildroot] [PATCH v2] support/testing: add FLAT stack size test case Fengwei Tan
@ 2026-09-16 20:45 ` Thomas Petazzoni via buildroot
  2026-09-25 14:47 ` Raphaël Mélotte via buildroot
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-09-16 20:45 UTC (permalink / raw)
  To: Fengwei Tan; +Cc: buildroot

On Sat, Sep 12, 2026 at 05:24:12PM +0800, Fengwei Tan wrote:
> Add an infrastructure test case to verify that the per-package
> <PKG>_FLAT_STACKSIZE variable correctly configures the stack size in the
> generated FLAT binary header.
> 
> Signed-off-by: Fengwei Tan <tfx2001@outlook.com>

Applied to master, thanks!

Best regards,

Thomas Petazzoni
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
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 v2] support/testing: add FLAT stack size test case
  2026-09-12  9:24 [Buildroot] [PATCH v2] support/testing: add FLAT stack size test case Fengwei Tan
  2026-09-16 20:45 ` Thomas Petazzoni via buildroot
@ 2026-09-25 14:47 ` Raphaël Mélotte via buildroot
  1 sibling, 0 replies; 3+ messages in thread
From: Raphaël Mélotte via buildroot @ 2026-09-25 14:47 UTC (permalink / raw)
  To: buildroot, Fengwei Tan; +Cc: Raphaël Mélotte

In reply of:
> Add an infrastructure test case to verify that the per-package
> <PKG>_FLAT_STACKSIZE variable correctly configures the stack size in the
> generated FLAT binary header.
> 
> Signed-off-by: Fengwei Tan <tfx2001@outlook.com>

Applied to 2025.02.x, 2026.08.x. Thanks

> ---
> As we discussed in [1], this patch adds a simple test case to verify
> that $(PKG)_FLAT_STACKSIZE works as expected.
> 
> I have also pushed this patch to GitLab CI, and the test job passed
> successfully [2].
> 
> [1] https://lore.kernel.org/buildroot/SY8P300MB0041233A165784A8729859B2F8A32@SY8P300MB0041.AUSP300.PROD.OUTLOOK.COM/
> [2] https://gitlab.com/tfx2001/buildroot/-/jobs/16053520032
> 
> Changes in v2:
> - No code changes. Settled on the FLAT header inspection approach as a
>   lightweight solution, since no feedback was received on the RFC version
> - Link to RFC: https://lore.kernel.org/buildroot/SY8P300MB0041166E9B5D56A3796BD3D6F8A12@SY8P300MB0041.AUSP300.PROD.OUTLOOK.COM/
> ---
>  DEVELOPERS                                         |  3 +++
>  .../core/br2-external/flat-stacksize/Config.in     |  1 +
>  .../core/br2-external/flat-stacksize/external.desc |  1 +
>  .../core/br2-external/flat-stacksize/external.mk   |  1 +
>  .../package/flat-stacksize-test/Config.in          |  7 ++++++
>  .../package/flat-stacksize-test/Makefile           | 15 ++++++++++++
>  .../flat-stacksize-test/flat-stacksize-test.mk     | 22 ++++++++++++++++++
>  .../package/flat-stacksize-test/main.c             |  3 +++
>  support/testing/tests/core/test_flat_stacksize.py  | 27 ++++++++++++++++++++++
>  9 files changed, 80 insertions(+)
> 
> 
> ---
> base-commit: 9a1c11c9971b454b3b38c4eb111ac5e42a15cf1c
> change-id: 20260912-flat-stacksize-test-793fe88e43bb
> 
> Best regards,
> --  
> Fengwei Tan <tfx2001@outlook.com>
> 
> diff --git a/DEVELOPERS b/DEVELOPERS
> index 97eb2d9cac..ed59f11309 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -1124,6 +1124,9 @@ F:	configs/freescale_imx6ullevk_defconfig
>  N:	Falco Hyfing <hyfinglists@gmail.com>
>  F:	package/python-pymodbus/
>  
> +N:	Fengwei Tan <tfx2001@outlook.com>
> +F:	support/testing/tests/core/test_flat_stacksize.py
> +
>  N:	Fiona Klute <fiona.klute@gmx.de>
>  F:	package/*/S*
>  F:	package/panel-mipi-dbi-firmware/
> diff --git a/support/testing/tests/core/br2-external/flat-stacksize/Config.in b/support/testing/tests/core/br2-external/flat-stacksize/Config.in
> new file mode 100644
> index 0000000000..cdb4e9f057
> --- /dev/null
> +++ b/support/testing/tests/core/br2-external/flat-stacksize/Config.in
> @@ -0,0 +1 @@
> +source "$BR2_EXTERNAL_FLAT_STACKSIZE_PATH/package/flat-stacksize-test/Config.in"
> diff --git a/support/testing/tests/core/br2-external/flat-stacksize/external.desc b/support/testing/tests/core/br2-external/flat-stacksize/external.desc
> new file mode 100644
> index 0000000000..f9c1a745e0
> --- /dev/null
> +++ b/support/testing/tests/core/br2-external/flat-stacksize/external.desc
> @@ -0,0 +1 @@
> +name: FLAT_STACKSIZE
> diff --git a/support/testing/tests/core/br2-external/flat-stacksize/external.mk b/support/testing/tests/core/br2-external/flat-stacksize/external.mk
> new file mode 100644
> index 0000000000..82900bf036
> --- /dev/null
> +++ b/support/testing/tests/core/br2-external/flat-stacksize/external.mk
> @@ -0,0 +1 @@
> +include $(sort $(wildcard $(BR2_EXTERNAL_FLAT_STACKSIZE_PATH)/package/*/*.mk))
> diff --git a/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/Config.in b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/Config.in
> new file mode 100644
> index 0000000000..67cf9964f5
> --- /dev/null
> +++ b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/Config.in
> @@ -0,0 +1,7 @@
> +config BR2_PACKAGE_FLAT_STACKSIZE_TEST
> +	bool "flat-stacksize-test"
> +	depends on BR2_BINFMT_FLAT && !BR2_USE_MMU
> +	help
> +	  Package for testing the $(PKG)_FLAT_STACKSIZE variable, which
> +	  defines the stack size of an application built into the
> +	  FLAT binary format.
> diff --git a/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/Makefile b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/Makefile
> new file mode 100644
> index 0000000000..dc7681bf56
> --- /dev/null
> +++ b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/Makefile
> @@ -0,0 +1,15 @@
> +O ?= $(CURDIR)
> +
> +CANONICAL_O := $(shell mkdir -p $(O) >/dev/null 2>&1)$(realpath $(O))
> +
> +TARGET := $(CANONICAL_O)/flat_stacksize_test
> +
> +all: $(TARGET)
> +
> +$(TARGET): main.c
> +	$(CC) $(CFLAGS) -o $@ main.c
> +
> +clean:
> +	rm -f $(TARGET)
> +
> +.PHONY: all clean
> diff --git a/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/flat-stacksize-test.mk b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/flat-stacksize-test.mk
> new file mode 100644
> index 0000000000..64695ad2dc
> --- /dev/null
> +++ b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/flat-stacksize-test.mk
> @@ -0,0 +1,22 @@
> +################################################################################
> +#
> +# flat-stacksize-test
> +#
> +################################################################################
> +
> +# Define a stack size that is different from the default FLAT
> +# stack size (4096 bytes).
> +FLAT_STACKSIZE_TEST_FLAT_STACKSIZE = 8192
> +
> +define FLAT_STACKSIZE_TEST_BUILD_CMDS
> +	$(TARGET_MAKE_ENV) $(MAKE) \
> +		-C $(FLAT_STACKSIZE_TEST_PKGDIR) O=$(@D) \
> +		$(TARGET_CONFIGURE_OPTS)
> +endef
> +
> +define FLAT_STACKSIZE_TEST_INSTALL_TARGET_CMDS
> +	$(INSTALL) -D -m 0755 $(@D)/flat_stacksize_test \
> +		$(TARGET_DIR)/usr/bin/flat_stacksize_test
> +endef
> +
> +$(eval $(generic-package))
> diff --git a/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/main.c b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/main.c
> new file mode 100644
> index 0000000000..9b6bdc2ec2
> --- /dev/null
> +++ b/support/testing/tests/core/br2-external/flat-stacksize/package/flat-stacksize-test/main.c
> @@ -0,0 +1,3 @@
> +int main(void) {
> +    return 0;
> +}
> diff --git a/support/testing/tests/core/test_flat_stacksize.py b/support/testing/tests/core/test_flat_stacksize.py
> new file mode 100644
> index 0000000000..ab41fadbc8
> --- /dev/null
> +++ b/support/testing/tests/core/test_flat_stacksize.py
> @@ -0,0 +1,27 @@
> +import os
> +
> +import infra.basetest
> +
> +
> +class TestFlatStackSize(infra.basetest.BRTest):
> +    br2_external = [infra.filepath("tests/core/br2-external/flat-stacksize")]
> +    config = """
> +        BR2_arm=y
> +        BR2_cortex_m4=y
> +        BR2_TOOLCHAIN_EXTERNAL=y
> +        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
> +        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV7M_UCLIBC_STABLE=y
> +        # BR2_TARGET_ROOTFS_TAR is not set
> +        BR2_PACKAGE_FLAT_STACKSIZE_TEST=y
> +        """
> +
> +    def test_run(self):
> +        binary = os.path.join(
> +            self.builddir, "target", "usr", "bin", "flat_stacksize_test"
> +        )
> +        self.assertTrue(os.path.exists(binary))
> +
> +        # Check the FLAT binary header really carries the stack size
> +        # declared by the package (8192 = 0x2000).
> +        out = infra.run_cmd_on_host(self.builddir, ["arm-linux-flthdr", binary])
> +        self.assertIn("Stack Size:   0x2000\n", out)
_______________________________________________
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:[~2026-09-25 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-12  9:24 [Buildroot] [PATCH v2] support/testing: add FLAT stack size test case Fengwei Tan
2026-09-16 20:45 ` Thomas Petazzoni via buildroot
2026-09-25 14:47 ` Raphaël Mélotte via buildroot

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.