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 D6910C433F5 for ; Mon, 10 Jan 2022 03:18:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 06FFA8326B; Mon, 10 Jan 2022 04:16:21 +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="WRjF3t9M"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 748D981C08; Mon, 10 Jan 2022 04:15:42 +0100 (CET) Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 A062980636 for ; Mon, 10 Jan 2022 04:15:22 +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-il1-x12b.google.com with SMTP id y18so935830iln.3 for ; Sun, 09 Jan 2022 19:15:22 -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=mc/Ufkl7Wghe4fg7+pCciJclMUYyYg3JNa7ttV9BgFU=; b=WRjF3t9Mpqb5sUZwV8dX8d09g0QiILldKpRlPpZnssqR1BpSElucfnaWp3xf9MEBRN v3hRBwEC40olzE+BwxIFSVtDBVprw2kngZLB2twhnOMPhhRfT6dDQkpLEE5RnX+VB0R8 dU2U/Cs/lgyeBXByx+88othtZ5LPcypze0qsg= 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=mc/Ufkl7Wghe4fg7+pCciJclMUYyYg3JNa7ttV9BgFU=; b=rsgvfZtFoDhhtJWenTfD38tZnwhIjO1UxdH6sIKv7m6ZiUrSKRmlNstfTnMa9U27/T pEKrb+O6U4s7rdwiAPlqDc1o9l3CZgJU3gINoBzd2vxi5EaXeZD6bratfGPvhey3MZl/ vi4TjXM1g86aCCvLCdisPpLrDDvwED48OZPOoeeeFBbKxuokY9bDf7f5aMY2z8C0JoG3 2Gb9zgzKC93myiB3Bd1D+O8rVtrwfUA9xVOO72zs30OYcblUUWWX4+qbcIJHdLy29uDr Zv8/pI7X9A730FnvHhUjRYCcvhjmgfUIGqXnIACS9dlHCiinDP14nd+oCj7tx7fBf2vt fuQg== X-Gm-Message-State: AOAM533AdpcL9Kv3oYgf1yIoJiohlJ6hDSbKvu2i997Ie5u3X23ACrR8 AJhh+vqC9LqlJjETgF3yngR4tdIo/FzRSA== X-Google-Smtp-Source: ABdhPJwvQTGozdb2qyQb9iNUTmXienoaDvUz/7B2ylwC7iHXrdqForgpSzzRq9kLIDsRfeeLGnehIg== X-Received: by 2002:a05:6e02:184c:: with SMTP id b12mr8459672ilv.307.1641784521275; Sun, 09 Jan 2022 19:15:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 19:15:21 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH v2 22/38] binman: Enable bintool tests including cmdline processing Date: Sun, 9 Jan 2022 20:13:57 -0700 Message-Id: <20220110031413.1970836-23-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 The tests rely on having at least 5 bintool implementions. Now that we have this, enable them. Add tests for the binman 'tool' subcommand. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/ftest.py | 32 ++++++++++++++++++++++++++++++++ tools/binman/main.py | 7 ++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 179326c42a3..92bcb740884 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -17,6 +17,8 @@ import struct import sys import tempfile import unittest +import unittest.mock +import urllib.error from binman import bintool from binman import cbfs_util @@ -4991,6 +4993,36 @@ fdt fdtmap Extract the devicetree blob from the fdtmap err = stderr.getvalue() self.assertRegex(err, "Image 'main-section'.*faked.*: blob-ext-list") + def testListBintools(self): + args = ['tool', '--list'] + with test_util.capture_sys_output() as (stdout, _): + self._DoBinman(*args) + out = stdout.getvalue().splitlines() + self.assertTrue(len(out) >= 2) + + def testFetchBintools(self): + def fail_download(url): + """Take the tools.Download() function by raising an exception""" + raise urllib.error.URLError('my error') + + args = ['tool'] + with self.assertRaises(ValueError) as e: + self._DoBinman(*args) + self.assertIn("Invalid arguments to 'tool' subcommand", + str(e.exception)) + + args = ['tool', '--fetch'] + with self.assertRaises(ValueError) as e: + self._DoBinman(*args) + self.assertIn('Please specify bintools to fetch', str(e.exception)) + + args = ['tool', '--fetch', '_testing'] + with unittest.mock.patch.object(tools, 'Download', + side_effect=fail_download): + with test_util.capture_sys_output() as (stdout, _): + self._DoBinman(*args) + self.assertIn('failed to fetch with all methods', stdout.getvalue()) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/main.py b/tools/binman/main.py index 35944f314a2..dcf20290f2b 100755 --- a/tools/binman/main.py +++ b/tools/binman/main.py @@ -68,6 +68,7 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath): name to execute (as in 'binman test testSections', for example) toolpath: List of paths to use for tools """ + from binman import bintool_test from binman import cbfs_util_test from binman import elf_test from binman import entry_test @@ -85,9 +86,9 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath): test_util.RunTestSuites( result, debug, verbosity, test_preserve_dirs, processes, test_name, toolpath, - [entry_test.TestEntry, ftest.TestFunctional, fdt_test.TestFdt, - elf_test.TestElf, image_test.TestImage, cbfs_util_test.TestCbfs, - fip_util_test.TestFip]) + [bintool_test.TestBintool, entry_test.TestEntry, ftest.TestFunctional, + fdt_test.TestFdt, elf_test.TestElf, image_test.TestImage, + cbfs_util_test.TestCbfs, fip_util_test.TestFip]) return test_util.ReportResult('binman', test_name, result) -- 2.34.1.575.g55b058a8bb-goog