test-dm.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2013 Google, Inc
  4. */
  5. #include <common.h>
  6. #include <command.h>
  7. #include <console.h>
  8. #include <dm.h>
  9. #include <errno.h>
  10. #include <log.h>
  11. #include <malloc.h>
  12. #include <asm/global_data.h>
  13. #include <asm/state.h>
  14. #include <dm/root.h>
  15. #include <dm/uclass-internal.h>
  16. #include <test/test.h>
  17. #include <test/test.h>
  18. #include <test/ut.h>
  19. DECLARE_GLOBAL_DATA_PTR;
  20. /**
  21. * dm_test_run() - Run driver model tests
  22. *
  23. * Run all the available driver model tests, or a selection
  24. *
  25. * @test_name: Name of single test to run (e.g. "dm_test_fdt_pre_reloc" or just
  26. * "fdt_pre_reloc"), or NULL to run all
  27. * @return 0 if all tests passed, 1 if not
  28. */
  29. static int dm_test_run(const char *test_name)
  30. {
  31. struct unit_test *tests = UNIT_TEST_SUITE_START(dm_test);
  32. const int n_ents = UNIT_TEST_SUITE_COUNT(dm_test);
  33. int ret;
  34. ret = ut_run_list("driver model", "dm_test_", tests, n_ents, test_name);
  35. return ret ? CMD_RET_FAILURE : 0;
  36. }
  37. int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
  38. {
  39. const char *test_name = NULL;
  40. if (argc > 1)
  41. test_name = argv[1];
  42. return dm_test_run(test_name);
  43. }