blob: 4e5136c850507b2858100caa5ee2adea54cb0cc4 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass8e6cc462015-07-06 12:54:32 -06002/*
3 * Copyright (C) 2015 Google, Inc
Simon Glass8e6cc462015-07-06 12:54:32 -06004 */
5
6#include <common.h>
7#include <dm.h>
8#include <mmc.h>
Simon Glasse6f6f9e2020-05-10 11:39:58 -06009#include <part.h>
Simon Glass8e6cc462015-07-06 12:54:32 -060010#include <dm/test.h>
Simon Glass0e1fad42020-07-19 10:15:37 -060011#include <test/test.h>
Simon Glass8e6cc462015-07-06 12:54:32 -060012#include <test/ut.h>
13
Simon Glass8e6cc462015-07-06 12:54:32 -060014/*
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.
17 */
18static int dm_test_mmc_base(struct unit_test_state *uts)
19{
20 struct udevice *dev;
21
22 ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
23
24 return 0;
25}
Simon Glasse180c2b2020-07-28 19:41:12 -060026DM_TEST(dm_test_mmc_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
Simon Glass341392d2016-05-01 13:52:44 -060027
28static int dm_test_mmc_blk(struct unit_test_state *uts)
29{
30 struct udevice *dev;
31 struct blk_desc *dev_desc;
32 char cmp[1024];
33
34 ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
35 ut_assertok(blk_get_device_by_str("mmc", "0", &dev_desc));
36
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"));
42
43 return 0;
44}
Simon Glasse180c2b2020-07-28 19:41:12 -060045DM_TEST(dm_test_mmc_blk, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);