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

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@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);

Align the prefix used in cmd_ut_category function and name of tests for ut mem. This patch solves the issues detected by "make qcheck" after previous patch.
Fixes: 550a9e7902ce ("cmd: Update the memory-search command") Signed-off-by: Patrick Delaunay patrick.delaunay@st.com ---
test/cmd/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/cmd/mem.c b/test/cmd/mem.c index fa6770e8c0..fbaa8a4b3c 100644 --- a/test/cmd/mem.c +++ b/test/cmd/mem.c @@ -15,6 +15,6 @@ int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) struct unit_test *tests = ll_entry_start(struct unit_test, mem_test); const int n_ents = ll_entry_count(struct unit_test, mem_test);
- return cmd_ut_category("cmd_mem", "cmd_mem_", tests, n_ents, argc, + return cmd_ut_category("cmd_mem", "mem_test_", tests, n_ents, argc, argv); }

On Thu, 19 Nov 2020 at 03:09, Patrick Delaunay patrick.delaunay@st.com wrote:
Align the prefix used in cmd_ut_category function and name of tests for ut mem. This patch solves the issues detected by "make qcheck" after previous patch.
Fixes: 550a9e7902ce ("cmd: Update the memory-search command") Signed-off-by: Patrick Delaunay patrick.delaunay@st.com
test/cmd/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Thu, Nov 19, 2020 at 10:08:42AM +0100, Patrick Delaunay wrote:
Align the prefix used in cmd_ut_category function and name of tests for ut mem. This patch solves the issues detected by "make qcheck" after previous patch.
Fixes: 550a9e7902ce ("cmd: Update the memory-search command") Signed-off-by: Patrick Delaunay patrick.delaunay@st.com Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

Align the prefix used in cmd_ut_category function and name of tests for ut str. This patch solves the issues detected by "make qcheck" after previous patch.
Fixes: fdc79a6b125d ("lib: Add a function to convert a string to upper case") Signed-off-by: Patrick Delaunay patrick.delaunay@st.com ---
test/str_ut.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/str_ut.c b/test/str_ut.c index ef1205dbbd..cd5045516d 100644 --- a/test/str_ut.c +++ b/test/str_ut.c @@ -19,7 +19,7 @@ static const char str3[] = "0xbI'm sorry you're alive."; /* Declare a new str test */ #define STR_TEST(_name, _flags) UNIT_TEST(_name, _flags, str_test)
-static int str_test_upper(struct unit_test_state *uts) +static int str_upper(struct unit_test_state *uts) { char out[TEST_STR_SIZE];
@@ -55,7 +55,7 @@ static int str_test_upper(struct unit_test_state *uts)
return 0; } -STR_TEST(str_test_upper, 0); +STR_TEST(str_upper, 0);
static int run_strtoul(struct unit_test_state *uts, const char *str, int base, ulong expect_val, int expect_endp_offset, bool upper)

On Thu, 19 Nov 2020 at 03:09, Patrick Delaunay patrick.delaunay@st.com wrote:
Align the prefix used in cmd_ut_category function and name of tests for ut str. This patch solves the issues detected by "make qcheck" after previous patch.
Fixes: fdc79a6b125d ("lib: Add a function to convert a string to upper case") Signed-off-by: Patrick Delaunay patrick.delaunay@st.com
test/str_ut.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Thu, Nov 19, 2020 at 10:08:43AM +0100, Patrick Delaunay wrote:
Align the prefix used in cmd_ut_category function and name of tests for ut str. This patch solves the issues detected by "make qcheck" after previous patch.
Fixes: fdc79a6b125d ("lib: Add a function to convert a string to upper case") Signed-off-by: Patrick Delaunay patrick.delaunay@st.com Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

On Thu, 19 Nov 2020 at 03:09, Patrick Delaunay patrick.delaunay@st.com wrote:
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@st.com
test/cmd_ut.c | 7 +++++++ 1 file changed, 7 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org

On Thu, Nov 19, 2020 at 10:08:41AM +0100, Patrick Delaunay wrote:
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@st.com Reviewed-by: Simon Glass sjg@chromium.org
This is a great idea, which I cannot apply right now as it shows the setexpr tests aren't right. So, I'll try and look in to that if someone else doesn't get there first.
participants (3)
-
Patrick Delaunay
-
Simon Glass
-
Tom Rini