blob: 9ab0db1b66fee7f27489cd20311b6692d7e82491 [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>
9#include <dm/test.h>
10#include <test/ut.h>
11
Simon Glass8e6cc462015-07-06 12:54:32 -060012/*
13 * Basic test of the mmc uclass. We could expand this by implementing an MMC
14 * stack for sandbox, or at least implementing the basic operation.
15 */
16static int dm_test_mmc_base(struct unit_test_state *uts)
17{
18 struct udevice *dev;
19
20 ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
21
22 return 0;
23}
24DM_TEST(dm_test_mmc_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
Simon Glass341392d2016-05-01 13:52:44 -060025
26static int dm_test_mmc_blk(struct unit_test_state *uts)
27{
28 struct udevice *dev;
29 struct blk_desc *dev_desc;
30 char cmp[1024];
31
32 ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
33 ut_assertok(blk_get_device_by_str("mmc", "0", &dev_desc));
34
35 /* Read a few blocks and look for the string we expect */
36 ut_asserteq(512, dev_desc->blksz);
37 memset(cmp, '\0', sizeof(cmp));
38 ut_asserteq(2, blk_dread(dev_desc, 0, 2, cmp));
39 ut_assertok(strcmp(cmp, "this is a test"));
40
41 return 0;
42}
43DM_TEST(dm_test_mmc_blk, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);