From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9108CC433EF for ; Mon, 10 Jan 2022 03:21:22 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 19390834C4; Mon, 10 Jan 2022 04:17:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="OVVBH2iD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1C5BE8197D; Mon, 10 Jan 2022 04:15:59 +0100 (CET) Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E54F883102 for ; Mon, 10 Jan 2022 04:15:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd33.google.com with SMTP id y70so15796288iof.2 for ; Sun, 09 Jan 2022 19:15:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PtyfEfyWM4FR01Sh0bCv3jJd+716AnLDSYjvONQRWc8=; b=OVVBH2iDNDpAuQ2y2NHFcusALPpkt6GTsfUk6snBRlIa5QBMP850hu65KUAV4yUrOf Xs0yAdfJG5xm5ktHTJLwEVtas4NiIuXtexU719E1ehXED17hX9U7kNKXnAzTiNm4pJll yl2b1PzzmAGmaPmHyk3FartEkIg5jugEmLSCM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PtyfEfyWM4FR01Sh0bCv3jJd+716AnLDSYjvONQRWc8=; b=K/pqxRKJUmltyWM2FJLkz+oB/YOYeGz7SBuzym3/LTU/47pO/Y366a+5AM56v8FeBb +eJTdNmkE6zfJr2MvH2ao70ppDe6qVegDEjXGmsbIDAc00FGLahlNNCfRsSkJCOdM32Y TXci14s2ebLpg08LEZRbn9AqGVBS5mY9AKJ17MTQxUF7LIduX8ojRz7M9b4bVUDfQK7R eK6SaNGPrAtxtbrlI5OiSAIwPkXKYpIBP1VxBuPUBjE3yWoe8zGmhPE5Bv9/poq15xJa kmBBfD82yrq0Wjr2frcjdGlCA3Q5RAdWgajh/wAjV/AvW5HUQeC2cftUynIccelVbgLG fMcg== X-Gm-Message-State: AOAM533NSOQGr3nN/7rWKNGyxOvC03Zr3mmyDhSbkn4C3KaI9jtNRbrE KErBISwGG8aSA7eveihMTv8L88BspHh57Q== X-Google-Smtp-Source: ABdhPJxod4PsZEBuVTBjAZKv3/JSYXYjBON3f4KaC1ABUX44mqGvMUoldpwz7RaCjQpam/a1D2CMyQ== X-Received: by 2002:a05:6602:1604:: with SMTP id x4mr3848702iow.114.1641784529619; Sun, 09 Jan 2022 19:15:29 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id d16sm3542182ioy.29.2022.01.09.19.15.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 19:15:29 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH v2 35/38] binman: Complete test coverage of comp_util Date: Sun, 9 Jan 2022 20:14:10 -0700 Message-Id: <20220110031413.1970836-36-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.575.g55b058a8bb-goog In-Reply-To: <20220110031413.1970836-1-sjg@chromium.org> References: <20220110031413.1970836-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.2 at phobos.denx.de X-Virus-Status: Clean Drop the unused gzip code, update comments and add a test for an invalid algorithm. The temporary file is not needed now, so drop that also. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/comp_util.py | 16 ++-------------- tools/binman/ftest.py | 9 +++++++++ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/tools/binman/comp_util.py b/tools/binman/comp_util.py index 2f78bab9bbb..dc76adab352 100644 --- a/tools/binman/comp_util.py +++ b/tools/binman/comp_util.py @@ -25,28 +25,20 @@ def compress(indata, algo, with_header=True): This requires 'lz4' and 'lzma_alone' tools. It also requires an output directory to be previously set up, by calling PrepareOutputDir(). - Care is taken to use unique temporary files so that this function can be - called from multiple threads. - Args: indata (bytes): Input data to compress - algo (str): Algorithm to use ('none', 'gzip', 'lz4' or 'lzma') + algo (str): Algorithm to use ('none', 'lz4' or 'lzma') Returns: bytes: Compressed data """ if algo == 'none': return indata - fname = tempfile.NamedTemporaryFile(prefix='%s.comp.tmp' % algo, - dir=tools.GetOutputDir()).name - tools.WriteFile(fname, indata) if algo == 'lz4': data = LZ4.compress(indata) # cbfstool uses a very old version of lzma elif algo == 'lzma': data = LZMA_ALONE.compress(indata) - elif algo == 'gzip': - data = tools.Run('gzip', '-c', fname, binary=True) else: raise ValueError("Unknown algorithm '%s'" % algo) if with_header: @@ -65,7 +57,7 @@ def decompress(indata, algo, with_header=True): Args: indata (bytes): Input data to decompress - algo (str): Algorithm to use ('none', 'gzip', 'lz4' or 'lzma') + algo (str): Algorithm to use ('none', 'lz4' or 'lzma') Returns: (bytes) Compressed data @@ -75,14 +67,10 @@ def decompress(indata, algo, with_header=True): if with_header: data_len = struct.unpack('