doc: test: Add docs and test for part_find

Add some documentation and a test for this new command.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2024-12-08 12:32:43 -07:00
parent 1137ab205f
commit 6e79f1f503
4 changed files with 163 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ obj-$(CONFIG_CMD_MEMINFO) += meminfo.o
endif
obj-$(CONFIG_CMD_MEMORY) += mem_copy.o
obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o
obj-$(CONFIG_CMD_PART_FIND) += part_find.o
ifdef CONFIG_CMD_PCI
obj-$(CONFIG_CMD_PCI_MPS) += pci_mps.o
endif

42
test/cmd/part_find.c Normal file
View File

@@ -0,0 +1,42 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Test for 'part_find' command
*
* Copyright 2024 Google LLC
* Written by Simon Glass <sjg@chromium.org>
*/
#include <dm/device-internal.h>
#include <dm/lists.h>
#include <dm/ofnode.h>
#include <dm/test.h>
#include <test/cmd.h>
#include <test/ut.h>
/* Test 'part_find' command */
static int cmd_test_part_find(struct unit_test_state *uts)
{
struct udevice *dev;
ofnode root, node;
/* Enable the requested mmc node since we need a second bootflow */
root = oftree_root(oftree_default());
node = ofnode_find_subnode(root, "mmc5");
ut_assert(ofnode_valid(node));
ut_assertok(lists_bind_fdt(gd->dm_root, node, &dev, NULL, false));
ut_assertok(device_probe(dev));
ut_assertok(env_set("target_part", NULL));
ut_assertok(run_command("part_find c12a7328-f81f-11d2-ba4b-00a0c93ec93b", 0));
ut_assert_console_end();
ut_asserteq_str("mmc 5:c", env_get("target_part"));
ut_asserteq(1, run_command("part_find invalid", 0));
ut_asserteq_str("mmc 5:c", env_get("target_part"));
ut_assert_console_end();
return 0;
}
CMD_TEST(cmd_test_part_find, UTF_CONSOLE | UTF_DM | UTF_SCAN_FDT);