support/testing/tests/toolchain/test_external: support non-ELF toolchains
authorThomas Petazzoni <thomas.petazzoni@bootlin.com>
Fri, 14 Aug 2020 19:52:32 +0000 (21:52 +0200)
committerYann E. MORIN <yann.morin.1998@free.fr>
Sun, 16 Aug 2020 21:43:48 +0000 (23:43 +0200)
The TestExternalToolchain() base class implement a test checking if
the ELF interpreter that is advertised by Busybox really exists in the
rootfs. Of course, this only makes sense with ELF toolchains. Until
now, only ELF toolchains were tested, but we are going to use
TestExternalToolchain() with non-ELF toolchains as well, so let's make
this conditional.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
[yann.morin.1998@free.fr: strip() lines during readlines()]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
support/testing/tests/toolchain/test_external.py

index 881d2b00db55ef99daa85be1891ac4d337bccc59..db62a84391c4828a5898fe84d96b06a959f2f8f1 100644 (file)
@@ -26,11 +26,15 @@ class TestExternalToolchain(infra.basetest.BRTest):
             path = os.path.join(self.builddir, "target", d)
             self.assertFalse(has_broken_links(path))
 
-        interp = infra.get_elf_prog_interpreter(self.builddir,
-                                                self.toolchain_prefix,
-                                                "bin/busybox")
-        interp_path = os.path.join(self.builddir, "target", interp[1:])
-        self.assertTrue(os.path.exists(interp_path))
+        with open(os.path.join(self.builddir, ".config"), 'r') as configf:
+            configlines = [l.strip() for l in configf.readlines()]
+
+        if "BR2_BINFMT_ELF=y" in configlines:
+            interp = infra.get_elf_prog_interpreter(self.builddir,
+                                                    self.toolchain_prefix,
+                                                    "bin/busybox")
+            interp_path = os.path.join(self.builddir, "target", interp[1:])
+            self.assertTrue(os.path.exists(interp_path))
 
 
 class TestExternalToolchainSourceryArmv4(TestExternalToolchain):