xref: /openbmc/u-boot/test/env/cmd_ut_env.c (revision d9b23e26)
1 /*
2  * (C) Copyright 2015
3  * Joe Hershberger, National Instruments, joe.hershberger@ni.com
4  *
5  * SPDX-License-Identifier:	GPL-2.0
6  */
7 
8 #include <common.h>
9 #include <command.h>
10 #include <test/env.h>
11 #include <test/suites.h>
12 #include <test/ut.h>
13 
14 int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
15 {
16 	struct unit_test *tests = ll_entry_start(struct unit_test, env_test);
17 	const int n_ents = ll_entry_count(struct unit_test, env_test);
18 	struct unit_test_state uts = { .fail_count = 0 };
19 	struct unit_test *test;
20 
21 	if (argc == 1)
22 		printf("Running %d environment tests\n", n_ents);
23 
24 	for (test = tests; test < tests + n_ents; test++) {
25 		if (argc > 1 && strcmp(argv[1], test->name))
26 			continue;
27 		printf("Test: %s\n", test->name);
28 
29 		uts.start = mallinfo();
30 
31 		test->func(&uts);
32 	}
33 
34 	printf("Failures: %d\n", uts.fail_count);
35 
36 	return uts.fail_count ? CMD_RET_FAILURE : 0;
37 }
38