From patchwork Fri Aug 19 14:25:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 1668164 X-Patchwork-Delegate: sjg@chromium.org 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=ag6nheUH; 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 4M8PGj4Dx9z1yg7 for ; Sat, 20 Aug 2022 00:27:25 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1E66184B5D; Fri, 19 Aug 2022 16:26:28 +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="ag6nheUH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6AC3484BB5; Fri, 19 Aug 2022 16:26:09 +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 EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130079.outbound.protection.outlook.com [40.107.13.79]) (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 4276784B7E for ; Fri, 19 Aug 2022 16:26:01 +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=aMM9q3oQ+zTl3KHBrld9r6W1bSmwt0RA+IkxMlNkgItLLRM5cxpmJnaZaj9rZn5Hc0UBbQN3vi7bdn383GNniEMjw6mbQo/u3rERXztCZu8JLBFU71w2AyFpzWQ6R4z+Pa6R+jBDuonGXIZIunQECbAVSQiyE0dv/P1z++rMT+xpRmC8Yoth6Evh+XxqxUqZaOUJD7OE50BbOVdnF1Dht+bXHYzk7dOhoFwZ6zHmg1HuTqiSvdXVr2zL6LH2pKkwu90oIQg3GPsIWVbt5ypf/KzBPbT+HVJ1KLYbEx3KXJWsFpYzaHCPNu3N2cPo4bkcStZc4n9G1kifVJsl8S1bCw== 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=QBF/Wio0YxAZHJO6GV8R+E/0qTHIi1sAC3tFKOmr8uvNl8ZULzDKCAEPQ9jvHXRFEnZ5Iaq6RHPsOU1ELo9Zr1BGDr3G+BogvFbpFv7p3kGelDn6lobeXpuBMPlOSDLuey86YsCmmZ/M3oQcGAFXvKHDIX2UaaKGd458chNY+gfmQMw0TRxoEsMmrJjrs7+d1B89lcC+ku+6OSrQyBG+omTWHvyaVFqvmM4PKhPIzWG9jv1HWPIeJySoa30iVH9MWG/OdIVO/EuP/plsd5bs3W8E6v8i0zcIuClrhWndNvWIQT7vDXZVWxdUEq9FUae2cV3KZ0jkGPYqnDogKh2VPQ== 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=ag6nheUHrN/afiwXcIjMjxRtVVz22dVijPlhqjBvmavNpmjD69joi4t7ATgI0orASCRDZjCNu8gsyE3tdOmqyxbbEjzyl0W2C897Aq4q8UbfV4ge7Q17phMzgkHj9Bd5yFL9eT+DQ248PpTp3jMP1AJgnK5BlOtoncjHoNh1n7g= 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 AS8PR08MB6855.eurprd08.prod.outlook.com (2603:10a6:20b:398::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.15; Fri, 19 Aug 2022 14:25:57 +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:25:57 +0000 From: Stefan Herbrechtsmeier To: u-boot@lists.denx.de Cc: Stefan Herbrechtsmeier , Simon Glass , Alper Nebi Yasak Subject: [PATCH v6 01/21] binman: Skip elf tests if python elftools is not available Date: Fri, 19 Aug 2022 16:25:18 +0200 Message-Id: <20220819142538.24847-2-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220819142538.24847-1-stefan.herbrechtsmeier-oss@weidmueller.com> References: <20220819142538.24847-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-ClientProxiedBy: AS4PR10CA0015.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5dc::11) 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: 2d9f6160-fca9-4765-9179-08da81eebb8d X-MS-TrafficTypeDiagnostic: AS8PR08MB6855:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CWdsDcX6DncobmjAHZoMd90cGk/b7YrPs6Sc0RKegVGeoznVdhnIbdhfZxJezW4bZPxWpOJlA2Kq3juDud41mVV0iWhWxXULyvwbgCO6SJUGG2GL97SuS6JARMG+e6YBgqUqe8dUELd2FTwbepkUggRb2cyi6gKa9sg/maUumB5ibDUgorB7AZ45nYpMgy/Rbkla46YO8wcgWAQhgWeHdfbKDb4lbOD8A4KhSeQTrGhXYqY15gJNNfjf6Eey9KiNsX6tfVZEVU/Rta4IAhn0FGhOxinq+xGP0b4VmZNTYUAOEOKRc2xqP61v9LZKlIqqIZRifmZtLdDfdHiFhKC9/V8hHm0Mk25pQ4dWP/CiPShfURjiqRLj02sWcc1g3DoqfQlL7goL/ifqywwhr4krhJTh4iR1FFFRVCjD9yuhnpejyFNGSMndZAi0Evx0R1wIkf371bz+MeajsEMMYlfBIu7lAzQzU23w7rdU9ALlcl3ToRSjq17Y+YI1kWYSkL4rD9oi5VaB0TDw+FEzUXmFDUoFpnJJZyv8WA+qCoZeIhu8cBIH9GUoCDAGHMPz8UpvpSW1LZmVI7r68fTENHgXIP4Bs+/6l45YeitxyFmxC6T6mT8Rr1imFE29olH3c/jSQyEsePn0fO/b+ue4vXP94NqK+DT4PMqDYYsS+khInpyJ3R9kZQLEYd0eqpZpgQlmyu1yZTO1tAxXJ15qpv8LL6VVQ8oS7ssVgEC2ld6xKgvkDTrKYM/m0swFegxBtbCX1wl32J8eBOoIzy9OPEcTdHOJeTk+fuPAsUkWrl0Lhhs= 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)(366004)(396003)(376002)(39860400002)(136003)(346002)(6512007)(6506007)(52116002)(2616005)(2906002)(8936002)(5660300002)(6666004)(478600001)(41300700001)(26005)(186003)(38350700002)(1076003)(38100700002)(54906003)(86362001)(83380400001)(6916009)(36756003)(4326008)(8676002)(66946007)(66476007)(66556008)(6486002)(316002)(21314003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RpuY9spSBNLtCJwHaP9P+6gLJY7cOV9/zLXc9lZviZjsFpOVgW+NO8eQItSJoZlM4xBg95Kxj9co66EBYJFAz5j97rXTaYFPpGalRY/yjW5V3Ft4Tc/ah2fzrTpy1OiRZyNPqk6xVBcgdP7jqtPTWKVhjAN7s/YTdo6Sc323ylThAiqDbBKwtwSCtgYqoQ3J5KY/XA+SiFz6QTW2oLiaKPFghoFcNFTfM7Lo3g156P3CTulBflSqD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+lHbf41FS+1K6e+fs5ZMlAoPLeuPE7t+hrBY3txA1gA/uyVqDz+7bDcLvcDW/HU9NPTZEhKtZPlCZD7fTIQcAjovJ0xCu+Jk/zBx7B42VFU5U2k+0nZu3Ac3WexZwY8EK9yUrhJ7A47YoJ64H/L+m4Iu6vvNdoplvZb0pIUWVp/L5Ob4S4UPxr7Sw987ObzxkR9P+mYbx8FKK0VI+tXCaIFnHMRrBqXgmERZdANg9bJENknREPAHRAtTUf+x7ujfm22y3H4CJp6+uzekfcX+ddr2ZmLBX/GT+QQdHw== X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d9f6160-fca9-4765-9179-08da81eebb8d 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:25:57.6257 (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: Em3KHSHPM62C7jdCU9A9nY/IHkTyiE68azLZB6RlZ2ElUqbNIbZCXWFUul4ZaP3/2NGQA5rpmGldcFJIdBJZ8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6855 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 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,