From patchwork Fri Aug 19 14:00:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 1668115 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=weidmueller.onmicrosoft.com header.i=@weidmueller.onmicrosoft.com header.a=rsa-sha256 header.s=selector1-weidmueller-onmicrosoft-com header.b=hx6kKr+v; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M8Nhr232Nz1ygd for ; Sat, 20 Aug 2022 00:01:32 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A7B0F84B79; Fri, 19 Aug 2022 16:01:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=weidmueller.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=weidmueller.onmicrosoft.com header.i=@weidmueller.onmicrosoft.com header.b="hx6kKr+v"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AD13A84AA4; Fri, 19 Aug 2022 16:01:02 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70071.outbound.protection.outlook.com [40.107.7.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 005D684AA4 for ; Fri, 19 Aug 2022 16:00:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=weidmueller.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=stefan.herbrechtsmeier-oss@weidmueller.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oKKw6dTfO2xRZjk9hl0Q4MK/WX7TLf8xbOj3rATLLKJlInVP6J6L4tNNTgA/aMdE0Tau4YwCeXV+hbnxPbbJcGDedl3F5xsIPBhq8tAd0fC7xdZxfzz7kc03Csc8w7ygUyuYuvTmG21FNgk3byN6ur86KKt/pULoi9aBwd19DtuTKA+EcSPVI1mjrbWGOVL3yD0Qco0zakoP3xher5ddW6df/BcGqzLw0irnvfG5ORufnc6pQBNEMiAvGz7ODABitrHR+3Dyx7mVXlznonZfcAOoDm6zlHfIh7sSqDqXJTHT7dgHoZYmuI/Ew3A8l6+41OzuSt6NRk1Omy1cJ9svJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c3pHTbqiSrrXubSb4Bj8JmnJdG0xquJv3R7gL88cO0s=; b=A5CUN8fnziqqr9rBHMup5HzIi8ru/1IWXi7HaaZVMkZBpHQuTd/oHZLEudiPQJt2ogpCSelyD/qGjfITxrJT3cjRlcWMbLKRqN0zev15kXsQc5Ay98nDdq2/U437HEIiqaDkmQYF6MNn1i3jRpm8iYpDsp5k6jsDWQXkauLd/f36Q6dsnN2rDk/An1BYG0uQcQSL0rp0Dh80q49LnrCAajqdgQm81Zw+iPefg8d/RuPCYc+1e3NMhnsC8uSpLPEGYsfX/Y/jP70Jt18vCKxY9Uaa2x9i6L9/tRZsL6q5FSCnom5IvzMO7l+/MuBlZ4N6MbuA+UJgcYK9GhWHVsoS2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=weidmueller.com; dmarc=pass action=none header.from=weidmueller.com; dkim=pass header.d=weidmueller.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weidmueller.onmicrosoft.com; s=selector1-weidmueller-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c3pHTbqiSrrXubSb4Bj8JmnJdG0xquJv3R7gL88cO0s=; b=hx6kKr+vd9UQz3j12pw6DVuOc3Ut9uqcA+0kRUVRPbZeJ2YpN+1h0GldgiwlYUSS7WfUiWzNAaN6Ku6bITTZVsptbEHap5kFiXsFkXdc7SoykEb1pTSJFxD2h7J+8eQO9UCBrIDNdmNNpnr0lnW9R1Dpw0OxsYFbJYu66J4pOVg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=weidmueller.com; Received: from PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) by VI1PR0802MB2302.eurprd08.prod.outlook.com (2603:10a6:800:9e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Fri, 19 Aug 2022 14:00:54 +0000 Received: from PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f95b:2e64:9ee6:4d44]) by PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f95b:2e64:9ee6:4d44%3]) with mapi id 15.20.5546.018; Fri, 19 Aug 2022 14:00:54 +0000 From: Stefan Herbrechtsmeier To: u-boot@lists.denx.de Cc: Stefan Herbrechtsmeier , Simon Glass , Alper Nebi Yasak Subject: [PATCH v5 01/21] binman: Skip elf tests if python elftools is not available Date: Fri, 19 Aug 2022 16:00:15 +0200 Message-Id: <20220819140035.32760-2-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220819140035.32760-1-stefan.herbrechtsmeier-oss@weidmueller.com> References: <20220819140035.32760-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-ClientProxiedBy: AS4P251CA0011.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:5d2::7) To PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d0339c83-a28e-4c33-2b67-08da81eb3b4c X-MS-TrafficTypeDiagnostic: VI1PR0802MB2302:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HsoUqDfSM9WFVfILa7K1UudQzU0UXaEqOgUpCe9ELa0PIYkNZskwDrbWf/IPlfs69AjugxUiOJssTv2eDEMH5Z1u6Q/0p8vpoMZGV/NZD/SjR/vk5fYIs7EecOzKuGdxSe4G3d31lhlK8WCI7OzUcEtCwsYV//tY7qIWeAu7U0X/da/vYTvmihf20htwL4FHZgK3jjqSrEPoNQTvyCfY7pyI4enokvIw74xVeIPWSJ2mAec5yJSFTorXmGYoi5od/f0Unll1l+28feGzdR69VjkwsW0pO3fbSEYc5vEpgPPtveqTZllm/UNPeswJbJCwEtYGtCQBTXkWI+UUoqgJlMk8AN8Ps58Oc/AFdflM3Ds52aqup8Hlr/HYCJ3NFTQYl6ExKoCQrVXY8t1eC12sJl2IYWKOS4/cVKN5XO/mD87xPSsMuKZ9OxfsBKoaG5/2A/58+Ush8/6ph7d0Us748jc7SFEcmRWqjq7rVu3NhEXUK0pNYQsF4xi357UhKqvowkZ9UM+b4Jcu7Pdzt6S4yuEDW9euL8E7U2ZWQ0H4V3zRS+XWv0qrkdyADxJa0ER55b6FKnyjOJNwYr5ZtRzlH9sJGqrDqqiLlQQjvRQV+fjslMfv7LqZE4aBx/c4hSd2+D6CeXpgzr/9y/ustfDf3X9Z9etPhW0YqTPgQHOarrr7Tg7M59O+CcUjgc5PYKk5vboh4UIN9JHATMgOWn4PVcsVdMipmRw8JoYQ+Rim+xDZLQD23rKaJrzR1vdac8LBmc9U4XQT428VNuEJT9tKDp9Br00qaFUuyiWTu+Fd/hc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR08MB6969.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(346002)(39860400002)(376002)(396003)(136003)(366004)(6486002)(6666004)(2616005)(478600001)(316002)(2906002)(54906003)(6916009)(36756003)(41300700001)(86362001)(1076003)(186003)(38350700002)(83380400001)(38100700002)(26005)(52116002)(6512007)(6506007)(4326008)(5660300002)(66946007)(66476007)(8676002)(8936002)(66556008)(21314003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EZHyqqk352lq7gTcxRLIvYP+o+8EiJs/zcnsD1s4x8ZVT78J9n8oYNLXmbKaphq/6/URJNIjIFkIaarsN1sDIUnaPl7Zw5NeI3euPof00/qu7hJIQeE9TWe7jtKCl4ISmNRzdbQ/IUzTUmQ5krZJ6hDgEATOakWhGkbZSL0x1lfo+4PXIgeugjc4LM2og8DNDsZ84M9SHiz4ewMM7/kzcCruek3B14NnReagEfTxTvYgeaw0DhWi1nTPECmQ2iY8U6OetA9sBnN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0XSHKV4rchMhWkqYj3r3bQiL0/DzRWVZJ7RwFyk4vmKw9JEpiXC9x0ynZgDLkCxC5w8kveNQtzvXYqHi844jXwbtav+OU8y/btk1MZYiLiJ24Q918qdcOrvswJs2iOtpSxU8mR2uSBDEw1dg0Ymo2alHT6o2zUdE7C1pRNInPLxvgorrnxyOzxMLXshP/eU5yCy3zx4mBL0iZJE9W7jJwld071BIlztrzLL6bI/0Yz2f3Y70BQzSL8MgMLKc7p4sATFyNSgVA== X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0339c83-a28e-4c33-2b67-08da81eb3b4c X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2022 14:00:53.9585 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e4289438-1c5f-4c95-a51a-ee553b8b18ec X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7JLXRSsuj3KAhDmLX9jEoD5V+4cUwo1u/fdoj9G2txB8MPxK6qq0r2ekB+KMkVWNyAnA3EOCQLnxs8PB13RvOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2302 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean From: Stefan Herbrechtsmeier Skip tests which requires python elftools if the tool is not available. Signed-off-by: Stefan Herbrechtsmeier Reviewed-by: Simon Glass --- (no changes since v2) Changes in v2: - Add commit to skip elf tests tools/binman/elf_test.py | 14 ++++++++++++++ tools/binman/ftest.py | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py index 5a51c64cfe..75b867c2be 100644 --- a/tools/binman/elf_test.py +++ b/tools/binman/elf_test.py @@ -122,6 +122,8 @@ class TestElf(unittest.TestCase): def testOutsideFile(self): """Test a symbol which extends outside the entry area is detected""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') entry = FakeEntry(10) section = FakeSection() elf_fname = self.ElfTestFile('u_boot_binman_syms') @@ -147,6 +149,8 @@ class TestElf(unittest.TestCase): Only 32 and 64 bits are supported, since we need to store an offset into the image. """ + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') entry = FakeEntry(10) section = FakeSection() elf_fname =self.ElfTestFile('u_boot_binman_syms_size') @@ -161,6 +165,8 @@ class TestElf(unittest.TestCase): This should produce -1 values for all thress symbols, taking up the first 16 bytes of the image. """ + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') entry = FakeEntry(28) section = FakeSection(sym_value=None) elf_fname = self.ElfTestFile('u_boot_binman_syms') @@ -172,6 +178,8 @@ class TestElf(unittest.TestCase): def testDebug(self): """Check that enabling debug in the elf module produced debug output""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') try: tout.init(tout.DEBUG) entry = FakeEntry(24) @@ -281,6 +289,8 @@ class TestElf(unittest.TestCase): def test_read_segments_bad_data(self): """Test for read_loadable_segments() with an invalid ELF file""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') fname = self.ElfTestFile('embed_data') with self.assertRaises(ValueError) as e: elf.read_loadable_segments(tools.get_bytes(100, 100)) @@ -288,6 +298,8 @@ class TestElf(unittest.TestCase): def test_get_file_offset(self): """Test GetFileOffset() gives the correct file offset for a symbol""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') fname = self.ElfTestFile('embed_data') syms = elf.GetSymbols(fname, ['embed']) addr = syms['embed'].address @@ -314,6 +326,8 @@ class TestElf(unittest.TestCase): def test_get_symbol_from_address(self): """Test GetSymbolFromAddress()""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') fname = self.ElfTestFile('elf_sections') sym_name = 'calculate' syms = elf.GetSymbols(fname, [sym_name]) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index fa1f421c05..da9aa9e679 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -4807,6 +4807,8 @@ class TestFunctional(unittest.TestCase): def testUpdateFdtInElf(self): """Test that we can update the devicetree in an ELF file""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') infile = elf_fname = self.ElfTestFile('u_boot_binman_embed') outfile = os.path.join(self._indir, 'u-boot.out') begin_sym = 'dtb_embed_begin' @@ -4858,6 +4860,8 @@ class TestFunctional(unittest.TestCase): def testUpdateFdtInElfNoSyms(self): """Test that missing symbols are detected with --update-fdt-in-elf""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') infile = elf_fname = self.ElfTestFile('u_boot_binman_embed') outfile = '' begin_sym = 'wrong_begin' @@ -4871,6 +4875,8 @@ class TestFunctional(unittest.TestCase): def testUpdateFdtInElfTooSmall(self): """Test that an over-large dtb is detected with --update-fdt-in-elf""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') infile = elf_fname = self.ElfTestFile('u_boot_binman_embed_sm') outfile = os.path.join(self._indir, 'u-boot.out') begin_sym = 'dtb_embed_begin' @@ -5344,6 +5350,8 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testFitSplitElf(self): """Test an image with an FIT with an split-elf operation""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') entry_args = { 'of-list': 'test-fdt1 test-fdt2', 'default-dt': 'test-fdt2', @@ -5421,6 +5429,8 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testFitSplitElfBadElf(self): """Test a FIT split-elf operation with an invalid ELF file""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') TestFunctional._MakeInputFile('bad.elf', tools.get_bytes(100, 100)) entry_args = { 'of-list': 'test-fdt1 test-fdt2', @@ -5440,6 +5450,8 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testFitSplitElfBadDirective(self): """Test a FIT split-elf invalid fit,xxx directive in an image node""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') err = self._check_bad_fit('227_fit_bad_dir.dts') self.assertIn( "Node '/binman/fit': subnode 'images/@atf-SEQ': Unknown directive 'fit,something'", @@ -5447,6 +5459,8 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testFitSplitElfBadDirectiveConfig(self): """Test a FIT split-elf with invalid fit,xxx directive in config""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') err = self._check_bad_fit('228_fit_bad_dir_config.dts') self.assertEqual( "Node '/binman/fit': subnode 'configurations/@config-SEQ': Unknown directive 'fit,config'", @@ -5470,6 +5484,8 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testFitSplitElfMissing(self): """Test an split-elf FIT with a missing ELF file""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') err = self.checkFitSplitElf(allow_missing=True) self.assertRegex( err, @@ -5477,6 +5493,8 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testFitSplitElfFaked(self): """Test an split-elf FIT with faked ELF file""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') err = self.checkFitSplitElf(allow_missing=True, allow_fake_blobs=True) self.assertRegex( err,