[PATCH 1/3] test: cmd_ut_category: raise a error when the test is not found

Patrick Delaunay patrick.delaunay at st.com
Thu Nov 19 10:08:41 CET 2020


Raise an error when test is not found, for example with manual test
with bad test name, as following, doesn't raise an error

=> ut lib bad
Failures: 0

After the patch:

=> ut lib bad
lib test bad not found
Failures: 1

This patch allows also to detect tests which don't respect the expected
format with "prefix" used in cmd_ut_category and defined in ut_subtest
(./test/py/conftest.py). When I execute "make qcheck" this patch detects
2 issues, corrected by the 2 next patches.

Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
---

 test/cmd_ut.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 8f0bc688a2..6a752e6456 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -20,6 +20,7 @@ int cmd_ut_category(const char *name, const char *prefix,
 	struct unit_test_state uts = { .fail_count = 0 };
 	struct unit_test *test;
 	int prefix_len = prefix ? strlen(prefix) : 0;
+	int nb_tests = 0;
 
 	if (argc == 1)
 		printf("Running %d %s tests\n", n_ents, name);
@@ -47,6 +48,12 @@ int cmd_ut_category(const char *name, const char *prefix,
 		uts.start = mallinfo();
 
 		test->func(&uts);
+		nb_tests++;
+	}
+
+	if (argc > 1 && nb_tests == 0) {
+		printf("%s test %s not found\n", name, argv[1]);
+		uts.fail_count = 1;
 	}
 
 	printf("Failures: %d\n", uts.fail_count);
-- 
2.17.1



More information about the U-Boot mailing list