From patchwork Mon Mar 20 20:36:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 741168 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vn7725J8Dz9rvt for ; Tue, 21 Mar 2017 07:37:50 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id E464A88F19; Mon, 20 Mar 2017 20:37:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TSYY117sBfq7; Mon, 20 Mar 2017 20:37:42 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id B28D988F1B; Mon, 20 Mar 2017 20:37:24 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 5AC631C0CF8 for ; Mon, 20 Mar 2017 20:37:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 567AB30728 for ; Mon, 20 Mar 2017 20:37:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id A7-FypexIeMu for ; Mon, 20 Mar 2017 20:37:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by silver.osuosl.org (Postfix) with ESMTP id 6E7F4306B4 for ; Mon, 20 Mar 2017 20:37:17 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 16ECB2081A; Mon, 20 Mar 2017 21:37:17 +0100 (CET) Received: from localhost (LFbn-1-6691-76.w90-120.abo.wanadoo.fr [90.120.129.76]) by mail.free-electrons.com (Postfix) with ESMTPSA id CFFCC207E4; Mon, 20 Mar 2017 21:36:57 +0100 (CET) From: Thomas Petazzoni To: Buildroot List Date: Mon, 20 Mar 2017 21:36:54 +0100 Message-Id: <1490042214-6762-6-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490042214-6762-1-git-send-email-thomas.petazzoni@free-electrons.com> References: <1490042214-6762-1-git-send-email-thomas.petazzoni@free-electrons.com> Cc: Thomas Petazzoni , Luca Ceresoli , "Yann E. MORIN" , Ricardo Martincoski Subject: [Buildroot] [PATCH v3 5/5] support/testing: add toolchain tests X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This commit adds an initial toolchain test case, testing the ARM CodeSourcery toolchain, just checking that the proper sysroot is used, and that a minimal Linux system boots fine under Qemu. Signed-off-by: Thomas Petazzoni --- support/testing/tests/toolchain/__init__.py | 0 support/testing/tests/toolchain/test_external.py | 156 +++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 support/testing/tests/toolchain/__init__.py create mode 100644 support/testing/tests/toolchain/test_external.py diff --git a/support/testing/tests/toolchain/__init__.py b/support/testing/tests/toolchain/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/support/testing/tests/toolchain/test_external.py b/support/testing/tests/toolchain/test_external.py new file mode 100644 index 0000000..1fbf81f --- /dev/null +++ b/support/testing/tests/toolchain/test_external.py @@ -0,0 +1,156 @@ +import os +import infra + +BASIC_CONFIG = \ +""" +BR2_TARGET_ROOTFS_CPIO=y +# BR2_TARGET_ROOTFS_TAR is not set +""" + +def check_broken_links(path): + for root, dirs, files in os.walk(path): + for f in files: + fpath = os.path.join(root, f) + if not os.path.exists(fpath): + return True + return False + +class TestExternalToolchain(infra.basetest.BRTest): + def common_check(self): + # Check for broken symlinks + for d in ["lib", "usr/lib"]: + path = os.path.join(self.builddir, "staging", d) + self.assertFalse(check_broken_links(path)) + path = os.path.join(self.builddir, "target", d) + self.assertFalse(check_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)) + +class TestExternalToolchainSourceryArmv4(TestExternalToolchain): + config = BASIC_CONFIG + \ +""" +BR2_arm=y +BR2_arm920t=y +BR2_TOOLCHAIN_EXTERNAL=y +BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM=y +""" + toolchain_prefix = "arm-none-linux-gnueabi" + + def test_run(self): + TestExternalToolchain.common_check(self) + + # Check the architecture variant + arch = infra.get_file_arch(self.builddir, + self.toolchain_prefix, + "lib/libc.so.6") + self.assertEqual(arch, "v4T") + + # Check the sysroot symlink + symlink = os.path.join(self.builddir, "staging", "armv4t") + self.assertTrue(os.path.exists(symlink)) + self.assertEqual(os.readlink(symlink), "./") + + # Boot the system + img = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot(arch="armv5", + kernel="builtin", + options=["-initrd", img]) + self.emulator.login() + +class TestExternalToolchainSourceryArmv5(TestExternalToolchain): + config = BASIC_CONFIG + \ +""" +BR2_arm=y +BR2_TOOLCHAIN_EXTERNAL=y +BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM=y +""" + toolchain_prefix = "arm-none-linux-gnueabi" + + def test_run(self): + TestExternalToolchain.common_check(self) + + # Check the architecture variant + arch = infra.get_file_arch(self.builddir, + self.toolchain_prefix, + "lib/libc.so.6") + self.assertEqual(arch, "v5TE") + + # Boot the system + img = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot(arch="armv5", + kernel="builtin", + options=["-initrd", img]) + self.emulator.login() + +class TestExternalToolchainSourceryArmv7(TestExternalToolchain): + config = BASIC_CONFIG + \ +""" +BR2_arm=y +BR2_cortex_a8=y +BR2_ARM_EABI=y +BR2_ARM_INSTRUCTIONS_THUMB2=y +BR2_TOOLCHAIN_EXTERNAL=y +BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM=y +""" + toolchain_prefix = "arm-none-linux-gnueabi" + + def test_run(self): + TestExternalToolchain.common_check(self) + + # Check the architecture variant + arch = infra.get_file_arch(self.builddir, + self.toolchain_prefix, + "lib/libc.so.6") + self.assertEqual(arch, "v7") + isa = infra.get_elf_arch_tag(self.builddir, + self.toolchain_prefix, + "lib/libc.so.6", + "Tag_THUMB_ISA_use") + self.assertEqual(isa, "Thumb-2") + + # Check we have the sysroot symlink + symlink = os.path.join(self.builddir, "staging", "thumb2") + self.assertTrue(os.path.exists(symlink)) + self.assertEqual(os.readlink(symlink), "./") + + # Boot the system + img = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot(arch="armv7", + kernel="builtin", + options=["-initrd", img]) + self.emulator.login() + +class TestExternalToolchainLinaroArm(TestExternalToolchain): + config = BASIC_CONFIG + \ +""" +BR2_arm=y +BR2_cortex_a8=y +BR2_TOOLCHAIN_EXTERNAL=y +BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM=y +""" + toolchain_prefix = "arm-linux-gnueabihf" + + def test_run(self): + TestExternalToolchain.common_check(self) + + # Check the architecture variant + arch = infra.get_file_arch(self.builddir, + self.toolchain_prefix, + "lib/libc.so.6") + self.assertEqual(arch, "v7") + isa = infra.get_elf_arch_tag(self.builddir, + self.toolchain_prefix, + "lib/libc.so.6", + "Tag_THUMB_ISA_use") + self.assertEqual(isa, "Thumb-2") + + # Boot the system + img = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot(arch="armv7", + kernel="builtin", + options=["-initrd", img]) + self.emulator.login()