cmd_ut_env.c 893 B

12345678910111213141516171819202122232425262728293031323334353637
  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/env.h>
  10. #include <test/suites.h>
  11. #include <test/ut.h>
  12. int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  13. {
  14. struct unit_test *tests = ll_entry_start(struct unit_test, env_test);
  15. const int n_ents = ll_entry_count(struct unit_test, env_test);
  16. struct unit_test_state uts = { .fail_count = 0 };
  17. struct unit_test *test;
  18. if (argc == 1)
  19. printf("Running %d environment tests\n", n_ents);
  20. for (test = tests; test < tests + n_ents; test++) {
  21. if (argc > 1 && strcmp(argv[1], test->name))
  22. continue;
  23. printf("Test: %s\n", test->name);
  24. uts.start = mallinfo();
  25. test->func(&uts);
  26. }
  27. printf("Failures: %d\n", uts.fail_count);
  28. return uts.fail_count ? CMD_RET_FAILURE : 0;
  29. }