mmc.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2015 Google, Inc
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <mmc.h>
  8. #include <dm/test.h>
  9. #include <test/ut.h>
  10. /*
  11. * Basic test of the mmc uclass. We could expand this by implementing an MMC
  12. * stack for sandbox, or at least implementing the basic operation.
  13. */
  14. static int dm_test_mmc_base(struct unit_test_state *uts)
  15. {
  16. struct udevice *dev;
  17. ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
  18. return 0;
  19. }
  20. DM_TEST(dm_test_mmc_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  21. static int dm_test_mmc_blk(struct unit_test_state *uts)
  22. {
  23. struct udevice *dev;
  24. struct blk_desc *dev_desc;
  25. char cmp[1024];
  26. ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
  27. ut_assertok(blk_get_device_by_str("mmc", "0", &dev_desc));
  28. /* Read a few blocks and look for the string we expect */
  29. ut_asserteq(512, dev_desc->blksz);
  30. memset(cmp, '\0', sizeof(cmp));
  31. ut_asserteq(2, blk_dread(dev_desc, 0, 2, cmp));
  32. ut_assertok(strcmp(cmp, "this is a test"));
  33. return 0;
  34. }
  35. DM_TEST(dm_test_mmc_blk, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);