From patchwork Tue Nov 14 01:55:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 837657 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="nfwjxmti"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ybW2K6WpYz9s7G for ; Tue, 14 Nov 2017 13:01:13 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id A15A2C21EAB; Tue, 14 Nov 2017 01:58:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 95EA2C21F1A; Tue, 14 Nov 2017 01:56:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 026CAC21DC8; Tue, 14 Nov 2017 01:55:24 +0000 (UTC) Received: from mail-oi0-f65.google.com (mail-oi0-f65.google.com [209.85.218.65]) by lists.denx.de (Postfix) with ESMTPS id D6AFAC21E13 for ; Tue, 14 Nov 2017 01:55:19 +0000 (UTC) Received: by mail-oi0-f65.google.com with SMTP id a81so2555328oii.13 for ; Mon, 13 Nov 2017 17:55:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=GNKuUBFQU3sThTcQWzITL+atRRzLIOYUT8U0IHlBJIg=; b=nfwjxmticwiFZZtiihQXq8PeMUuz7ZutE6W4Y7hLqUZiEAgcI85LbkwCq+XcGX54Pp UupmoIxbbXnJZ/QLmOaKakByXvyTM/lZp3FRqU0jXw/JFbP/LkxLrQpsbW6ryiWOeDBS j+TUvCv5AR9GO0DlByoagXPFIeCEnv3d9LL+XbPnVtrhBjVktD7W51WV6DWiVbYHKgkp HIU9NsUUSDBol/p+qoI6YaSW/UjOlyMUkybVp7mPePIdnkbFEvt5syUdTHodkzxYYXzN 8LCk3hJfegrhp0JmYtv0Mj+4x3Fy1Hvx/VYL/ESdUhhUJnOUKyFwmQlSLSGN1m3uIpnu UD2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=GNKuUBFQU3sThTcQWzITL+atRRzLIOYUT8U0IHlBJIg=; b=plagAjeXhIfUbr/8l79kkx7UhImh1JX21gnbqmDV7SRwysP1iJzebG/PVPykViw7qK e0S9iZ3HED4oJYndN8AWzzREvbS2QRFAQkeIL32ALo4LSgMYXwWjxBzb8nKYXnlZN3QG 8HzSi411e8l7lV5FhT3+rTV9GW+6qEtxX3NdWhHJo+8KtHx0FqSfQhPew++1VxNNuZHR 8x2dzrksFxg8vZ0gyyDLnfNNlWdRnO9bjPJr2V8UcKhMxralPLfvsUICipGyDdfv6R6F bbUbqBsq8jBfcDSyWiAfAfWAMlzPvpKaUCeX5jTfspKKgnPkLmiBi+siPIReZ6ppAVMw tp7w== X-Gm-Message-State: AJaThX4HM6bYeTnTJ7+8AD8wd266q6OuwWdQI9arv+rLGssOIpps6j2z SgcfxP9iZpY8d88ACuD44tPJCw== X-Google-Smtp-Source: AGs4zMbj1N0LSvoPQd7/W6YYoWqpzzL2Pf5LBvCijtibYjnCcOJYIPM9puYA+mmrzTKDY0CEZNC8mw== X-Received: by 10.202.227.204 with SMTP id a195mr2778171oih.65.1510624518205; Mon, 13 Nov 2017 17:55:18 -0800 (PST) Received: from kiwi.bld.corp.google.com ([100.101.164.89]) by smtp.gmail.com with ESMTPSA id j15sm4962425oiy.17.2017.11.13.17.55.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Nov 2017 17:55:17 -0800 (PST) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id BDDC2140B42; Mon, 13 Nov 2017 18:55:16 -0700 (MST) From: Simon Glass To: U-Boot Mailing List Date: Mon, 13 Nov 2017 18:55:00 -0700 Message-Id: <20171114015506.25673-8-sjg@chromium.org> X-Mailer: git-send-email 2.15.0.448.gf294e3d99a-goog In-Reply-To: <20171114015506.25673-1-sjg@chromium.org> References: <20171114015506.25673-1-sjg@chromium.org> Cc: Tom Rini Subject: [U-Boot] [PATCH 07/13] binman: Support enabling debug in tests X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The elf module can provide some debugging information to assist with figuring out what is going wrong. This is also useful in tests. Update the -D option so that it is passed through to tests as well. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/binman/binman.py | 6 ++++-- tools/binman/control.py | 3 +++ tools/binman/elf.py | 3 +++ tools/binman/ftest.py | 17 +++++++++++++---- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/tools/binman/binman.py b/tools/binman/binman.py index 81a613ddc40..aa513962663 100755 --- a/tools/binman/binman.py +++ b/tools/binman/binman.py @@ -31,7 +31,7 @@ import cmdline import command import control -def RunTests(): +def RunTests(debug): """Run the functional tests and any embedded doctests""" import elf_test import entry_test @@ -46,6 +46,8 @@ def RunTests(): suite.run(result) sys.argv = [sys.argv[0]] + if debug: + sys.argv.append('-D') # Run the entry tests first ,since these need to be the first to import the # 'entry' module. @@ -111,7 +113,7 @@ def RunBinman(options, args): sys.tracebacklimit = 0 if options.test: - ret_code = RunTests() + ret_code = RunTests(options.debug) elif options.test_coverage: RunTestCoverage() diff --git a/tools/binman/control.py b/tools/binman/control.py index e9d48df0301..e175e8d41bd 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -12,6 +12,7 @@ import sys import tools import command +import elf import fdt import fdt_util from image import Image @@ -89,6 +90,8 @@ def Binman(options, args): try: tout.Init(options.verbosity) + if options.debug: + elf.debug = True try: tools.SetInputDirs(options.indir) tools.PrepareOutputDir(options.outdir, options.preserve) diff --git a/tools/binman/elf.py b/tools/binman/elf.py index 97208b17950..0fb5a4a8ed6 100644 --- a/tools/binman/elf.py +++ b/tools/binman/elf.py @@ -14,6 +14,9 @@ import struct import tools +# This is enabled from control.py +debug = False + Symbol = namedtuple('Symbol', ['section', 'address', 'size', 'weak']) # Used for tests which don't have an ELF file to read diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 372b61fbb3b..2bee6a168f3 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -136,7 +136,10 @@ class TestFunctional(unittest.TestCase): Returns: Return value (0 for success) """ - (options, args) = cmdline.ParseArgs(list(args)) + args = list(args) + if '-D' in sys.argv: + args = args + ['-D'] + (options, args) = cmdline.ParseArgs(args) options.pager = 'binman-invalid-pager' options.build_dir = self._indir @@ -144,14 +147,16 @@ class TestFunctional(unittest.TestCase): # options.verbosity = tout.DEBUG return control.Binman(options, args) - def _DoTestFile(self, fname): + def _DoTestFile(self, fname, debug=False): """Run binman with a given test file Args: fname: Device tree source filename to use (e.g. 05_simple.dts) """ - return self._DoBinman('-p', '-I', self._indir, - '-d', self.TestFile(fname)) + args = ['-p', '-I', self._indir, '-d', self.TestFile(fname)] + if debug: + args.append('-D') + return self._DoBinman(*args) def _SetupDtb(self, fname, outfile='u-boot.dtb'): """Set up a new test device-tree file @@ -363,6 +368,10 @@ class TestFunctional(unittest.TestCase): data = self._DoReadFile('05_simple.dts') self.assertEqual(U_BOOT_DATA, data) + def testSimpleDebug(self): + """Test a simple binman run with debugging enabled""" + data = self._DoTestFile('05_simple.dts', debug=True) + def testDual(self): """Test that we can handle creating two images