mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-26 03:50:44 -09:00
support/testing: add FLAT stack size test case
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> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
committed by
Thomas Petazzoni
parent
6c781be506
commit
0bf4525045
@@ -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/
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
source "$BR2_EXTERNAL_FLAT_STACKSIZE_PATH/package/flat-stacksize-test/Config.in"
|
||||
@@ -0,0 +1 @@
|
||||
name: FLAT_STACKSIZE
|
||||
@@ -0,0 +1 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL_FLAT_STACKSIZE_PATH)/package/*/*.mk))
|
||||
@@ -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.
|
||||
@@ -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
|
||||
@@ -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))
|
||||
@@ -0,0 +1,3 @@
|
||||
int main(void) {
|
||||
return 0;
|
||||
}
|
||||
27
support/testing/tests/core/test_flat_stacksize.py
Normal file
27
support/testing/tests/core/test_flat_stacksize.py
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user