test: cmd_ut_category: raise a error when the test is not found
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.
---
test/cmd_ut.c | 7 +++++++ 1 file changed, 7 insertions(+)
test/cmd_ut.c +7 -0
@@ -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);
Signature · 1 line
2.17.1
PATCH 2/3 test: correct the test prefix in ut cmd_mem
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.
---
test/cmd/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
test/cmd/mem.c +1 -1
@@ -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); }
Signature · 1 line
2.17.1
PATCH 2/3 test: correct the test prefix in ut cmd_mem
Quoted 6 lines · Patrick Delaunay
Align the prefix used in
cmd_ut_categoryfunction and name of tests for ut mem.
This patch solves the issues detected by "make qcheck" after previous patch.
Quoted 7 lines
Fixes 550a9e7902ce ("cmd: Update the memory-search command")Signed-off-by Patrick Delaunay <[email protected]>---
test/cmd/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 2/3 test: correct the test prefix in ut cmd_mem
In reply to Patrick DelaunayQuoted 8 lines · Patrick Delaunay
Align the prefix used in
cmd_ut_categoryfunction 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 <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210118/0cca1dc6/attachment.sig>
PATCH 3/3 test: correct the test prefix in ut str
In reply to Patrick DelaunayAlign 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.
---
test/str_ut.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
test/str_ut.c +2 -2
@@ -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)
Signature · 1 line
2.17.1
PATCH 3/3 test: correct the test prefix in ut str
Quoted 6 lines · Patrick Delaunay
Align the prefix used in
cmd_ut_categoryfunction and name of tests for ut str.
This patch solves the issues detected by "make qcheck" after previous patch.
Quoted 6 lines
Fixes fdc79a6b125d ("lib: Add a function to convert a string to upper case")Signed-off-by Patrick Delaunay <[email protected]>---
test/str_ut.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
PATCH 3/3 test: correct the test prefix in ut str
In reply to Patrick DelaunayQuoted 8 lines · Patrick Delaunay
Align the prefix used in
cmd_ut_categoryfunction 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 <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210118/a1ee593f/attachment.sig>
PATCH 1/3 test: cmd_ut_category: raise a error when the test is not found
In reply to Patrick DelaunayQuoted 18 lines · Patrick Delaunay
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: 0After the patch:
=> ut lib bad
lib test bad not found
Failures: 1This patch allows also to detect tests which don't respect the expected format with "prefix" used in
cmd_ut_categoryand defined inut_subtest(./test/py/conftest.py). When I execute "make qcheck" this patch detects 2 issues, corrected by the 2 next patches.
Quoted 5 lines
Signed-off-by Patrick Delaunay <[email protected]>---
test/cmd_ut.c | 7 +++++++ 1 file changed, 7 insertions(+)
PATCH 1/3 test: cmd_ut_category: raise a error when the test is not found
In reply to Patrick DelaunayQuoted 12 lines · Patrick Delaunay
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: 0After the patch:
=> ut lib bad
lib test bad not found
Failures: 1
Quoted 7 lines
This patch allows also to detect tests which don't respect the expected format with "prefix" used in
cmd_ut_categoryand defined inut_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 <[email protected]>Reviewed-by Simon Glass <[email protected]>
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.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210116/306dd571/attachment.sig>