From patchwork Fri Aug 19 14:25:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 1668171 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=f46fICkt; 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 4M8PJ36V2Vz1yg7 for ; Sat, 20 Aug 2022 00:28:35 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C3DA384BF3; Fri, 19 Aug 2022 16:26:43 +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="f46fICkt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A73F584BC1; Fri, 19 Aug 2022 16:26:15 +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-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150088.outbound.protection.outlook.com [40.107.15.88]) (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 8FD1A84B89 for ; Fri, 19 Aug 2022 16:26:03 +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=ilIY3+a+cP2SOYqNmJGpY7APvZuk0jFRJ5RkchhIOVbh1jKYNcTrRiJxWyjANo916EdXsyIWV2KlkcLVxC7eR22nYkXyBp6Tvu2FzIPn8VBsGFsxthwYXxaxC6Am+8GTCX4uRrhqOfuUYBwx8vwcQDF7M5OM3Olc9JeeazGKWn3jL5/bx7UmazsguVCjZdCMqcER4EZnvK6qgznOEJ8fqwQlaz5gXeog+8VoN6Q19gdBH84TbY4c14rY1uOf2Xwimd0Qka3xlw6PFZGVJLxqTHqhndjK0eX2Czjv0RyI6NAtmqlti3QG7PA2T/2PgIeifjcln0IWhByUQ/2jN9uobQ== 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=XkvaW8VoCEo0wsjXrjeYFxpkcDVrYf+oxgtC84Pc1rI=; b=AwKro2I4GvOoEc6Xor2h/uK3QLTMlc0nniqjOHaE/lP7pbpQyVjdGMMd8o3KiFcTxXfYrzuXqb62dYKvkqdxNpmD9ZpEmvirOuG6o+ciTEDcpvW92KpuFyhKCmYmDr3ZhrWw6RIj/q034WcWgfOxsTQX7yq1oSyh2zgWc8g9f1crxRCH9jNaXoflCQsIZ3WUjuuWxJknD+m8upb1HN3EAOl4hqWqrDcQHLkffxHT2etEAM3DVMDMNk4iglsrOlvJ12/eWsGWzPX3VsGMv2wMAdNIhblpN+mjMWCpQCtQh7vugKSXh+FBESOSWzIbNVKay8RocgoinjyJnu10gPhbwg== 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=XkvaW8VoCEo0wsjXrjeYFxpkcDVrYf+oxgtC84Pc1rI=; b=f46fICkthkImA9PwY7e4eoWBWUu7bQKiD0YuH0lSdEEQme4MUipJWD34Ky/ZYdIAJQ3JWVO2pphlQBDX585+iiQ5Y+vYVQ2MGBTgW1YwEBeFPUwlkUPPd5+C0s4K3LCoyOHpQTP5h3Yv6qYyU+oAZ0HvO2SbBxDvGysWiMgZj7I= 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 PR3PR08MB5739.eurprd08.prod.outlook.com (2603:10a6:102:8e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.18; Fri, 19 Aug 2022 14:26:02 +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:26:02 +0000 From: Stefan Herbrechtsmeier To: u-boot@lists.denx.de Cc: Stefan Herbrechtsmeier , Alper Nebi Yasak , Simon Glass Subject: [PATCH v6 11/21] binman: Move compression bintools creation into test setup Date: Fri, 19 Aug 2022 16:25:28 +0200 Message-Id: <20220819142538.24847-12-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: 897a9422-74a7-45ad-1205-08da81eebe3a X-MS-TrafficTypeDiagnostic: PR3PR08MB5739:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6dMpw5dLv6E6vS7BtS/Wxb4QdsXcjWbtOfHN90b4trT6o1XEd+sfqDkcw4Q/Kbcf9vSWVVDr68eaZ65mdaUyXb5NEMpONrP/gBlFJOfoQSAnQE8xfuzzA0sVY6+c+m2Lj5/mIZdXsR1KkJS/+8q1bw1i/lWK8aVYVns2zsw72MleiFOuRJGBk9RXfNhrM9c06v+99m/pIW/tpHMGEjTwqPJZwVzUuF9AgOpKhb26QEMkMySC4c6b22Fdp6l6H2dIAQKwo9KyO1LskiVP6woSkVvLZyOHRdE4KiceMiYw4r6Cdg0xgogXpeRWs/q8D2/KbmL0USDpQFE1T9nqSh8Y1UVkT+9NnMTVLwAUwprkCdNz58I7resqsTlwJtBSDTXMSmgKoYpLGOr9poS6+ps1In3lTo8Ngdg3DuEKZNK9Rdz6rKVj+HwukRxXFaCGnL1hBeHhaz7aKVs3a2Kupol3MFDpFYA7DqIc9h1m6A3bkSyKIWrqa+IXl3gFh0usFTjoTxFuaLpsg2ApJ4KNalzq9OTrs/0cYMp4+UT1jjk5AiVqTtSvF9Z6nTaJrz2XDGJrEtfJcmYAgMEvVymNNi29qRHXY/jMpLGVia/25/Em9KWFUB5xTOdFUkdlrZPFR491QQe4Ove85RH07hLnK+scJeIexSaYDYFrmh3tNNV0BSVEv1bKrjRbddhtK8+ud4P+0UpTagce7rB2Ubt4rcUvPgBRu5gEL2S4p8xgBRrMpdqMLDXY/PhtUWoDynOcqTyvw6UbB5OGcahDGlg9iKzUTQ== 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)(396003)(366004)(376002)(136003)(346002)(39860400002)(4326008)(8676002)(66476007)(66946007)(66556008)(54906003)(316002)(6916009)(36756003)(5660300002)(8936002)(2906002)(478600001)(6486002)(41300700001)(6506007)(6666004)(6512007)(26005)(52116002)(2616005)(86362001)(1076003)(38350700002)(38100700002)(83380400001)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NJghZPhE3uepc/CQPp7lRSLuP27AeEfsqe8UYb9zqptP66t2zjGXEXCOqi9TTIwD/8NppMZ4IvdFHQ8cmxA6/s3y/gDt88KYorzhg8S962i3DGm8k0uCNlvNguVvqgssgDvUIWBV+qx40LGzwLg5m2NzwliIYptSLKB0VwLLwGiLFU19Aa1J5zoLOKfLTvGy7ezNU8hzvaEcAjlAY6VPE4Dm1ebMq9Gb2tmFqz2aZOJEsggzyiI+s0KjxpT30fHx0BzRduqBB0pa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8EnS/Z3esnkBvN7INYcmJrGHuyGZx6VMjXfwOQOzEPsx7DdxSTALxxXbiDkRsZ42nc97Dx9WJiJ66fvgSGGZDK5FXt7gpsKICCH6hNhvFOhaJr4ECfi3gNHPNOJgmz8cuZUO383NmGWWz+4yPW00CUxeCsvdcbJjzbx4D7FrdPhYg5dC7ntRJNXD2RJVy+NRka4uRq0nv//fqz8EwuhRj2Ceg1CklKL2+v7oe3+Mjr9eO+lps7kddln1jNBudzO+TarQOJiI5lvz2RxbDTm0YIvEqE4J8lO6Q== X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: 897a9422-74a7-45ad-1205-08da81eebe3a 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:26:02.0960 (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: uKkQwAkBKiqIdg0ieG3dpVAjjQEtT0kH2orwswklgMkL8aQHOUPNvSJ1xqlRaWMFmDuAE3Mfbiz3e2Av+8gQzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5739 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 Move compression bintools (packer) creation into test setup to reuse bintool objects between tests. Signed-off-by: Stefan Herbrechtsmeier Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- (no changes since v5) Changes in v5: - Add commit to move compression bintools creation into test setup tools/binman/ftest.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 1538ca3c4e..7ab9289a88 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -23,7 +23,6 @@ import urllib.error from binman import bintool from binman import cbfs_util from binman import cmdline -from binman import comp_util from binman import control from binman import elf from binman import elf_test @@ -107,6 +106,8 @@ BASE_DTB_PROPS = ['offset', 'size', 'image-pos'] # Extra properties expected to be in the device tree when allow-repack is used REPACK_DTB_PROPS = ['orig-offset', 'orig-size'] +# Supported compression bintools +COMP_BINTOOLS = ['lz4', 'lzma_alone'] class TestFunctional(unittest.TestCase): """Functional tests for binman @@ -212,7 +213,9 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('tee.elf', tools.read_file(cls.ElfTestFile('elf_sections'))) - cls.have_lz4 = comp_util.HAVE_LZ4 + cls.comp_bintools = {} + for name in COMP_BINTOOLS: + cls.comp_bintools[name] = bintool.Bintool.create(name) @classmethod def tearDownClass(cls): @@ -242,9 +245,13 @@ class TestFunctional(unittest.TestCase): cls.toolpath = toolpath cls.verbosity = verbosity + def _CheckBintool(self, bintool): + if not bintool.is_present(): + self.skipTest('%s not available' % bintool.name) + def _CheckLz4(self): - if not self.have_lz4: - self.skipTest('lz4 --no-frame-crc not available') + bintool = self.comp_bintools['lz4'] + self._CheckBintool(bintool) def _CleanupOutputDir(self): """Remove the temporary output directory""" @@ -1967,7 +1974,8 @@ class TestFunctional(unittest.TestCase): self._ResetDtbs() def _decompress(self, data): - return comp_util.decompress(data, 'lz4') + bintool = self.comp_bintools['lz4'] + return bintool.decompress(data) def testCompress(self): """Test compression of blobs""" @@ -2855,8 +2863,10 @@ class TestFunctional(unittest.TestCase): def testExtractCbfsRaw(self): """Test extracting CBFS compressed data without decompressing it""" + bintool = self.comp_bintools['lzma_alone'] + self._CheckBintool(bintool) data = self._RunExtractCmd('section/cbfs/u-boot-dtb', decomp=False) - dtb = comp_util.decompress(data, 'lzma') + dtb = bintool.decompress(data) self.assertEqual(EXTRACT_DTB_SIZE, len(dtb)) def testExtractBadEntry(self): @@ -4427,14 +4437,15 @@ class TestFunctional(unittest.TestCase): rest = base[len(U_BOOT_DATA):] # Check compressed data - expect1 = comp_util.compress(COMPRESS_DATA + U_BOOT_DATA, 'lz4') + bintool = self.comp_bintools['lz4'] + expect1 = bintool.compress(COMPRESS_DATA + U_BOOT_DATA) data1 = rest[:len(expect1)] section1 = self._decompress(data1) self.assertEquals(expect1, data1) self.assertEquals(COMPRESS_DATA + U_BOOT_DATA, section1) rest1 = rest[len(expect1):] - expect2 = comp_util.compress(COMPRESS_DATA + COMPRESS_DATA, 'lz4') + expect2 = bintool.compress(COMPRESS_DATA + COMPRESS_DATA) data2 = rest1[:len(expect2)] section2 = self._decompress(data2) self.assertEquals(expect2, data2)