support/testing/tests: add test for check_bin_arch

This tests build a bogus package that installs a binary built for the
host architecture into $(TARGET_DIR), which should cause a build
failure, at least as long as the host architecture isn't ARM.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
[yann.morin.1998@free.fr: drop uneeded subprocess import to fix flake8]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2021.11.x
Thomas Petazzoni 2021-08-17 10:39:28 +02:00 committed by Yann E. MORIN
parent 1259d40b0a
commit c938698b4a
6 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1 @@
source "$BR2_EXTERNAL_DETECT_BAD_ARCH_PATH/package/detect-bad-arch/Config.in"

View File

@ -0,0 +1 @@
name: DETECT_BAD_ARCH

View File

@ -0,0 +1 @@
include $(sort $(wildcard $(BR2_EXTERNAL_DETECT_BAD_ARCH_PATH)/package/*/*.mk))

View File

@ -0,0 +1,4 @@
config BR2_PACKAGE_DETECT_BAD_ARCH
bool
default y

View File

@ -0,0 +1,15 @@
################################################################################
#
# detect-bad-arch
#
################################################################################
define DETECT_BAD_ARCH_BUILD_CMDS
echo "int main(void) { return 0; }" | $(HOSTCC) -x c -o $(@D)/foo -
endef
define DETECT_BAD_ARCH_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 0755 $(@D)/foo $(TARGET_DIR)/usr/bin/foo
endef
$(eval $(generic-package))

View File

@ -0,0 +1,18 @@
import infra
import infra.basetest
class DetectBadArchTest(infra.basetest.BRConfigTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + infra.basetest.MINIMAL_CONFIG
br2_external = [infra.filepath("tests/core/br2-external/detect-bad-arch")]
def test_run(self):
with self.assertRaises(SystemError):
self.b.build()
logf_path = infra.log_file_path(self.b.builddir, "build",
infra.basetest.BRConfigTest.logtofile)
if logf_path:
s = 'ERROR: architecture for "/usr/bin/foo" is'
with open(logf_path, "r") as f:
lines = [l for l in f.readlines() if l.startswith(s)]
self.assertEqual(len(lines), 1)