1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2015 Google, Inc
11 #include <test/test.h>
15 * Basic test of the mmc uclass. We could expand this by implementing an MMC
16 * stack for sandbox, or at least implementing the basic operation.
18 static int dm_test_mmc_base(struct unit_test_state *uts)
22 ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
26 DM_TEST(dm_test_mmc_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
28 static int dm_test_mmc_blk(struct unit_test_state *uts)
31 struct blk_desc *dev_desc;
34 ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
35 ut_assertok(blk_get_device_by_str("mmc", "0", &dev_desc));
37 /* Read a few blocks and look for the string we expect */
38 ut_asserteq(512, dev_desc->blksz);
39 memset(cmp, '\0', sizeof(cmp));
40 ut_asserteq(2, blk_dread(dev_desc, 0, 2, cmp));
41 ut_assertok(strcmp(cmp, "this is a test"));
45 DM_TEST(dm_test_mmc_blk, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);