mmc.c 1.1 KB

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