Files
u-boot/test/cmd/part_find.c
Simon Glass 6e79f1f503 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>
2025-09-25 09:47:09 -06:00

43 lines
1.1 KiB
C

// 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);