From patchwork Mon Aug 8 10:51:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 1664519 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=K7Wyz30Q; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M1Y1H0zqBz9s2R for ; Mon, 8 Aug 2022 20:52:03 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3B488841A4; Mon, 8 Aug 2022 12:51:55 +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="K7Wyz30Q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3C597841A4; Mon, 8 Aug 2022 12:51:54 +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-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80087.outbound.protection.outlook.com [40.107.8.87]) (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 2E6FD839F6 for ; Mon, 8 Aug 2022 12:51:51 +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=j5xPZdGvYXL2gIHp5IozYyGJ08y+YKtPaX5TObwCUNGYjFGpW73c4Umb4g2dj0D/1AK6PqXKmQTW5qWdbpSnZzqGoHhD521JPKqdbg1petcX9JrQy3NI7fzpZFKdPg5p/ddX6/TjfAu1ax+LoqTizV1w3ixiqVArM1OuC1DdSv13UoCL9e3fmibJLdwwoLjMEaKg7TbGzSP+4vFd1yOV3fyN+/HGAIOWQ2Urn5G6CoP11sIP6cq6safFcuj1iW5S3cBvAJjmld6/Ry39S2VWjFJRX8EkY7g0VtE78hrsjwykssRs0YDiLSHgO2JLbX5305Pcanm0/qMiR3XCWEz6/g== 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=qatMbbe9mHLRnvLb55B7BM+sL5uSYO+RcMUmsKZoLxE=; b=j9klkoWFEVTWil9Ur9so5wQsfx7X3ex7ZYsTBDlF+7UxdA5nyPYslxhuriY5Ba7cyuQfUhzRDw5r17WEfOWeGtnCGFpSjyA0s79tlgncnLZtryv4pUVhB3ohOQc26WOpZC+5Xb0JDTF6rNaTQy5Me0z5PCKZQ0KQH5YPFUlHyNjIH4daxUw+c4S2AZe41BXSAwxjilp/KJR1kRbkAXCRQY6+ifAFMf4jUUS5O/jnq2f8E5inqOeHvewHnk8ywRAShHU/gEs6p/CCR2pFJ7kFmaHJJOhs93bCHD4srqLauKP9h6vqKms1aNjkDkLG0GRjx+KEasDoMfdn1qGAj/LV3Q== 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=qatMbbe9mHLRnvLb55B7BM+sL5uSYO+RcMUmsKZoLxE=; b=K7Wyz30QN7jlwSsyPstpbUgv+B+157uTyZnjvN8tNiVdxyH9GfssHe7D3q+hkstOqVkOviCS5txwgZPLYLIMSNv0d1dKQWQt1cgTqmRh7e6J4MTomIndrJrYQbPBCkNAsuGegfPDC2eZrDyouk+xanZ0yrgW+sVllAteM/ZSeGo= 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 DB6PR0802MB2487.eurprd08.prod.outlook.com (2603:10a6:4:9e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.15; Mon, 8 Aug 2022 10:51:49 +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.5504.020; Mon, 8 Aug 2022 10:51:49 +0000 From: Stefan Herbrechtsmeier To: u-boot@lists.denx.de Cc: Stefan Herbrechtsmeier , Alper Nebi Yasak , Simon Glass Subject: [PATCH v2 01/10] binman: Skip elf tests if python elftools is not available Date: Mon, 8 Aug 2022 12:51:16 +0200 Message-Id: <20220808105125.21356-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 X-ClientProxiedBy: FR0P281CA0058.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::19) 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: 6a679801-c952-48ec-1bb8-08da792bfea1 X-MS-TrafficTypeDiagnostic: DB6PR0802MB2487:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DU5Ermk08w41sa1XBM+qO3v1C/35yjhXL5mkZEAKg0BFmLfFHzVY17wJbjX4QOXTEJLEQhrOILqfoglEdMb1auFJXnCYNtdEzk+cuzT3IRdpZ60jBZhNiRsudgE8q4MDucpCTxzrhv4wAoZH1TK1Py6H4j4/LKwUTlDU0MghsUpPv1CrKPPmYNnK8QACQW85sgZsWArPwIDzc04sBZw1li7W/4XO5MLbVNiBS/HcBNmbgcUUQJyvF9lvWbvvMJi2pIljnnAwUQgMalqigorYqrZ1dNG9tjKSl0clMdEQdElXRebhJVqI3VdeHQnorHpoT5gng7bXZj91avuW94yuO4a5BfSDW126zLym/pCjO5j68Sx4dHWqTNj5qyfMKrXQ9azNV6fL7++D8GofRM/LTDsxRkj2RNeWu6Tib5czoZdTdZCpMaWJVTLze14pSLo3+syPqhVlZsqUCm3+T6L5yZ/58gCnbbnY3/KWaee8Dv2Crb5T3+87GllvDodjrrnAq9CH3lIJ7gJfapvlFs1fjdIK+v5lmqhUI47fbRMKowTH6pU5adoisAVtxzzhlXeCT3k01FlCoIXWrbBb/n0t77T/XRqcV8Bdx2xHHhq8TDNP2bzIIozOD4PX+kyD6APo6rBeKEtuTVvgXsjr+HQn4sZQkd7POwSB8AkBnAArG5JtaduWJzTHVdkS3YOIbZzJx+Q7oS1rf0SToTOI16IRGTiPYOvDDfnySJ+ObBFW8gUjKMWtf+FmzDVCLFBYmF4dYjyv32YFFyKL74dUjCbO4I7m6/rxzMdR/ucHn8dAXKMEHi40gOWMigY/v8sFa6K/ 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)(376002)(346002)(136003)(366004)(39860400002)(396003)(6666004)(2906002)(6512007)(26005)(41300700001)(52116002)(6506007)(83380400001)(38100700002)(38350700002)(2616005)(186003)(1076003)(478600001)(36756003)(4326008)(8676002)(66476007)(66556008)(8936002)(86362001)(6486002)(66946007)(6916009)(316002)(54906003)(5660300002)(21314003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 44yZfCkS5bAuoO0VZnVQXxlLTxXips8vJz8yiTWdIJVYt75jSn4+7jl8Mv/dqkgrk33Hswymit4Dgm5ExCt9/q8/UTCFYr45myARokg4rYTyFoaDD+eqSQ7BxBcrUkq2KVFZA0FtMtGpzqeCjYaooLwiEK4yRO053XtLoq8+NPvrs1w4Vyr/4W8SbJZVq+Q1qJNaBjRnOZhxgLNx9jjI0yYJaiFDZKTYf/Sup81L4AXQ5sWZ08zw/7woLVii9FwEHeNPVmlNyf3IUW6amD0HWiIuNRsEOhdU45YWhnuY6NE5ReFI6Ra8LnRcQw0domY6lbgftJFwkTu+0S+/zWS4XHN79aNQYAPUwk+pvbiSc5EsIXGAK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igHHPKFDJxqa0tf9bUFj4Ut4n0nlma9DpVgYQ3oyRIz8/E3Qo9B7sP+zxFNb4SbJabvClKJoXRXwlJWClD1lXHJzxRNfnesMshu8JkniwVwow17uOn1KKZyd8RfjQxMFES0bMbQp5U5GMM+Fyyl8DeN/Mns8nFlO7WDixrH7R+0/xhLQ== X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6a679801-c952-48ec-1bb8-08da792bfea1 X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2022 10:51:49.0434 (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: u4gVj5divUmvk6/8o6bSRpG00D1WxP8hPqquRRp4gfFmqWjB4kF8Mw2T33BmvUt63ItQgr27YsrieU2CnThLKg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2487 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 --- Changes in v2: - Added 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,