From patchwork Thu Mar 19 16:13:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niel Fourie X-Patchwork-Id: 1258290 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=FaxhQ+6m; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48jsRf2rpMz9sPR for ; Fri, 20 Mar 2020 03:14:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4D8B281662; Thu, 19 Mar 2020 17:14:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1584634449; bh=qe1d0/7C3HQ6O3rX41XuPGjOctYdQYqp+Rl+BIqXfrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=FaxhQ+6myKgST3yBVPfJvu4NHpjcm74CkgXslv8AzdiCYcE+sChpCv2l6zfGoYrdt PGkx3rwpuVlXIxuKjp9sf776Jhbza1Buxo38T+Mknu26iM/jZ9Rd0iTZJp28e58K9o yUrezlUZHkq/POTRW+AOYuhQV4B4eTS1T965SGQdWmtkNxmOdwpfPylTyA4BpWOzET OOl4DMhHoN2uxFeC9yOK0A6eyILrpdrN7aylPzxLrXfDQiKrEK6rd5jEvrn8acouab PsBDHzKmtS52lMDSxRr5GPsJ65ZKHLXvFAUGwBC6Z6ZVf1fcSKa4wsd9h2KEKNWpee YyH27mbM+yhgg== Received: by phobos.denx.de (Postfix, from userid 109) id 458F48157B; Thu, 19 Mar 2020 17:14:06 +0100 (CET) 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, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) (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 63F0381286 for ; Thu, 19 Mar 2020 17:14:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=lusus@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 48jsRG02wBz1qs39; Thu, 19 Mar 2020 17:14:01 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 48jsRF6mQxz1qrGj; Thu, 19 Mar 2020 17:14:01 +0100 (CET) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id fBU_Q1jRTRyx; Thu, 19 Mar 2020 17:14:01 +0100 (CET) X-Auth-Info: VKwHE9RtVy1j9pQ+OW0Y7+0KGKQbH2I96U84f51fmMc= Received: from aldebaran.denx.de (unknown [62.91.23.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 19 Mar 2020 17:14:01 +0100 (CET) From: Niel Fourie To: u-boot@lists.denx.de Cc: sjg@chromium.org, seanga2@gmail.com, Niel Fourie Subject: [PATCH v2 1/3] cmd: part: Add subcommand to list supported partition tables Date: Thu, 19 Mar 2020 17:13:28 +0100 Message-Id: <20200319161330.1195470-2-lusus@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200319161330.1195470-1-lusus@denx.de> References: <20200319161330.1195470-1-lusus@denx.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean Add a subcommand "types" to the part command, which lists the supported partition table types. Signed-off-by: Niel Fourie CC: Simon Glass Reviewed-by: Simon Glass --- Changes in v2: - Add Python test cmd/part.c | 27 +++++++++++++++++++++++++-- test/py/tests/test_part.py | 14 ++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 test/py/tests/test_part.py diff --git a/cmd/part.c b/cmd/part.c index 5e4e45ca6d..fae5df7b71 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -182,6 +182,26 @@ static int do_part_number(int argc, char * const argv[]) return do_part_info(argc, argv, CMD_PART_INFO_NUMBER); } +static int do_part_types(int argc, char * const argv[]) +{ + struct part_driver *drv = ll_entry_start(struct part_driver, + part_driver); + const int n_ents = ll_entry_count(struct part_driver, part_driver); + struct part_driver *entry; + int i = 0; + + puts("Supported partition tables"); + + for (entry = drv; entry != drv + n_ents; entry++) { + printf("%c %s", i ? ',' : ':', entry->name); + i++; + } + if (!i) + puts(": "); + puts("\n"); + return CMD_RET_SUCCESS; +} + static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { if (argc < 2) @@ -197,7 +217,8 @@ static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return do_part_size(argc - 2, argv + 2); else if (!strcmp(argv[1], "number")) return do_part_number(argc - 2, argv + 2); - + else if (!strcmp(argv[1], "types")) + return do_part_types(argc - 2, argv + 2); return CMD_RET_USAGE; } @@ -221,5 +242,7 @@ U_BOOT_CMD( " part can be either partition number or partition name\n" "part number \n" " - set environment variable to the partition number using the partition name\n" - " part must be specified as partition name" + " part must be specified as partition name\n" + "part types\n" + " - list supported partition table types" ); diff --git a/test/py/tests/test_part.py b/test/py/tests/test_part.py new file mode 100644 index 0000000000..cba9804510 --- /dev/null +++ b/test/py/tests/test_part.py @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2020 +# Niel Fourie, DENX Software Engineering, lusus@denx.de + +import pytest + +@pytest.mark.buildconfigspec('cmd_part') +@pytest.mark.buildconfigspec('partitions') +@pytest.mark.buildconfigspec('efi_partition') +def test_dm_compat(u_boot_console): + """Test that `part types` prints a result which includes `EFI`.""" + output = u_boot_console.run_command('part types') + assert "Supported partition tables:" in output + assert "EFI" in output