u-boot/test/dm/fastboot.c
Tom Rini 7894816a98 global: Avoid indirect inclusion of <env.h> from <command.h>
The include file <command.h> does not need anything from <env.h>.
Furthermore, include/env.h itself includes other headers which can lead
to longer indirect inclusion paths. To prepare to remove <env.h> from
<command.h> fix all of the places which had relied on this indirect
inclusion to instead include <env.h> directly.

Signed-off-by: Tom Rini <trini@konsulko.com>
---
Cc: Anatolij Gustschin <agust@denx.de>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Jerome Forissier <jerome.forissier@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Marek Vasut <marex@denx.de>
Cc: Mark Kettenis <kettenis@openbsd.org>
Cc: Masahisa Kojima <kojima.masahisa@socionext.com>
Cc: Mattijs Korpershoek <mkorpershoek@kernel.org>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Cc: Stefan Bosch <stefan_b@posteo.net>
Cc: Tien Fong Chee <tien.fong.chee@altera.com>
Cc: Tingting Meng <tingting.meng@altera.com>
Cc: Tobias Waldekranz <tobias@waldekranz.com>
2025-05-14 13:34:36 -06:00

96 lines
3.1 KiB
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2015 Google, Inc
*/
#include <dm.h>
#include <env.h>
#include <fastboot.h>
#include <fb_mmc.h>
#include <mmc.h>
#include <part.h>
#include <part_efi.h>
#include <dm/test.h>
#include <test/ut.h>
#include <linux/stringify.h>
#define FB_ALIAS_PREFIX "fastboot_partition_alias_"
static int dm_test_fastboot_mmc_part(struct unit_test_state *uts)
{
char response[FASTBOOT_RESPONSE_LEN] = {0};
char str_disk_guid[UUID_STR_LEN + 1];
struct blk_desc *mmc_dev_desc, *fb_dev_desc;
struct disk_partition part_info;
struct disk_partition parts[2] = {
{
.start = 48, /* GPT data takes up the first 34 blocks or so */
.size = 1,
.name = "test1",
},
{
.start = 49,
.size = 1,
.name = "test2",
},
};
/*
* There are a lot of literal 0s I don't want to have to construct from
* MMC_DEV.
*/
ut_asserteq(0, CONFIG_FASTBOOT_FLASH_MMC_DEV);
ut_assertok(blk_get_device_by_str("mmc", "0", &mmc_dev_desc));
if (CONFIG_IS_ENABLED(RANDOM_UUID)) {
gen_rand_uuid_str(parts[0].uuid, UUID_STR_FORMAT_STD);
gen_rand_uuid_str(parts[1].uuid, UUID_STR_FORMAT_STD);
gen_rand_uuid_str(str_disk_guid, UUID_STR_FORMAT_STD);
}
ut_assertok(gpt_restore(mmc_dev_desc, str_disk_guid, parts,
ARRAY_SIZE(parts)));
/* "Classic" partition labels */
ut_asserteq(1, fastboot_mmc_get_part_info("test1", &fb_dev_desc,
&part_info, response));
ut_asserteq(2, fastboot_mmc_get_part_info("test2", &fb_dev_desc,
&part_info, response));
/* Test aliases */
ut_assertnull(env_get(FB_ALIAS_PREFIX "test3"));
ut_assertok(env_set(FB_ALIAS_PREFIX "test3", "test1"));
ut_asserteq(1, fastboot_mmc_get_part_info("test3", &fb_dev_desc,
&part_info, response));
ut_assertok(env_set(FB_ALIAS_PREFIX "test3", NULL));
/* "New" partition labels */
ut_asserteq(1, fastboot_mmc_get_part_info("#test1", &fb_dev_desc,
&part_info, response));
ut_asserteq(1, fastboot_mmc_get_part_info("0#test1", &fb_dev_desc,
&part_info, response));
ut_asserteq(1, fastboot_mmc_get_part_info("0.0#test1", &fb_dev_desc,
&part_info, response));
ut_asserteq(1, fastboot_mmc_get_part_info("0:1", &fb_dev_desc,
&part_info, response));
ut_asserteq(1, fastboot_mmc_get_part_info("0.0:1", &fb_dev_desc,
&part_info, response));
ut_asserteq(1, fastboot_mmc_get_part_info("0", &fb_dev_desc,
&part_info, response));
ut_asserteq(1, fastboot_mmc_get_part_info("0.0", &fb_dev_desc,
&part_info, response));
ut_asserteq(0, fastboot_mmc_get_part_info("0:0", &fb_dev_desc,
&part_info, response));
ut_asserteq(0, fastboot_mmc_get_part_info("0.0:0", &fb_dev_desc,
&part_info, response));
ut_asserteq(0, fastboot_mmc_get_part_info("2", &fb_dev_desc,
&part_info, response));
ut_asserteq(0, fastboot_mmc_get_part_info("2.0", &fb_dev_desc,
&part_info, response));
ut_asserteq(1, fastboot_mmc_get_part_info(":1", &fb_dev_desc,
&part_info, response));
ut_asserteq(0, fastboot_mmc_get_part_info(":0", &fb_dev_desc,
&part_info, response));
return 0;
}
DM_TEST(dm_test_fastboot_mmc_part, UTF_SCAN_PDATA | UTF_SCAN_FDT);