From patchwork Tue Aug 16 06:41:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 1666682 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=85.214.62.61; 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=F2k1kjbe; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M6M5t0Xhsz1yft for ; Tue, 16 Aug 2022 16:42:40 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A78F2848D2; Tue, 16 Aug 2022 08:42:31 +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="F2k1kjbe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0B77A84228; Tue, 16 Aug 2022 08:42:30 +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 EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50057.outbound.protection.outlook.com [40.107.5.57]) (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 A5060841F4 for ; Tue, 16 Aug 2022 08:42:26 +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=OzvDa4iuLVpKtMOgvTqsxAaSatqLZl3v/10LrsFLgdVpBOcpW3Y1/V/PFqcS3g/E0843pHsLaPkj+XjcdOaELReq3CbWxYpjwE/IebM+7Nc6oJgqIsL3Z8O7p0P6OcMBwx9okpWCT3gUWq05miLw7zwqDXmVqUBIWVC9CzOvl1jG3YwM4QBsnSuUDESQSEBFCB8NOZa5cHFnA8Zr3A1NB/Qgcgp/WIo+B2uhW3axID3+gBl4vzf39qQJ7u4YgeobBwBDyklC0z1vT27k9xPjjhpU8t8/GKBWg0nY2ubh6J7HnaHswQaejHHzJwi1KMNmg85dL1KbYon9kVn82Zaa7A== 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=w+3uOVo2qqUJunkfu0BCNOoXns5+5awb6U7JSeaaE2o=; b=A8d/eMwFcOrVnvqGKdM5LXa03eJ9NNpb6engpoORn31LUEYVZRMpd4Y3+tn84pp82BMJYvFLZHhqXCjajqc6QHWM2YWdM27zweMVEyWfw23IL+aknCVVN0Sa1pVOLKvJVAk5kWw7VizmaAqAYjK9le5BTeVERT2J0WHCu5IZ5U1JJ65ZLfs64H7eM4Xzk8PA+FqTo2P/Bd/hcGR3jSEWeZv+6loyZ4YKDX072gjvQ11+aWCsCF0Pp+hzHhahYoHFO8eWFGTA+bMUQcIdE7lVIp8sZrdIRMzDgUGWaBhB+BHqbvXEV8dvQy0kf3zWpH90AR8C173UY0aM7BbtuoMlzQ== 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=w+3uOVo2qqUJunkfu0BCNOoXns5+5awb6U7JSeaaE2o=; b=F2k1kjbedBuS9IPluBdQuKb6KzUeMJMj9BknZIn9/LmXIE4Qhe/JaoLLzLaKHQS6YgG24brVMes0ZKSZsVEXhhogbCcow7cfDa0QThFK1xsKwkkAbK6Ky6lfTRh2nOIuPkHQ1ZDuFGYCCpMJaETpzrvG1IkDpyAdMptJ30UiAJM= 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 VE1PR08MB4685.eurprd08.prod.outlook.com (2603:10a6:802:ae::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.25; Tue, 16 Aug 2022 06:42:24 +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.5525.011; Tue, 16 Aug 2022 06:42:24 +0000 From: Stefan Herbrechtsmeier To: u-boot@lists.denx.de Cc: Stefan Herbrechtsmeier , Simon Glass , Alper Nebi Yasak Subject: [PATCH v3 01/13] binman: Skip elf tests if python elftools is not available Date: Tue, 16 Aug 2022 08:41:39 +0200 Message-Id: <20220816064151.9848-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 X-ClientProxiedBy: AS9PR06CA0744.eurprd06.prod.outlook.com (2603:10a6:20b:487::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: 94d365fa-0b21-4ccb-6734-08da7f527a2d X-MS-TrafficTypeDiagnostic: VE1PR08MB4685:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yDQoT+5GdYAXRsaBxiYIll6a/GsszSBbKNvNv1lEvNH/OO4q/GNSB65liGceR0fbKr0oeBSdro90Bt8v1vakyHNPEn1je7lEKRYLyoHTbXMJ0jvasTGUrLKvcn4LIdwk1Xml08KJ6l4NHZBKCfPB0Qnx23rHEOqNwOqi0+jdk/ibmO3QHUAs6z5sSBgV3ESHVnrk5o3+muWCDj3cIZ9RQBg8vBt1MfKyz5/CgQ9nZuEs8g1dEpY8YqXpE/9yEcxxiOkzjiT8sFslaMh7RX7GHIhN1KwYbirA7Os9hiotcpDGoMUKHcCe2VY5Ku8kDHQoOKwDduSHmrtcIroAPsQ0uL78Ggku3PQB2UBphtOOzd/3J8m7TmujsZjTmJDcbZ+O55l79JHhuNKVddqWc9pKZzObNYGAGIsymg+wvdru1paRXmUlJq95o6tXdjCiIAXvBpIi93BPSvTkG7czcZtf40/Anqyl4mR2ElYTCZiBp9XcuEH//Ef5BOMHIJbtrKC1/tn+3hIL+Lg3zLNMh/wdYwVxvm1kG5z06aDfhqJt4K2tNbuZVu+UP9gZP5HN6iAFW/6VJwsHR5WXq/swod3ZGlGnri4MEjLeeaM3Em7YKI/qJu31rg8GQ6ceBXEq98y6XbL6Dyqxz3fXzQ0dqUY/vJqtIBkZ/yHJ052d8LuoPE6WV+Xh3WFWmvPXBiRpT75DbTKe7JodZdo7uP0cnYIb589TutOv8HVl+z2Von0tjTdq457rbu6OHCW0xZ+kzeShSBfaCJBz5f6KQo5T+SnteAt048JeLycXic1JSxcXyg3sYsThPGnYUi00u6is77gc 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)(136003)(366004)(396003)(346002)(376002)(39860400002)(86362001)(38350700002)(38100700002)(36756003)(316002)(8936002)(41300700001)(4326008)(66946007)(5660300002)(1076003)(66476007)(478600001)(8676002)(66556008)(6486002)(6512007)(26005)(52116002)(83380400001)(6506007)(2906002)(6666004)(186003)(2616005)(6916009)(54906003)(21314003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BTfjASLQl9fRmrtsR84lfTV8Xbq9bQj2068/KwUeD6NhMRD1aYRBjlYxuRbZTgOJnsrmCR5LjUsPLSEO2EoYLCXpFLx+qjtO9SI0FkPzL/utGD3m4Cobj+a8UwhbuhCRbZAwb8mFqJYdY8Lops/BxIz6m/uyT4JAyiVTD1tlq144Hzpx3AfC/G5jV+bnsZddCFuhOsIJwlV9B2akF5wzPRMTnkixq8SEZefIo5p9dUEhTWyZYBJ7HaNMwgmYiCxkBbfa46aZLo5LK5kMvcLBrx3ZZjX6uWJpbILrs1GQknbxBZNk/LmIbHTQICA0iC6Mg+4/x3kOdirXsswZ56NNXD1RThV4wQp1PtvQ+YDoC98rbCkn6Ns6texgdgLdtFR7I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shXSusYhEqFNPDl9yrqEIyoTytLykEmEl8MN66bQpCSQoyL2nD/eRn+5UwEv7xMRkHMBlyQ/Fz6WuGAKpAmPr5ATAgWL31bFywgs1lO/Mb3tvWrXy/PDvGs8YKGBWVojF0qZrraDYnWF2zqtcxn50/IE+w== X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94d365fa-0b21-4ccb-6734-08da7f527a2d X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 06:42:24.1606 (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: 7Y0DB4mjeOtzl6H9IJUDjMKokKo0VFhYlvoTg2TN3Q+PoLhdfnHvshpqkKB2N0sX64nv8p1yiUl1FGbCxJpe9g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4685 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: - 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,