cmd_ut.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * (C) Copyright 2015
  3. * Joe Hershberger, National Instruments, joe.hershberger@ni.com
  4. *
  5. * SPDX-License-Identifier: GPL-2.0
  6. */
  7. #include <common.h>
  8. #include <command.h>
  9. #include <test/suites.h>
  10. static int do_ut_all(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  11. static cmd_tbl_t cmd_ut_sub[] = {
  12. U_BOOT_CMD_MKENT(all, CONFIG_SYS_MAXARGS, 1, do_ut_all, "", ""),
  13. };
  14. static int do_ut_all(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  15. {
  16. int i;
  17. int retval;
  18. int any_fail = 0;
  19. for (i = 1; i < ARRAY_SIZE(cmd_ut_sub); i++) {
  20. printf("----Running %s tests----\n", cmd_ut_sub[i].name);
  21. retval = cmd_ut_sub[i].cmd(cmdtp, flag, 1, &cmd_ut_sub[i].name);
  22. if (!any_fail)
  23. any_fail = retval;
  24. }
  25. return any_fail;
  26. }
  27. static int do_ut(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  28. {
  29. cmd_tbl_t *cp;
  30. if (argc < 2)
  31. return CMD_RET_USAGE;
  32. /* drop initial "ut" arg */
  33. argc--;
  34. argv++;
  35. cp = find_cmd_tbl(argv[0], cmd_ut_sub, ARRAY_SIZE(cmd_ut_sub));
  36. if (cp)
  37. return cp->cmd(cmdtp, flag, argc, argv);
  38. return CMD_RET_USAGE;
  39. }
  40. #ifdef CONFIG_SYS_LONGHELP
  41. static char ut_help_text[] =
  42. "all - execute all enabled tests\n"
  43. ;
  44. #endif
  45. U_BOOT_CMD(
  46. ut, CONFIG_SYS_MAXARGS, 1, do_ut,
  47. "unit tests", ut_help_text
  48. );