diff options
author | Niel Fourie <lusus@denx.de> | 2020-03-24 16:17:03 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-07-07 15:22:42 -0400 |
commit | 0ffdfbd1d0eca769878913d15f232c9219cf2aa1 (patch) | |
tree | 61c6ebad8c31b303aa34a531ddc75702a5ccba68 | |
parent | 1e88e78177da80fa8e9fa9fc7613657478d61d1e (diff) | |
download | u-boot-0ffdfbd1d0eca769878913d15f232c9219cf2aa1.tar.gz u-boot-0ffdfbd1d0eca769878913d15f232c9219cf2aa1.tar.bz2 u-boot-0ffdfbd1d0eca769878913d15f232c9219cf2aa1.zip |
cmd: part: Add subcommand to list supported partition tables
Add a subcommand "types" to the part command, which lists the supported
partition table types.
Signed-off-by: Niel Fourie <lusus@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | cmd/part.c | 27 | ||||
-rw-r--r-- | test/py/tests/test_part.py | 14 |
2 files changed, 39 insertions, 2 deletions
diff --git a/cmd/part.c b/cmd/part.c index 216f14bf5d..3395c17b89 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(": <none>"); + puts("\n"); + return CMD_RET_SUCCESS; +} + static int do_part(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { @@ -198,7 +218,8 @@ static int do_part(struct cmd_tbl *cmdtp, int flag, int argc, 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; } @@ -222,5 +243,7 @@ U_BOOT_CMD( " part can be either partition number or partition name\n" "part number <interface> <dev> <part> <varname>\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 |