test: Tidy up the test/ directory
cover test: Tidy up the test/ directory
Some tests do not use the unit-test framework. Others are in a suite of their own, for no obvious reason.
This series tidies this up.
Simon Glass (21):
bloblist: test: Move test into common
bloblist: test: Drop global_data declarations
bloblist: test: doc: Move into the common suite
test: Drop test-trace.sh and common.sh
compression: test: Move test into lib
compression: test: Move into the lib suite
command_ut: test: Move test into lib
command: test: Move into the cmd suite
test: Update command test to use unit-test functions
bootm: test: Move test into boot
test: Move print_ut test into common
test: Move print_ut into the common suite
test: Move str_ut test into lib
str: test: Move into the lib suite
test: Move unicode_ut test into lib
test: Move unicode tests into the lib suite
test: Move time_ut test into lib
test: Move time tests into the lib suite
test: Update time tests to use unit-test asserts
test: Correct display of failing test
test: Quote test names
doc/usage/cmd/ut.rst | 29 +++++--
include/test/compression.h | 16 ----
test/Makefile | 10 ---
test/boot/Makefile | 1 +
test/{ => boot}/bootm.c | 0
test/cmd/Makefile | 1 +
test/cmd/command.c | 108 +++++++++++++++++++++++++++
test/cmd_ut.c | 30 +-------
test/command_ut.c | 104 --------------------------
test/common.sh | 20 -----
test/common/Makefile | 4 +
test/{ => common}/bloblist.c | 47 ++++--------
test/{print_ut.c => common/print.c} | 27 ++-----
test/lib/Makefile | 6 ++
test/{ => lib}/compression.c | 39 ++++------
test/{str_ut.c => lib/str.c} | 31 +++-----
test/{time_ut.c => lib/time.c} | 60 +++++----------
test/{unicode_ut.c => lib/unicode.c} | 70 +++++++----------
test/test-main.c | 8 +-
test/trace/test-trace.sh | 64 ----------------
20 files changed, 240 insertions(+), 435 deletions(-)
delete mode 100644 include/test/compression.h
rename test/{ => boot}/bootm.c (100%)
create mode 100644 test/cmd/command.c
delete mode 100644 test/command_ut.c
delete mode 100644 test/common.sh
rename test/{ => common}/bloblist.c (93%)
rename test/{print_ut.c => common/print.c} (94%)
rename test/{ => lib}/compression.c (95%)
rename test/{str_ut.c => lib/str.c} (93%)
rename test/{time_ut.c => lib/time.c} (56%)
rename test/{unicode_ut.c => lib/unicode.c} (92%)
delete mode 100755 test/trace/test-trace.shSignature · 1 line
2.43.0
PATCH 1/21 bloblist: test: Move test into common
This test doesn't belong at the top level. Move it into the common/ directory, to match its implementation.
This also fixes the build rule for the bootm test, which was depending on bloblist by mistake.
---
test/Makefile | 3 ---
test/common/Makefile | 3 +++
test/{ => common}/bloblist.c | 0
3 files changed, 3 insertions(+), 3 deletions(-)
rename test/{ => common}/bloblist.c (100%)test/Makefile +0 -3
@@ -4,10 +4,7 @@ obj-y += test-main.o -ifneq ($(CONFIG_$(XPL_)BLOBLIST),) -obj-$(CONFIG_$(XPL_)CMDLINE) += bloblist.o obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o -endif obj-$(CONFIG_$(XPL_)CMDLINE) += cmd/ obj-$(CONFIG_$(XPL_)CMDLINE) += cmd_ut.o obj-$(CONFIG_$(XPL_)CMDLINE) += command_ut.o
test/common/Makefile +3 -0
@@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0+ obj-y += cmd_ut_common.o obj-$(CONFIG_AUTOBOOT) += test_autoboot.o +ifneq ($(CONFIG_$(XPL_)BLOBLIST),) +obj-$(CONFIG_$(XPL_)CMDLINE) += bloblist.o +endif obj-$(CONFIG_CYCLIC) += cyclic.o obj-$(CONFIG_EVENT_DYNAMIC) += event.o obj-y += cread.o
test/common/bloblist.c renamed from test/bloblist.c +0 -0
Signature · 1 line
2.43.0
Re: [PATCH 01/21] bloblist: test: Move test into common
Quoted 6 lines · Simon Glass
This test doesn't belong at the top level. Move it into the common/ directory, to match its implementation.
This also fixes the build rule for the bootm test, which was depending on bloblist by mistake.
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
test/Makefile | 3 --- test/common/Makefile | 3 +++ test/{ => common}/bloblist.c | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename test/{ => common}/bloblist.c (100%)
On rpi_3_32b (and presumably others):test/py/tests/test_ut.py ss....F
=================================== FAILURES =================================== _______________________ test_ut[ut_bootm_bootm_test_nop] _______________________ test/py/tests/test_ut.py:592: in test_ut
assert output.endswith('Failures: 0')
E AssertionError: assert False
E + where False = <built-in method endswith of str object at 0x2bfcb00>('Failures: 0')
E + where <built-in method endswith of str object at 0x2bfcb00> = 'ut - unit tests\r\n\r\nUsage:\r\nut [-r] [-f] [<suite>] - run unit tests\r\n -r<runs> Number of times to run each...elated commands\r\nprint - printing things to the console\r\nsetexpr - setexpr command\r\nunicode - Unicode functions'.endswith
----------------------------- Captured stdout call ----------------------------- U-Boot> ut bootm bootm_test_nop
ut - unit tests
Usage:
ut [-r] [-f] [<suite>] - run unit tests
-r<runs> Number of times to run each test -f Force 'manual' tests to run as well <suite> Test suite to run, or all
Options for <suite>:
all - execute all enabled tests
info - show info about tests
bdinfo - bdinfo command
bootstd - standard boot implementation
cmd - test various commands
env - environment
fdt - fdt command
hush - Test hush behavior
lib - library functions
log - logging functions
mem - memory-related commands
print - printing things to the console
setexpr - setexpr command
unicode - Unicode functions
U-Boot>
=========================== short test summary info ============================
Signature · 1 line
Tom
Re: [PATCH 01/21] bloblist: test: Move test into common
Hi Tom,
Quoted 48 lines · Tom Rini
Quoted 6 lines · Simon Glass
This test doesn't belong at the top level. Move it into the common/ directory, to match its implementation.
This also fixes the build rule for the bootm test, which was depending on bloblist by mistake.
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
test/Makefile | 3 --- test/common/Makefile | 3 +++ test/{ => common}/bloblist.c | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename test/{ => common}/bloblist.c (100%)On
rpi_3_32b(and presumably others):test/py/tests/test_ut.pyss....F=================================== FAILURES =================================== _______________________ test_ut[ut_bootm_bootm_test_nop] _______________________
test/py/tests/test_ut.py:592: intest_ut
assertoutput.endswith('Failures: 0')
E AssertionError: assert False
E + where False = <built-in method endswith of str object at 0x2bfcb00>('Failures: 0')
E + where <built-in method endswith of str object at0x2bfcb00> = 'ut - unit tests\r\n\r\nUsage:\r\nut [-r] [-f] [<suite>] - run unit tests\r\n -r<runs> Number of times to run each...elated commands\r\nprint - printing things to the console\r\nsetexpr - setexpr command\r\nunicode - Unicode functions'.endswith
----------------------------- Captured stdout call ----------------------------- U-Boot> ut bootmbootm_test_nop
ut - unit testsUsage:
ut [-r] [-f] [<suite>] - run unit tests-r<runs> Number of times to run each test -f Force 'manual' tests to run as well <suite> Test suite to run, or allOptions for <suite>:
all - execute all enabled tests
info - show info about tests
bdinfo - bdinfo command
bootstd - standard boot implementation
cmd - test various commands
env - environment
fdt - fdt command
hush - Test hush behavior
Quoted 8 lines
lib - library functions
log - logging functions
mem - memory-related commands
print - printing things to the console
setexpr - setexpr command
unicode - Unicode functions
U-Boot>
=========================== short test summary info ============================
Oh, that explains why the test depended on bloblist. I thought it was a mistake but it was just a way to make it only run on sandbox. I will resend the series, leaving the bloblist suite in place.
I'm looking forward to getting my lab running...
Regards,
Simon
PATCH 2/21 bloblist: test: Drop global_data declarations
In reply to Simon GlassThis pointer is not used any more, so drop the declarations.
---
test/common/bloblist.c | 3 --- 1 file changed, 3 deletions(-)
test/common/bloblist.c +0 -3
@@ -6,13 +6,10 @@#include <bloblist.h> #include <log.h> #include <mapmem.h> -#include <asm/global_data.h> #include <test/suites.h> #include <test/test.h> #include <test/ut.h> -DECLARE_GLOBAL_DATA_PTR ; -/* Declare a new bloblist test */ #define BLOBLIST_TEST (_name, _flags) \ UNIT_TEST(_name, _flags, bloblist_test)
Signature · 1 line
2.43.0
PATCH 3/21 bloblist: test: doc: Move into the common suite
In reply to Simon GlassThere is no particular need for bloblist to have its own test suite. Move it into the common suite instead.
Add the missing help for 'common' and update the docs.
---
doc/usage/cmd/ut.rst | 29 +++++++++++++++++++++------- test/cmd_ut.c | 6 +----- test/common/bloblist.c | 44 ++++++++++++++---------------------------- 3 files changed, 38 insertions(+), 41 deletions(-)
doc/usage/cmd/ut.rst +22 -7
@@ -70,7 +70,6 @@ List available unit-test suites:: Suites: all - execute all enabled tests addrmap - very basic test of addrmap command - bloblist - bloblist implementation bootstd - standard boot implementation compression - compressors and bootm decompression dm - driver model
@@ -89,8 +88,8 @@ List available unit-test suites:: Run one of the suites:: - => ut bloblist - Running 14 bloblist tests + => ut common + Running 21 common tests Test: bloblist_test_align: bloblist.c Test: bloblist_test_bad_blob: bloblist.c Test: bloblist_test_blob: bloblist.c
@@ -105,16 +104,32 @@ Run one of the suites:: Test: bloblist_test_resize_fail: bloblist.c Test: bloblist_test_resize_last: bloblist.c Test: bloblist_test_shrink: bloblist.c - Failures: 0 + Test: cli_ch_test: cread.c + Test: cread_test: cread.c + Test: dm_test_cyclic_running: cyclic.c + Test: test_autoboot: test_autoboot.c + Enter password "a" in 1 seconds to stop autoboot + Enter password "a" in 1 seconds to stop autoboot + Enter password "a" in 1 seconds to stop autoboot + Enter password "a" in 1 seconds to stop autoboot + Enter password "a" in 1 seconds to stop autoboot + Enter password "a" in 1 seconds to stop autoboot + Autoboot password unlock not successful + Test: test_event_base: event.c + Test: test_event_probe: event.c + Test: test_event_probe: event.c (flat tree) + Test: test_event_simple: event.c + Skipped: 2, Failures: 0 + => Run just a single test in a suite:: - => ut bloblist bloblist_test_grow + => ut common bloblist_test_grow Test: bloblist_test_grow: bloblist.c Failures: 0 Show information about tests:: => ut info - Test suites: 21 - Total tests: 642 + Test suites: 29 + Total tests: 806
test/cmd_ut.c +1 -5
@@ -113,8 +113,6 @@ static struct cmd_tbl cmd_ut_sub[] = {#ifdef CONFIG_SANDBOX U_BOOT_CMD_MKENT (compression,CONFIG_SYS_MAXARGS ,1 , do_ut_compression,"" ,"" ), -U_BOOT_CMD_MKENT (bloblist,CONFIG_SYS_MAXARGS ,1 , do_ut_bloblist, -"" ,"" ),U_BOOT_CMD_MKENT (bootm,CONFIG_SYS_MAXARGS ,1 , do_ut_bootm,"" ,"" ), #endif U_BOOT_CMD_MKENT(str, CONFIG_SYS_MAXARGS, 1, do_ut_str, "", ""),
@@ -198,15 +196,13 @@ U_BOOT_LONGHELP(ut,#ifdef CONFIG_CMD_BDI "\nbdinfo - bdinfo command"#endif -#ifdef CONFIG_SANDBOX - "\nbloblist - bloblist implementation" -#endif #ifdef CONFIG_BOOTSTD "\nbootstd - standard boot implementation"#endif #ifdef CONFIG_CMDLINE "\ncmd - test various commands" #endif +"\ncommon - tests for common/ directory" #ifdef CONFIG_SANDBOX "\ncompression - compressors and bootm decompression"#endif
test/common/bloblist.c +15 -29
134 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH 03/21] bloblist: test: doc: Move into the common suite
Quoted 6 lines · Simon Glass
There is no particular need for bloblist to have its own test suite. Move it into the common suite instead.
Add the missing help for 'common' and update the docs.
Signed-off-by Simon Glass <[email protected]>
This feels both like churn and weird. I would think "common" tests are for things that are kinda legacy and too catch-all to have their own subgroup.
Signature · 1 line
Tom
Re: [PATCH 03/21] bloblist: test: doc: Move into the common suite
Hi Tom,
Quoted 6 lines · Tom Rini
Quoted 3 lines · Simon Glass
There is no particular need for bloblist to have its own test suite. Move it into the common suite instead.
Quoted 7 lines
Quoted 3 lines
Add the missing help for 'common' and update the docs.
Signed-off-by Simon Glass <[email protected]>This feels both like churn and weird. I would think "common" tests are for things that are kinda legacy and too catch-all to have their own subgroup.
It's just chosen so that the test for common/ is in test/common - i.e. it makes it easier for people to find it.
BTW this series removes all tests from test/*.c and moves them into appropriate subdirs. Some of the tests are quite old so have just sat there all these years.
Regards,
Simon
Re: [PATCH 03/21] bloblist: test: doc: Move into the common suite
Quoted 11 lines · Simon Glass
Hi Tom,
Quoted 8 lines · Tom Rini
Quoted 5 lines · Simon Glass
There is no particular need for bloblist to have its own test suite. Move it into the common suite instead.
Add the missing help for 'common' and update the docs.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Simon Glass <[email protected]>This feels both like churn and weird. I would think "common" tests are for things that are kinda legacy and too catch-all to have their own subgroup.
It's just chosen so that the test for common/ is in test/common - i.e. it makes it easier for people to find it.
Then I really don't understand renaming bloblist from something descriptive to common which is not.
Quoted 3 lines
BTW this series removes all tests from test/*.c and moves them into appropriate subdirs. Some of the tests are quite old so have just sat there all these years.
This is good, yes. But perhaps needs a bit more thought then about how strong a mapping between filename/directory structure and test suite name there needs to be.
Signature · 1 line
Tom
Re: [PATCH 03/21] bloblist: test: doc: Move into the common suite
Hi Tom,
Quoted 19 lines · Tom Rini
Quoted 17 lines · Simon Glass
Hi Tom,
Quoted 13 lines · Tom Rini
Quoted 6 lines · Simon Glass
There is no particular need for bloblist to have its own test suite. Move it into the common suite instead.
Add the missing help for 'common' and update the docs.
Signed-off-by Simon Glass <[email protected]>This feels both like churn and weird. I would think "common" tests are for things that are kinda legacy and too catch-all to have their own subgroup.
Quoted 5 lines
Quoted 2 lines
It's just chosen so that the test for common/ is in test/common - i.e. it makes it easier for people to find it.
Then I really don't understand renaming bloblist from something descriptive to common which is not.
Old: test/bloblist.c
New: test/common/bloblist.c
It is only the directory that is changing.
Quoted 8 lines
Quoted 4 lines
BTW this series removes all tests from test/*.c and moves them into appropriate subdirs. Some of the tests are quite old so have just sat there all these years.
This is good, yes. But perhaps needs a bit more thought then about how strong a mapping between filename/directory structure and test suite name there needs to be.
OK so what do you suggest instead? This series was the result of my thought about this :-)
Regards,
Simon
Re: [PATCH 03/21] bloblist: test: doc: Move into the common suite
Quoted 25 lines · Simon Glass
Hi Tom,
Quoted 22 lines · Tom Rini
Quoted 19 lines · Simon Glass
Hi Tom,
Quoted 6 lines · Tom Rini
Quoted 3 lines · Simon Glass
There is no particular need for bloblist to have its own test suite. Move it into the common suite instead.
Quoted 7 lines
Quoted 3 lines
Add the missing help for 'common' and update the docs.
Signed-off-by Simon Glass <[email protected]>This feels both like churn and weird. I would think "common" tests are for things that are kinda legacy and too catch-all to have their own subgroup.
It's just chosen so that the test for common/ is in test/common - i.e. it makes it easier for people to find it.
Quoted 7 lines
Quoted 2 lines
Then I really don't understand renaming bloblist from something descriptive to common which is not.
Old:
test/bloblist.c
New:test/common/bloblist.cIt is only the directory that is changing.
Then some of the commit messages need to be reworked? It looks like it stops being "ut bloblist" and part of "ut common" and that's my concern.
Signature · 1 line
Tom
Re: [PATCH 03/21] bloblist: test: doc: Move into the common suite
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 28 lines · Simon Glass
Hi Tom,
Quoted 24 lines · Tom Rini
Quoted 11 lines · Simon Glass
Hi Tom,
Quoted 8 lines · Tom Rini
Quoted 5 lines · Simon Glass
There is no particular need for bloblist to have its own test suite. Move it into the common suite instead.
Add the missing help for 'common' and update the docs.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Simon Glass <[email protected]>This feels both like churn and weird. I would think "common" tests are for things that are kinda legacy and too catch-all to have their own subgroup.
It's just chosen so that the test for common/ is in test/common - i.e. it makes it easier for people to find it.
Then I really don't understand renaming bloblist from something descriptive to common which is not.
Quoted 7 lines
Quoted 4 lines
Old:
test/bloblist.c
New:test/common/bloblist.cIt is only the directory that is changing.
Then some of the commit messages need to be reworked? It looks like it stops being "ut bloblist" and part of "ut common" and that's my concern.
Oh I see...
I basically decided that there is no point in having a special suite for bloblist, and some other things. A better way to handle this would be to allow running tests which match a name, e.g. 'ut common bloblist', because we are adding way too many suites IMO.
Regards,
Simon
Re: [PATCH 03/21] bloblist: test: doc: Move into the common suite
Quoted 41 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 28 lines · Simon Glass
Hi Tom,
Quoted 24 lines · Tom Rini
Quoted 11 lines · Simon Glass
Hi Tom,
Quoted 8 lines · Tom Rini
Quoted 5 lines · Simon Glass
There is no particular need for bloblist to have its own test suite. Move it into the common suite instead.
Add the missing help for 'common' and update the docs.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Simon Glass <[email protected]>This feels both like churn and weird. I would think "common" tests are for things that are kinda legacy and too catch-all to have their own subgroup.
It's just chosen so that the test for common/ is in test/common - i.e. it makes it easier for people to find it.
Then I really don't understand renaming bloblist from something descriptive to common which is not.
Quoted 7 lines
Quoted 4 lines
Old:
test/bloblist.c
New:test/common/bloblist.cIt is only the directory that is changing.
Then some of the commit messages need to be reworked? It looks like it stops being "ut bloblist" and part of "ut common" and that's my concern.
Quoted 6 lines
Oh I see...
I basically decided that there is no point in having a special suite for bloblist, and some other things. A better way to handle this would be to allow running tests which match a name, e.g. 'ut common bloblist', because we are adding way too many suites IMO.
OK. It's not a big deal, yeah. I think the common use cases are "run everything" and "run this one test that failed while I debug it".
Signature · 1 line
Tom
PATCH 4/21 test: Drop test-trace.sh and common.sh
In reply to Simon GlassThe trace feature is now tested in CI so there is no need for these old script. Also they don't work. Drop them.
---
test/common.sh | 20 ------------- test/trace/test-trace.sh | 64 ---------------------------------------- 2 files changed, 84 deletions(-) delete mode 100644 test/common.sh delete mode 100755 test/trace/test-trace.sh
test/common.sh deleted +0 -20
@@ -1,20 +0,0 @@ -#!/bin/sh - -OUTPUT_DIR=sandbox - -fail() { - echo "Test failed: $1" - if [ -n ${tmp} ]; then - rm ${tmp} - fi - exit 1 -} - -build_uboot() { - echo "Build sandbox" - OPTS="O=${OUTPUT_DIR} $1" - NUM_CPUS=$(nproc) - echo ${OPTS} - make ${OPTS} sandbox_config - make ${OPTS} -s -j${NUM_CPUS} -}
test/trace/test-trace.sh deleted +0 -64
64 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 5/21 compression: test: Move test into lib
In reply to Simon GlassThis test doesn't belong at the top level. Move it into the lib/ directory, since that is where compression is implemented.
---
test/Makefile | 1 -
test/lib/Makefile | 3 +++
test/{ => lib}/compression.c | 0
3 files changed, 3 insertions(+), 1 deletion(-)
rename test/{ => lib}/compression.c (100%)test/Makefile +0 -1
@@ -8,7 +8,6 @@ obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o obj-$(CONFIG_$(XPL_)CMDLINE) += cmd/ obj-$(CONFIG_$(XPL_)CMDLINE) += cmd_ut.o obj-$(CONFIG_$(XPL_)CMDLINE) += command_ut.o -obj-$(CONFIG_$(XPL_)UT_COMPRESSION) += compression.o obj-y += dm/ obj-$(CONFIG_FUZZ) += fuzz/ ifndef CONFIG_SANDBOX_VPL
test/lib/Makefile +3 -0
@@ -2,6 +2,9 @@ # # (C) Copyright 2018 # Mario Six, Guntermann & Drunck GmbH, [email protected] + +obj-$(CONFIG_$(XPL_)UT_COMPRESSION) += compression.o + ifeq ($(CONFIG_XPL_BUILD),) obj-y += cmd_ut_lib.o obj-y += abuf.o
test/lib/compression.c renamed from test/compression.c +0 -0
Signature · 1 line
2.43.0
PATCH 6/21 compression: test: Move into the lib suite
In reply to Simon GlassThere is no particular need for compression to have its own test suite. Move it into the lib suite instead.
Add the missing help for 'common' and update the docs.
---
include/test/compression.h | 16 ---------------- test/cmd_ut.c | 5 ----- test/lib/compression.c | 39 ++++++++++++++------------------------ 3 files changed, 14 insertions(+), 46 deletions(-) delete mode 100644 include/test/compression.h
include/test/compression.h deleted +0 -16
@@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* -* Copyright (c) 2017 Google, Inc -* Written by Simon Glass <[email protected]> -*/ - -#ifndef __TEST_COMPRESSION_H__ -#define __TEST_COMPRESSION_H__ - -#include <test/test.h> - -/* Declare a new compression test */ -#define COMPRESSION_TEST (_name, _flags) \ - UNIT_TEST(_name, _flags, compression_test) - -#endif /* __TEST_ENV_H__ */
test/cmd_ut.c +0 -5
@@ -111,8 +111,6 @@ static struct cmd_tbl cmd_ut_sub[] = { "", ""),#endif #ifdef CONFIG_SANDBOX -U_BOOT_CMD_MKENT (compression,CONFIG_SYS_MAXARGS ,1 , do_ut_compression, -"" ,"" ),U_BOOT_CMD_MKENT (bootm,CONFIG_SYS_MAXARGS ,1 , do_ut_bootm,"" ,"" ), #endif U_BOOT_CMD_MKENT(str, CONFIG_SYS_MAXARGS, 1, do_ut_str, "", ""),
@@ -203,9 +201,6 @@ U_BOOT_LONGHELP(ut,"\ncmd - test various commands" #endif"\ncommon - tests for common/ directory" -#ifdef CONFIG_SANDBOX - "\ncompression - compressors and bootm decompression" -#endif #ifdef CONFIG_UT_DM "\ndm - driver model"#endif
test/lib/compression.c +14 -25
@@ -23,8 +23,7 @@#include <linux/lzo.h> #include <linux/zstd.h> -#include <test/compression.h> -#include <test/suites.h> +#include <test/lib.h> #include <test/ut.h> static const char plain[] =
@@ -471,40 +470,40 @@ static int compression_test_gzip(struct unit_test_state *uts)return run_test (uts,"gzip" , compress_using_gzip, uncompress_using_gzip); } -COMPRESSION_TEST (compression_test_gzip,0 ); +LIB_TEST (compression_test_gzip,0 );static int compression_test_bzip2 (struct unit_test_state *uts) {return run_test (uts,"bzip2" , compress_using_bzip2, uncompress_using_bzip2); } -COMPRESSION_TEST (compression_test_bzip2,0 ); +LIB_TEST (compression_test_bzip2,0 );static int compression_test_lzma (struct unit_test_state *uts) {return run_test (uts,"lzma" , compress_using_lzma, uncompress_using_lzma); } -COMPRESSION_TEST (compression_test_lzma,0 ); +LIB_TEST (compression_test_lzma,0 );static int compression_test_lzo (struct unit_test_state *uts) {return run_test (uts,"lzo" , compress_using_lzo, uncompress_using_lzo); } -COMPRESSION_TEST (compression_test_lzo,0 ); +LIB_TEST (compression_test_lzo,0 );static int compression_test_lz4 (struct unit_test_state *uts) {return run_test (uts,"lz4" , compress_using_lz4, uncompress_using_lz4); } -COMPRESSION_TEST (compression_test_lz4,0 ); +LIB_TEST (compression_test_lz4,0 );static int compression_test_zstd (struct unit_test_state *uts) {return run_test (uts,"zstd" , compress_using_zstd, uncompress_using_zstd); } -COMPRESSION_TEST (compression_test_zstd,0 ); +LIB_TEST (compression_test_zstd,0 ); static int compress_using_none(struct unit_test_state *uts, void *in, unsigned long in_size,
@@ -570,50 +569,40 @@ static int compression_test_bootm_gzip(struct unit_test_state *uts) {return run_bootm_test (uts,IH_COMP_GZIP , compress_using_gzip); } -COMPRESSION_TEST (compression_test_bootm_gzip,0 ); +LIB_TEST (compression_test_bootm_gzip,0 );static int compression_test_bootm_bzip2 (struct unit_test_state *uts) {return run_bootm_test (uts,IH_COMP_BZIP2 , compress_using_bzip2); } -COMPRESSION_TEST (compression_test_bootm_bzip2,0 ); +LIB_TEST (compression_test_bootm_bzip2,0 );static int compression_test_bootm_lzma (struct unit_test_state *uts) {return run_bootm_test (uts,IH_COMP_LZMA , compress_using_lzma); } -COMPRESSION_TEST (compression_test_bootm_lzma,0 ); +LIB_TEST (compression_test_bootm_lzma,0 );static int compression_test_bootm_lzo (struct unit_test_state *uts) {return run_bootm_test (uts,IH_COMP_LZO , compress_using_lzo); } -COMPRESSION_TEST (compression_test_bootm_lzo,0 ); +LIB_TEST (compression_test_bootm_lzo,0 );static int compression_test_bootm_lz4 (struct unit_test_state *uts) {return run_bootm_test (uts,IH_COMP_LZ4 , compress_using_lz4); } -COMPRESSION_TEST (compression_test_bootm_lz4,0 ); +LIB_TEST (compression_test_bootm_lz4,0 );static int compression_test_bootm_zstd (struct unit_test_state *uts) {return run_bootm_test (uts,IH_COMP_ZSTD , compress_using_zstd); } -COMPRESSION_TEST (compression_test_bootm_zstd,0 ); +LIB_TEST (compression_test_bootm_zstd,0 );static int compression_test_bootm_none (struct unit_test_state *uts) {return run_bootm_test (uts,IH_COMP_NONE , compress_using_none); } -COMPRESSION_TEST (compression_test_bootm_none,0 ); - -int do_ut_compression (struct cmd_tbl *cmdtp,int flag,int argc, -char *const argv[]) -{ -struct unit_test *tests =UNIT_TEST_SUITE_START (compression_test); -const int n_ents =UNIT_TEST_SUITE_COUNT (compression_test); - -return cmd_ut_category ("compression" ,"compression_test_" , - tests, n_ents, argc, argv); -} +LIB_TEST (compression_test_bootm_none,0 );
Signature · 1 line
2.43.0
PATCH 7/21 command_ut: test: Move test into lib
In reply to Simon GlassThis test doesn't belong at the top level. Move it into the lib/ directory, since that is where compression is implemented.
Rename it to just 'command', since it is obviously a unit test and the _ut suffix does not add much except to make it different from the names of other test files.
---
test/Makefile | 1 -
test/cmd/Makefile | 1 +
test/{command_ut.c => cmd/command.c} | 0
3 files changed, 1 insertion(+), 1 deletion(-)
rename test/{command_ut.c => cmd/command.c} (100%)test/Makefile +0 -1
@@ -7,7 +7,6 @@ obj-y += test-main.o obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o obj-$(CONFIG_$(XPL_)CMDLINE) += cmd/ obj-$(CONFIG_$(XPL_)CMDLINE) += cmd_ut.o -obj-$(CONFIG_$(XPL_)CMDLINE) += command_ut.o obj-y += dm/ obj-$(CONFIG_FUZZ) += fuzz/ ifndef CONFIG_SANDBOX_VPL
test/cmd/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-y += cmd_ut_cmd.o +obj-$(CONFIG_$(XPL_)CMDLINE) += command.o ifdef CONFIG_HUSH_PARSER obj-$(CONFIG_CONSOLE_RECORD) += test_echo.o endif
test/cmd/command.c renamed from test/command_ut.c +0 -0
Signature · 1 line
2.43.0
PATCH 8/21 command: test: Move into the cmd suite
In reply to Simon GlassThe command test was the very first test written in U-Boot, some 12 years ago. It predates the unit-test subsystem and was never converted over.
There is no particular need for the command test to have its own command. It is also confusing to have it separate from the normal test suites. At present this test is not run in CI.
Move it into the cmd suite instead, updating it to become a unit test. One of the checks is dropped to avoid an error.
---
test/cmd/command.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
test/cmd/command.c +13 -10
@@ -10,13 +10,14 @@#include <log.h> #include <string.h> #include <linux/errno.h> +#include <test/cmd.h> +#include <test/ut.h> static const char test_cmd[] ="setenv list 1\n setenv list ${list}2; " "setenv list ${list}3\0" "setenv list ${list}4" ; -static int do_ut_cmd (struct cmd_tbl *cmdtp,int flag,int argc, -char *const argv[]) +static int command_test (struct unit_test_state *uts) {char long_str[CONFIG_SYS_CBSIZE +42 ];
@@ -72,8 +73,12 @@ static int do_ut_cmd(struct cmd_tbl *cmdtp, int flag, int argc,assert (run_commandf ("'" ) ==1 );assert (run_commandf ("env %s %s" ,"delete -f" ,"list" ) ==0 ); -/* Expected: "Error: "list" not defined" */ -assert (run_commandf ("printenv list" ) ==1 ); +/* +* Expected: "## Error: "list" not defined" +* (disabled to avoid pytest bailing out) +* +* assert(run_commandf("printenv list") == 1); +*/ memset (long_str,'x' ,sizeof (long_str));assert (run_commandf ("Truncation case: %s" , long_str) == -ENOSPC );
@@ -93,12 +98,10 @@ static int do_ut_cmd(struct cmd_tbl *cmdtp, int flag, int argc,/* Clean up before exit */ run_command ("env default -f -a" ,0 ); +/* put back the FDT environment */ +ut_assertok (env_set ("from_fdt" ,"yes" )); +printf ("%s: Everything went swimmingly\n" , __func__);return 0 ; } - -U_BOOT_CMD ( - ut_cmd,5 ,1 , do_ut_cmd, -"Very basic test of command parsers" , -"" -); +CMD_TEST (command_test,0 );
Signature · 1 line
2.43.0
PATCH 9/21 test: Update command test to use unit-test functions
In reply to Simon GlassRather than enabled DEBUG and using assert(), use the unit-test functions now provided.
Drop a check that causes pytest to fail.
---
test/cmd/command.c | 63 +++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 31 deletions(-)
test/cmd/command.c +32 -31
@@ -26,16 +26,16 @@ static int command_test(struct unit_test_state *uts)/* commands separated by \n */ run_command_list ("setenv list 1\n setenv list ${list}1" ,-1 ,0 ); -assert (!strcmp ("11" ,env_get ("list" ))); +ut_assert (!strcmp ("11" ,env_get ("list" )));/* command followed by \n and nothing else */ run_command_list ("setenv list 1${list}\n" ,-1 ,0 ); -assert (!strcmp ("111" ,env_get ("list" ))); +ut_assert (!strcmp ("111" ,env_get ("list" )));/* a command string with \0 in it. Stuff after \0 should be ignored */ run_command ("setenv list" ,0 );run_command_list (test_cmd,sizeof (test_cmd),0 ); -assert (!strcmp ("123" ,env_get ("list" ))); +ut_assert (!strcmp ("123" ,env_get ("list" )));/* * a command list where we limit execution to only the first command
@@ -43,60 +43,61 @@ static int command_test(struct unit_test_state *uts)*/ run_command_list ("setenv list 1\n setenv list ${list}2; " "setenv list ${list}3" ,strlen ("setenv list 1" ),0 ); -assert (!strcmp ("1" ,env_get ("list" ))); +ut_assert (!strcmp ("1" ,env_get ("list" ))); -assert (run_command ("false" ,0 ) ==1 ); -assert (run_command ("echo" ,0 ) ==0 ); -assert (run_command_list ("false" ,-1 ,0 ) ==1 ); -assert (run_command_list ("echo" ,-1 ,0 ) ==0 ); +ut_asserteq (1 ,run_command ("false" ,0 )); +ut_assertok (run_command ("echo" ,0 )); +ut_asserteq (1 ,run_command_list ("false" ,-1 ,0 )); +ut_assertok (run_command_list ("echo" ,-1 ,0 ));#ifdef CONFIG_HUSH_PARSER run_command ("setenv foo 'setenv black 1\nsetenv adder 2'" ,0 );run_command ("run foo" ,0 ); -assert (env_get ("black" ) !=NULL ); -assert (!strcmp ("1" ,env_get ("black" ))); -assert (env_get ("adder" ) !=NULL ); -assert (!strcmp ("2" ,env_get ("adder" ))); +ut_assertnonnull (env_get ("black" )); +ut_asserteq (0 ,strcmp ("1" ,env_get ("black" ))); +ut_assertnonnull (env_get ("adder" )); +ut_asserteq (0 ,strcmp ("2" ,env_get ("adder" )));#endif -assert (run_command ("" ,0 ) ==0 ); -assert (run_command (" " ,0 ) ==0 ); +ut_assertok (run_command ("" ,0 )); +ut_assertok (run_command (" " ,0 )); -assert (run_command ("'" ,0 ) ==1 ); +ut_asserteq (1 ,run_command ("'" ,0 ));/* Variadic function test-cases */ #pragma GCC diagnostic push#pragma GCC diagnostic ignored "-Wformat-zero-length" -assert (run_commandf ("" ) ==0 ); +ut_assertok (run_commandf ("" ));#pragma GCC diagnostic pop -assert (run_commandf (" " ) ==0 ); -assert (run_commandf ("'" ) ==1 ); +ut_assertok (run_commandf (" " )); +ut_asserteq (1 ,run_commandf ("'" )); -assert (run_commandf ("env %s %s" ,"delete -f" ,"list" ) ==0 ); +ut_assertok (run_commandf ("env %s %s" ,"delete -f" ,"list" ));/* * Expected: "## Error: "list" not defined" * (disabled to avoid pytest bailing out) * -* assert(run_commandf("printenv list") == 1); +* ut_asserteq(1, run_commandf("printenv list")); */ memset (long_str,'x' ,sizeof (long_str)); -assert (run_commandf ("Truncation case: %s" , long_str) == -ENOSPC ); +ut_asserteq (-ENOSPC ,run_commandf ("Truncation case: %s" , long_str));if (IS_ENABLED (CONFIG_HUSH_PARSER )) { -assert (run_commandf ("env %s %s %s %s" ,"delete -f" ,"adder" , -"black" ,"foo" ) ==0 ); -assert (run_commandf ("setenv foo 'setenv %s 1\nsetenv %s 2'" , -"black" ,"adder" ) ==0 ); -run_command ("run foo" ,0 ); -assert (env_get ("black" )); -assert (!strcmp ("1" ,env_get ("black" ))); -assert (env_get ("adder" )); -assert (!strcmp ("2" ,env_get ("adder" ))); +ut_assertok (run_commandf ("env %s %s %s %s" ,"delete -f" , +"adder" ,"black" ,"foo" )); +ut_assertok (run_commandf ( +"setenv foo 'setenv %s 1\nsetenv %s 2'" , +"black" ,"adder" )); +ut_assertok (run_command ("run foo" ,0 )); +ut_assertnonnull (env_get ("black" )); +ut_asserteq (0 ,strcmp ("1" ,env_get ("black" ))); +ut_assertnonnull (env_get ("adder" )); +ut_asserteq (0 ,strcmp ("2" ,env_get ("adder" ))); }/* Clean up before exit */ -run_command ("env default -f -a" ,0 ); +ut_assertok (run_command ("env default -f -a" ,0 ));/* put back the FDT environment */ ut_assertok (env_set ("from_fdt" ,"yes" ));
Signature · 1 line
2.43.0
PATCH 10/21 bootm: test: Move test into boot
In reply to Simon GlassThis test doesn't belong at the top level. Move it into the boot/ directory, to match its implementation.
---
test/Makefile | 1 -
test/boot/Makefile | 1 +
test/{ => boot}/bootm.c | 0
3 files changed, 1 insertion(+), 1 deletion(-)
rename test/{ => boot}/bootm.c (100%)test/Makefile +0 -1
@@ -4,7 +4,6 @@ obj-y += test-main.o -obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o obj-$(CONFIG_$(XPL_)CMDLINE) += cmd/ obj-$(CONFIG_$(XPL_)CMDLINE) += cmd_ut.o obj-y += dm/
test/boot/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_EXPO) += expo.o obj-$(CONFIG_CEDIT) += cedit.o endif +obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o obj-$(CONFIG_MEASURED_BOOT) += measurement.o ifdef CONFIG_OF_LIVE
test/boot/bootm.c renamed from test/bootm.c +0 -0
Signature · 1 line
2.43.0
PATCH 11/21 test: Move print_ut test into common
In reply to Simon GlassThis test doesn't belong at the top level. Move it into the common/ directory, to match its implementation. Rename it to drop the unnecessary _ut suffix.
---
test/Makefile | 1 -
test/common/Makefile | 1 +
test/{print_ut.c => common/print.c} | 0
3 files changed, 1 insertion(+), 1 deletion(-)
rename test/{print_ut.c => common/print.c} (100%)test/Makefile +0 -1
@@ -14,7 +14,6 @@ endif ifneq ($(CONFIG_HUSH_PARSER),) obj-$(CONFIG_$(XPL_)CMDLINE) += hush/ endif -obj-$(CONFIG_$(XPL_)CMDLINE) += print_ut.o obj-$(CONFIG_$(XPL_)CMDLINE) += str_ut.o obj-$(CONFIG_UT_TIME) += time_ut.o obj-y += ut.o
test/common/Makefile +1 -0
@@ -7,3 +7,4 @@ endif obj-$(CONFIG_CYCLIC) += cyclic.o obj-$(CONFIG_EVENT_DYNAMIC) += event.o obj-y += cread.o +obj-$(CONFIG_$(XPL_)CMDLINE) += print.o
test/common/print.c renamed from test/print_ut.c +0 -0
Signature · 1 line
2.43.0
PATCH 12/21 test: Move print_ut into the common suite
In reply to Simon GlassThere is no particular need for bloblist to have its own test suite. Move it into the common suite instead.
---
test/cmd_ut.c | 2 -- test/common/print.c | 27 ++++++++------------------- 2 files changed, 8 insertions(+), 21 deletions(-)
test/cmd_ut.c +0 -2
@@ -99,7 +99,6 @@ static struct cmd_tbl cmd_ut_sub[] = { U_BOOT_CMD_MKENT(setexpr, CONFIG_SYS_MAXARGS, 1, do_ut_setexpr, "", ""),#endif -U_BOOT_CMD_MKENT (print,CONFIG_SYS_MAXARGS ,1 , do_ut_print,"" ,"" ),#ifdef CONFIG_UT_TIME U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""),#endif
@@ -235,7 +234,6 @@ U_BOOT_LONGHELP(ut,#ifdef CONFIG_CMD_PCI_MPS "\npci_mps - PCI Express Maximum Payload Size" #endif -"\nprint - printing things to the console" "\nsetexpr - setexpr command" #ifdef CONFIG_SANDBOX"\nstr - basic test of string functions"
test/common/print.c +8 -19
@@ -11,7 +11,7 @@#include <version_string.h> #include <stdio.h> #include <vsprintf.h> -#include <test/suites.h> +#include <test/common.h> #include <test/test.h> #include <test/ut.h>
@@ -20,9 +20,6 @@#define FAKE_BUILD_TAG "jenkins-u-boot-denx_uboot_dm-master-build-aarch64" \ "and a lot more text to come" -/* Declare a new print test */ -#define PRINT_TEST (_name, _flags) UNIT_TEST(_name, _flags, print_test) -#if CONFIG_IS_ENABLED (LIB_UUID )/* Test printing GUIDs */ static int print_guid (struct unit_test_state *uts)
@@ -59,7 +56,7 @@ static int print_guid(struct unit_test_state *uts) return 0; } -PRINT_TEST (print_guid,0 ); +COMMON_TEST (print_guid,0 );#endif #if CONFIG_IS_ENABLED (EFI_LOADER ) && !defined(API_BUILD )
@@ -95,7 +92,7 @@ static int print_efi_ut(struct unit_test_state *uts) return 0; } -PRINT_TEST (print_efi_ut,0 ); +COMMON_TEST (print_efi_ut,0 );#endif static int print_printf (struct unit_test_state *uts)
@@ -163,7 +160,7 @@ static int print_printf(struct unit_test_state *uts)return 0 ; } -PRINT_TEST (print_printf,0 ); +COMMON_TEST (print_printf,0 );static int print_display_buffer (struct unit_test_state *uts) {
@@ -238,7 +235,7 @@ static int print_display_buffer(struct unit_test_state *uts)return 0 ; } -PRINT_TEST (print_display_buffer,UTF_CONSOLE ); +COMMON_TEST (print_display_buffer,UTF_CONSOLE );static int print_hexdump_line (struct unit_test_state *uts) {
@@ -264,7 +261,7 @@ static int print_hexdump_line(struct unit_test_state *uts)return 0 ; } -PRINT_TEST (print_hexdump_line,UTF_CONSOLE ); +COMMON_TEST (print_hexdump_line,UTF_CONSOLE );static int print_do_hex_dump (struct unit_test_state *uts) {
@@ -350,7 +347,7 @@ static int print_do_hex_dump(struct unit_test_state *uts)return 0 ; } -PRINT_TEST (print_do_hex_dump,UTF_CONSOLE ); +COMMON_TEST (print_do_hex_dump,UTF_CONSOLE );static int snprint (struct unit_test_state *uts) {
@@ -376,12 +373,4 @@ static int snprint(struct unit_test_state *uts)ut_asserteq (8 , ret);return 0 ; } -PRINT_TEST (snprint,0 ); - -int do_ut_print (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) -{ -struct unit_test *tests =UNIT_TEST_SUITE_START (print_test); -const int n_ents =UNIT_TEST_SUITE_COUNT (print_test); - -return cmd_ut_category ("print" ,"print_" , tests, n_ents, argc, argv); -} +COMMON_TEST (snprint,0 );
Signature · 1 line
2.43.0
PATCH 13/21 test: Move str_ut test into lib
In reply to Simon GlassThis test doesn't belong at the top level. Move it into the lib/ directory, to match (most of) its implementation. Rename it to drop the unnecessary _ut suffix.
---
test/Makefile | 1 -
test/lib/Makefile | 1 +
test/{str_ut.c => lib/str.c} | 0
3 files changed, 1 insertion(+), 1 deletion(-)
rename test/{str_ut.c => lib/str.c} (100%)test/Makefile +0 -1
@@ -14,7 +14,6 @@ endif ifneq ($(CONFIG_HUSH_PARSER),) obj-$(CONFIG_$(XPL_)CMDLINE) += hush/ endif -obj-$(CONFIG_$(XPL_)CMDLINE) += str_ut.o obj-$(CONFIG_UT_TIME) += time_ut.o obj-y += ut.o
test/lib/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-y += lmb.o obj-y += longjmp.o obj-$(CONFIG_CONSOLE_RECORD) += test_print.o obj-$(CONFIG_SSCANF) += sscanf.o +obj-$(CONFIG_$(XPL_)CMDLINE) += str.o obj-y += string.o obj-y += strlcat.o obj-$(CONFIG_ERRNO_STR) += test_errno_str.o
test/lib/str.c renamed from test/str_ut.c +0 -0
Signature · 1 line
2.43.0
PATCH 14/21 str: test: Move into the lib suite
In reply to Simon GlassThere is no particular need for the str tests to have their own test suite. Move them into the lib suite instead.
---
test/cmd_ut.c | 4 ---- test/lib/str.c | 31 ++++++++++--------------------- 2 files changed, 10 insertions(+), 25 deletions(-)
test/cmd_ut.c +0 -4
@@ -112,7 +112,6 @@ static struct cmd_tbl cmd_ut_sub[] = {#ifdef CONFIG_SANDBOX U_BOOT_CMD_MKENT(bootm, CONFIG_SYS_MAXARGS, 1, do_ut_bootm, "", ""),#endif -U_BOOT_CMD_MKENT (str,CONFIG_SYS_MAXARGS ,1 , do_ut_str,"" ,"" ),#ifdef CONFIG_CMD_ADDRMAP U_BOOT_CMD_MKENT(addrmap, CONFIG_SYS_MAXARGS, 1, do_ut_addrmap, "", ""),#endif
@@ -235,9 +234,6 @@ U_BOOT_LONGHELP(ut,"\npci_mps - PCI Express Maximum Payload Size" #endif"\nsetexpr - setexpr command" -#ifdef CONFIG_SANDBOX - "\nstr - basic test of string functions" -#endif #ifdef CONFIG_CMD_SEAMA "\nseama - seama command parameters loading and decoding"#endif
test/lib/str.c +10 -21
@@ -4,7 +4,7 @@*/ #include <vsprintf.h> -#include <test/suites.h> +#include <test/lib.h> #include <test/test.h> #include <test/ut.h>
@@ -19,9 +19,6 @@ static const char str5[] = "0x9876543210the last time I was deloused";static const char str6[] ="0778octal is seldom used" ;static const char str7[] ="707it is a piece of computing history" ; -/* Declare a new str test */ -#define STR_TEST (_name, _flags) UNIT_TEST(_name, _flags, str_test) -static int str_upper (struct unit_test_state *uts) {char out[TEST_STR_SIZE ];
@@ -58,7 +55,7 @@ static int str_upper(struct unit_test_state *uts)return 0 ; } -STR_TEST (str_upper,0 ); +LIB_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)
@@ -112,7 +109,7 @@ static int str_simple_strtoul(struct unit_test_state *uts)return 0 ; } -STR_TEST (str_simple_strtoul,0 ); +LIB_TEST (str_simple_strtoul,0 ); static int run_strtoull(struct unit_test_state *uts, const char *str, int base, unsigned long long expect_val, int expect_endp_offset,
@@ -175,7 +172,7 @@ static int str_simple_strtoull(struct unit_test_state *uts)return 0 ; } -STR_TEST (str_simple_strtoull,0 ); +LIB_TEST (str_simple_strtoull,0 );static int str_hextoul (struct unit_test_state *uts) {
@@ -187,7 +184,7 @@ static int str_hextoul(struct unit_test_state *uts)return 0 ; } -STR_TEST (str_hextoul,0 ); +LIB_TEST (str_hextoul,0 );static int str_dectoul (struct unit_test_state *uts) {
@@ -199,7 +196,7 @@ static int str_dectoul(struct unit_test_state *uts)return 0 ; } -STR_TEST (str_dectoul,0 ); +LIB_TEST (str_dectoul,0 );static int str_itoa (struct unit_test_state *uts) {
@@ -219,7 +216,7 @@ static int str_itoa(struct unit_test_state *uts)return 0 ; } -STR_TEST (str_itoa,0 ); +LIB_TEST (str_itoa,0 );static int str_xtoa (struct unit_test_state *uts) {
@@ -239,7 +236,7 @@ static int str_xtoa(struct unit_test_state *uts)return 0 ; } -STR_TEST (str_xtoa,0 ); +LIB_TEST (str_xtoa,0 );static int str_trailing (struct unit_test_state *uts) {
@@ -271,7 +268,7 @@ static int str_trailing(struct unit_test_state *uts)return 0 ; } -STR_TEST (str_trailing,0 ); +LIB_TEST (str_trailing,0 );static int test_str_to_list (struct unit_test_state *uts) {
@@ -351,12 +348,4 @@ static int test_str_to_list(struct unit_test_state *uts)return 0 ; } -STR_TEST (test_str_to_list,0 ); - -int do_ut_str (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) -{ -struct unit_test *tests =UNIT_TEST_SUITE_START (str_test); -const int n_ents =UNIT_TEST_SUITE_COUNT (str_test); - -return cmd_ut_category ("str" ,"str_" , tests, n_ents, argc, argv); -} +LIB_TEST (test_str_to_list,0 );
Signature · 1 line
2.43.0
PATCH 15/21 test: Move unicode_ut test into lib
In reply to Simon GlassThis test doesn't belong at the top level. Move it into the lib/ directory, to match its implementation. Rename it to drop the unnecessary _ut suffix.
---
test/Makefile | 1 -
test/lib/Makefile | 1 +
test/{unicode_ut.c => lib/unicode.c} | 0
3 files changed, 1 insertion(+), 1 deletion(-)
rename test/{unicode_ut.c => lib/unicode.c} (100%)test/Makefile +0 -1
@@ -21,7 +21,6 @@ ifeq ($(CONFIG_XPL_BUILD),) obj-y += boot/ obj-$(CONFIG_UNIT_TEST) += common/ obj-y += log/ -obj-$(CONFIG_$(XPL_)UT_UNICODE) += unicode_ut.o else obj-$(CONFIG_SPL_UT_LOAD) += image/ endif
test/lib/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_AES) += test_aes.o obj-$(CONFIG_GETOPT) += getopt.o obj-$(CONFIG_CRC8) += test_crc8.o obj-$(CONFIG_UT_LIB_CRYPT) += test_crypt.o +obj-$(CONFIG_$(XPL_)UT_UNICODE) += unicode.o obj-$(CONFIG_LIB_UUID) += uuid.o else obj-$(CONFIG_SANDBOX) += kconfig_spl.o
test/lib/unicode.c renamed from test/unicode_ut.c +0 -0
Signature · 1 line
2.43.0
PATCH 16/21 test: Move unicode tests into the lib suite
In reply to Simon GlassThere is no particular need for the unicode tests to have their own test suite. Move them into the lib suite instead.
---
test/cmd_ut.c | 7 ----- test/lib/unicode.c | 70 +++++++++++++++++++--------------------------- 2 files changed, 29 insertions(+), 48 deletions(-)
test/cmd_ut.c +0 -7
@@ -102,9 +102,6 @@ static struct cmd_tbl cmd_ut_sub[] = {#ifdef CONFIG_UT_TIME U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""),#endif -#if CONFIG_IS_ENABLED (UT_UNICODE ) && !defined(API_BUILD ) - U_BOOT_CMD_MKENT(unicode, CONFIG_SYS_MAXARGS, 1, do_ut_unicode, "", ""), -#endif #ifdef CONFIG_MEASURED_BOOT U_BOOT_CMD_MKENT (measurement,CONFIG_SYS_MAXARGS ,1 , do_ut_measurement, "", ""),
@@ -239,10 +236,6 @@ U_BOOT_LONGHELP(ut,#endif #ifdef CONFIG_UT_TIME "\ntime - very basic test of time functions" -#endif -#if defined(CONFIG_UT_UNICODE ) && \ - !defined(CONFIG_XPL_BUILD ) && !defined(API_BUILD ) -"\nunicode - Unicode functions" #endif );
test/lib/unicode.c +29 -41
244 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 17/21 test: Move time_ut test into lib
In reply to Simon GlassThis test doesn't belong at the top level. Move it into the lib/ directory, to match its implementation. Rename it to drop the unnecessary _ut suffix.
---
test/Makefile | 1 -
test/lib/Makefile | 1 +
test/{time_ut.c => lib/time.c} | 0
3 files changed, 1 insertion(+), 1 deletion(-)
rename test/{time_ut.c => lib/time.c} (100%)test/Makefile +0 -1
@@ -14,7 +14,6 @@ endif ifneq ($(CONFIG_HUSH_PARSER),) obj-$(CONFIG_$(XPL_)CMDLINE) += hush/ endif -obj-$(CONFIG_UT_TIME) += time_ut.o obj-y += ut.o ifeq ($(CONFIG_XPL_BUILD),)
test/lib/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_AES) += test_aes.o obj-$(CONFIG_GETOPT) += getopt.o obj-$(CONFIG_CRC8) += test_crc8.o obj-$(CONFIG_UT_LIB_CRYPT) += test_crypt.o +obj-$(CONFIG_UT_TIME) += time.o obj-$(CONFIG_$(XPL_)UT_UNICODE) += unicode.o obj-$(CONFIG_LIB_UUID) += uuid.o else
test/lib/time.c renamed from test/time_ut.c +0 -0
Signature · 1 line
2.43.0
PATCH 18/21 test: Move time tests into the lib suite
In reply to Simon GlassThere is no particular need for the time tests to have their own test command. Move them into the lib suite instead.
Update the test functions to match the normal unit-test signature.
---
test/cmd_ut.c | 6 ------ test/lib/time.c | 29 ++++++++++------------------- 2 files changed, 10 insertions(+), 25 deletions(-)
test/cmd_ut.c +0 -6
@@ -99,9 +99,6 @@ static struct cmd_tbl cmd_ut_sub[] = { U_BOOT_CMD_MKENT(setexpr, CONFIG_SYS_MAXARGS, 1, do_ut_setexpr, "", ""),#endif -#ifdef CONFIG_UT_TIME - U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""), -#endif #ifdef CONFIG_MEASURED_BOOT U_BOOT_CMD_MKENT (measurement,CONFIG_SYS_MAXARGS ,1 , do_ut_measurement, "", ""),
@@ -233,9 +230,6 @@ U_BOOT_LONGHELP(ut,"\nsetexpr - setexpr command" #ifdef CONFIG_CMD_SEAMA"\nseama - seama command parameters loading and decoding" -#endif -#ifdef CONFIG_UT_TIME -"\ntime - very basic test of time functions" #endif );
test/lib/time.c +10 -19
@@ -4,12 +4,13 @@* Written by Simon Glass <[email protected]> */ -#include <command.h> #include <errno.h> #include <time.h> #include <linux/delay.h> +#include <test/lib.h> +#include <test/ut.h> -static int test_get_timer (void ) +static int test_get_timer (struct unit_test_state *uts) {ulong base, start, next, diff;int iter;
@@ -42,8 +43,9 @@ static int test_get_timer(void)return 0 ; } +LIB_TEST (test_get_timer,0 ); -static int test_timer_get_us (void ) +static int test_timer_get_us (struct unit_test_state *uts) {ulong prev, next, min =1000000 ;long delta;
@@ -76,8 +78,9 @@ static int test_timer_get_us(void)return 0 ; } +LIB_TEST (test_timer_get_us,0 ); -static int test_time_comparison (void ) +static int test_time_comparison (struct unit_test_state *uts) {ulong start_us, end_us, delta_us;long error;
@@ -97,8 +100,9 @@ static int test_time_comparison(void)return 0 ; } +LIB_TEST (test_time_comparison,0 ); -static int test_udelay (void ) +static int test_udelay (struct unit_test_state *uts) {long error;ulong start, delta;
@@ -116,17 +120,4 @@ static int test_udelay(void)return 0 ; } - -int do_ut_time (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) -{ -int ret =0 ; - - ret |=test_get_timer (); - ret |=test_timer_get_us (); - ret |=test_time_comparison (); - ret |=test_udelay (); - -printf ("Test %s\n" , ret ?"failed" :"passed" ); - -return ret ?CMD_RET_FAILURE :CMD_RET_SUCCESS ; -} +LIB_TEST (test_udelay,0 );
Signature · 1 line
2.43.0
PATCH 19/21 test: Update time tests to use unit-test asserts
In reply to Simon GlassRather than returning various error codes, use assertions to check that the test passes.
---
test/lib/time.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-)
test/lib/time.c +7 -24
@@ -22,11 +22,7 @@ static int test_get_timer(struct unit_test_state *uts) next =get_timer (0 ); }while (start == next); -if (start +1 != next) { -printf ("%s: iter=%d, start=%lu, next=%lu, expected a difference of 1\n" , - __func__, iter, start, next); -return -EINVAL ; - } +ut_asserteq (start +1 , next); start++; }
@@ -35,11 +31,7 @@ static int test_get_timer(struct unit_test_state *uts)* an extra millisecond may have passed. */ diff =get_timer (base); -if (diff != iter && diff != iter +1 ) { -printf ("%s: expected get_timer(base) to match elapsed time: diff=%lu, expected=%d\n" , - __func__, diff, iter); -return -EINVAL ; - } +ut_assert (diff == iter || diff == iter +1 );return 0 ; }
@@ -57,11 +49,8 @@ static int test_timer_get_us(struct unit_test_state *uts) next =timer_get_us ();if (next != prev) { delta = next - prev; -if (delta <0 ) { -printf ("%s: timer_get_us() went backwards from %lu to %lu\n" , - __func__, prev, next); -return -EINVAL ; - }else if (delta !=0 ) { +ut_assert (delta >=0 ); +if (delta) {if (delta < min) min = delta; prev = next;
@@ -70,11 +59,7 @@ static int test_timer_get_us(struct unit_test_state *uts) } } -if (min !=1 ) { -printf ("%s: Minimum microsecond delta should be 1 but is %lu\n" , - __func__, min); -return -EINVAL ; - } +ut_asserteq (1 , min);return 0 ; }
@@ -95,8 +80,7 @@ static int test_time_comparison(struct unit_test_state *uts) error = delta_us -1000000 ;printf ("%s: Microsecond time for 1 second: %lu, error = %ld\n" , __func__, delta_us, error); -if (abs (error) >1000 ) -return -EINVAL ; +ut_assert (abs (error) <=1000 );return 0 ; }
@@ -115,8 +99,7 @@ static int test_udelay(struct unit_test_state *uts) error = delta -1000 ;printf ("%s: Delay time for 1000 udelay(1000): %lu ms, error = %ld\n" , __func__, delta, error); -if (abs (error) >100 ) -return -EINVAL ; +ut_assert (abs (error) <=100 );return 0 ; }
Signature · 1 line
2.43.0
PATCH 20/21 test: Correct display of failing test
In reply to Simon GlassThis should show the test name, not the selected name, since the user may be running all tests, in which case 'select_name' is NULL
Fix it.
---
test/test-main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
test/test-main.c +1 -1
@@ -622,7 +622,7 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix,for (i =0 ; i < uts->runs_per_test; i++) ret =ut_run_test_live_flat (uts, test);if (uts->fail_count != old_fail_count) { -printf ("Test %s failed %d times\n" , select_name, +printf ("Test %s failed %d times\n" , test_name, uts->fail_count - old_fail_count); } found++;
Signature · 1 line
2.43.0
PATCH 21/21 test: Quote test names
In reply to Simon GlassWhen mentioning a test name, add single quotes to make it easier to see.
---
test/test-main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
test/test-main.c +4 -4
@@ -594,14 +594,14 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix,*/ len =strlen (test_name);if (len <6 ||strcmp (test_name + len -6 ,"_norun" )) { -printf ("Test %s is manual so must have a name ending in _norun\n" , +printf ("Test '%s' is manual so must have a name ending in _norun\n" , test_name); uts->fail_count++;return -EBADF ; }if (!uts->force_run) {if (select_name) { -printf ("Test %s skipped as it is manual (use -f to run it)\n" , +printf ("Test '%s' skipped as it is manual (use -f to run it)\n" , test_name); }continue ;
@@ -612,7 +612,7 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix,if (one && upto == pos) { ret =ut_run_test_live_flat (uts, one);if (uts->fail_count != old_fail_count) { -printf ("Test %s failed %d times (position %d)\n" , +printf ("Test '%s' failed %d times (position %d)\n" , one->name, uts->fail_count - old_fail_count, pos); }
@@ -622,7 +622,7 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix,for (i =0 ; i < uts->runs_per_test; i++) ret =ut_run_test_live_flat (uts, test);if (uts->fail_count != old_fail_count) { -printf ("Test %s failed %d times\n" , test_name, +printf ("Test '%s' failed %d times\n" , test_name, uts->fail_count - old_fail_count); } found++;
Signature · 1 line
2.43.0