* [PATCH 01/21] bloblist: test: Move test into common
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-11-01 21:46 ` Tom Rini
2024-10-28 12:41 ` [PATCH 02/21] bloblist: test: Drop global_data declarations Simon Glass
` (19 subsequent siblings)
20 siblings, 1 reply; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Simon Glass, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Raymond Mao, Tom Rini
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.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
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%)
diff --git a/test/Makefile b/test/Makefile
index 145c952d2c3..2beff431899 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -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
diff --git a/test/common/Makefile b/test/common/Makefile
index 12c65f8c951..b6bff9201ec 100644
--- a/test/common/Makefile
+++ b/test/common/Makefile
@@ -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
diff --git a/test/bloblist.c b/test/common/bloblist.c
similarity index 100%
rename from test/bloblist.c
rename to test/common/bloblist.c
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 01/21] bloblist: test: Move test into common
2024-10-28 12:41 ` [PATCH 01/21] bloblist: test: Move test into common Simon Glass
@ 2024-11-01 21:46 ` Tom Rini
2024-11-02 16:32 ` Simon Glass
0 siblings, 1 reply; 31+ messages in thread
From: Tom Rini @ 2024-11-01 21:46 UTC (permalink / raw)
To: Simon Glass
Cc: U-Boot Mailing List, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Raymond Mao
[-- Attachment #1: Type: text/plain, Size: 2194 bytes --]
On Mon, Oct 28, 2024 at 01:41:06PM +0100, Simon Glass wrote:
> 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.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> 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 ============================
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH 01/21] bloblist: test: Move test into common
2024-11-01 21:46 ` Tom Rini
@ 2024-11-02 16:32 ` Simon Glass
0 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-11-02 16:32 UTC (permalink / raw)
To: Tom Rini
Cc: U-Boot Mailing List, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Raymond Mao
Hi Tom,
On Fri, 1 Nov 2024 at 22:46, Tom Rini <trini@konsulko.com> wrote:
>
> On Mon, Oct 28, 2024 at 01:41:06PM +0100, Simon Glass wrote:
>
> > 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.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > 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 ============================
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
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 02/21] bloblist: test: Drop global_data declarations
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
2024-10-28 12:41 ` [PATCH 01/21] bloblist: test: Move test into common Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 03/21] bloblist: test: doc: Move into the common suite Simon Glass
` (18 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Simon Glass, Ilias Apalodimas, Raymond Mao, Tom Rini
This pointer is not used any more, so drop the declarations.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
test/common/bloblist.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/test/common/bloblist.c b/test/common/bloblist.c
index fd85c7ab79e..7b90fa7f352 100644
--- a/test/common/bloblist.c
+++ b/test/common/bloblist.c
@@ -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)
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 03/21] bloblist: test: doc: Move into the common suite
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
2024-10-28 12:41 ` [PATCH 01/21] bloblist: test: Move test into common Simon Glass
2024-10-28 12:41 ` [PATCH 02/21] bloblist: test: Drop global_data declarations Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 19:33 ` Tom Rini
2024-10-28 12:41 ` [PATCH 04/21] test: Drop test-trace.sh and common.sh Simon Glass
` (17 subsequent siblings)
20 siblings, 1 reply; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Simon Glass, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Raymond Mao, Tom Rini
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 <sjg@chromium.org>
---
doc/usage/cmd/ut.rst | 29 +++++++++++++++++++++-------
test/cmd_ut.c | 6 +-----
test/common/bloblist.c | 44 ++++++++++++++----------------------------
3 files changed, 38 insertions(+), 41 deletions(-)
diff --git a/doc/usage/cmd/ut.rst b/doc/usage/cmd/ut.rst
index afeafa824d6..cadabb964e7 100644
--- a/doc/usage/cmd/ut.rst
+++ b/doc/usage/cmd/ut.rst
@@ -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
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 53fddebd49d..cba97725f76 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -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
diff --git a/test/common/bloblist.c b/test/common/bloblist.c
index 7b90fa7f352..dbd174299fd 100644
--- a/test/common/bloblist.c
+++ b/test/common/bloblist.c
@@ -6,14 +6,10 @@
#include <bloblist.h>
#include <log.h>
#include <mapmem.h>
-#include <test/suites.h>
+#include <test/common.h>
#include <test/test.h>
#include <test/ut.h>
-/* Declare a new bloblist test */
-#define BLOBLIST_TEST(_name, _flags) \
- UNIT_TEST(_name, _flags, bloblist_test)
-
enum {
TEST_TAG = BLOBLISTT_U_BOOT_SPL_HANDOFF,
TEST_TAG2 = BLOBLISTT_VBOOT_CTX,
@@ -91,7 +87,7 @@ static int bloblist_test_init(struct unit_test_state *uts)
return 1;
}
-BLOBLIST_TEST(bloblist_test_init, 0);
+COMMON_TEST(bloblist_test_init, 0);
static int bloblist_test_blob(struct unit_test_state *uts)
{
@@ -131,7 +127,7 @@ static int bloblist_test_blob(struct unit_test_state *uts)
return 0;
}
-BLOBLIST_TEST(bloblist_test_blob, 0);
+COMMON_TEST(bloblist_test_blob, 0);
/* Check bloblist_ensure_size_ret() */
static int bloblist_test_blob_ensure(struct unit_test_state *uts)
@@ -165,7 +161,7 @@ static int bloblist_test_blob_ensure(struct unit_test_state *uts)
return 0;
}
-BLOBLIST_TEST(bloblist_test_blob_ensure, 0);
+COMMON_TEST(bloblist_test_blob_ensure, 0);
static int bloblist_test_bad_blob(struct unit_test_state *uts)
{
@@ -181,7 +177,7 @@ static int bloblist_test_bad_blob(struct unit_test_state *uts)
return 0;
}
-BLOBLIST_TEST(bloblist_test_bad_blob, 0);
+COMMON_TEST(bloblist_test_bad_blob, 0);
static int bloblist_test_checksum(struct unit_test_state *uts)
{
@@ -254,7 +250,7 @@ static int bloblist_test_checksum(struct unit_test_state *uts)
return 0;
}
-BLOBLIST_TEST(bloblist_test_checksum, 0);
+COMMON_TEST(bloblist_test_checksum, 0);
/* Test the 'bloblist info' command */
static int bloblist_test_cmd_info(struct unit_test_state *uts)
@@ -275,7 +271,7 @@ static int bloblist_test_cmd_info(struct unit_test_state *uts)
return 0;
}
-BLOBLIST_TEST(bloblist_test_cmd_info, UTF_CONSOLE);
+COMMON_TEST(bloblist_test_cmd_info, UTF_CONSOLE);
/* Test the 'bloblist list' command */
static int bloblist_test_cmd_list(struct unit_test_state *uts)
@@ -297,7 +293,7 @@ static int bloblist_test_cmd_list(struct unit_test_state *uts)
return 0;
}
-BLOBLIST_TEST(bloblist_test_cmd_list, UTF_CONSOLE);
+COMMON_TEST(bloblist_test_cmd_list, UTF_CONSOLE);
/* Test alignment of bloblist blobs */
static int bloblist_test_align(struct unit_test_state *uts)
@@ -355,7 +351,7 @@ static int bloblist_test_align(struct unit_test_state *uts)
return 0;
}
-BLOBLIST_TEST(bloblist_test_align, 0);
+COMMON_TEST(bloblist_test_align, 0);
/* Test relocation of a bloblist */
static int bloblist_test_reloc(struct unit_test_state *uts)
@@ -389,7 +385,7 @@ static int bloblist_test_reloc(struct unit_test_state *uts)
return 0;
}
-BLOBLIST_TEST(bloblist_test_reloc, 0);
+COMMON_TEST(bloblist_test_reloc, 0);
/* Test expansion of a blob */
static int bloblist_test_grow(struct unit_test_state *uts)
@@ -442,7 +438,7 @@ static int bloblist_test_grow(struct unit_test_state *uts)
return 0;
}
-BLOBLIST_TEST(bloblist_test_grow, 0);
+COMMON_TEST(bloblist_test_grow, 0);
/* Test shrinking of a blob */
static int bloblist_test_shrink(struct unit_test_state *uts)
@@ -492,7 +488,7 @@ static int bloblist_test_shrink(struct unit_test_state *uts)
return 0;
}
-BLOBLIST_TEST(bloblist_test_shrink, 0);
+COMMON_TEST(bloblist_test_shrink, 0);
/* Test failing to adjust a blob size */
static int bloblist_test_resize_fail(struct unit_test_state *uts)
@@ -527,7 +523,7 @@ static int bloblist_test_resize_fail(struct unit_test_state *uts)
return 0;
}
-BLOBLIST_TEST(bloblist_test_resize_fail, 0);
+COMMON_TEST(bloblist_test_resize_fail, 0);
/* Test expanding the last blob in a bloblist */
static int bloblist_test_resize_last(struct unit_test_state *uts)
@@ -578,7 +574,7 @@ static int bloblist_test_resize_last(struct unit_test_state *uts)
return 0;
}
-BLOBLIST_TEST(bloblist_test_resize_last, 0);
+COMMON_TEST(bloblist_test_resize_last, 0);
/* Check a completely full bloblist */
static int bloblist_test_blob_maxsize(struct unit_test_state *uts)
@@ -601,14 +597,4 @@ static int bloblist_test_blob_maxsize(struct unit_test_state *uts)
return 0;
}
-BLOBLIST_TEST(bloblist_test_blob_maxsize, 0);
-
-int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[])
-{
- struct unit_test *tests = UNIT_TEST_SUITE_START(bloblist_test);
- const int n_ents = UNIT_TEST_SUITE_COUNT(bloblist_test);
-
- return cmd_ut_category("bloblist", "bloblist_test_",
- tests, n_ents, argc, argv);
-}
+COMMON_TEST(bloblist_test_blob_maxsize, 0);
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 03/21] bloblist: test: doc: Move into the common suite
2024-10-28 12:41 ` [PATCH 03/21] bloblist: test: doc: Move into the common suite Simon Glass
@ 2024-10-28 19:33 ` Tom Rini
2024-10-29 15:45 ` Simon Glass
0 siblings, 1 reply; 31+ messages in thread
From: Tom Rini @ 2024-10-28 19:33 UTC (permalink / raw)
To: Simon Glass
Cc: U-Boot Mailing List, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Raymond Mao
[-- Attachment #1: Type: text/plain, Size: 460 bytes --]
On Mon, Oct 28, 2024 at 01:41:08PM +0100, Simon Glass wrote:
> 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 <sjg@chromium.org>
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.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 03/21] bloblist: test: doc: Move into the common suite
2024-10-28 19:33 ` Tom Rini
@ 2024-10-29 15:45 ` Simon Glass
2024-10-29 16:36 ` Tom Rini
0 siblings, 1 reply; 31+ messages in thread
From: Simon Glass @ 2024-10-29 15:45 UTC (permalink / raw)
To: Tom Rini
Cc: U-Boot Mailing List, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Raymond Mao
Hi Tom,
On Mon, 28 Oct 2024 at 20:33, Tom Rini <trini@konsulko.com> wrote:
>
> On Mon, Oct 28, 2024 at 01:41:08PM +0100, Simon Glass wrote:
>
> > 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 <sjg@chromium.org>
>
> 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
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 03/21] bloblist: test: doc: Move into the common suite
2024-10-29 15:45 ` Simon Glass
@ 2024-10-29 16:36 ` Tom Rini
2024-10-31 18:00 ` Simon Glass
0 siblings, 1 reply; 31+ messages in thread
From: Tom Rini @ 2024-10-29 16:36 UTC (permalink / raw)
To: Simon Glass
Cc: U-Boot Mailing List, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Raymond Mao
[-- Attachment #1: Type: text/plain, Size: 1224 bytes --]
On Tue, Oct 29, 2024 at 04:45:40PM +0100, Simon Glass wrote:
> Hi Tom,
>
> On Mon, 28 Oct 2024 at 20:33, Tom Rini <trini@konsulko.com> wrote:
> >
> > On Mon, Oct 28, 2024 at 01:41:08PM +0100, Simon Glass wrote:
> >
> > > 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 <sjg@chromium.org>
> >
> > 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.
> 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.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 03/21] bloblist: test: doc: Move into the common suite
2024-10-29 16:36 ` Tom Rini
@ 2024-10-31 18:00 ` Simon Glass
2024-10-31 18:10 ` Tom Rini
0 siblings, 1 reply; 31+ messages in thread
From: Simon Glass @ 2024-10-31 18:00 UTC (permalink / raw)
To: Tom Rini
Cc: U-Boot Mailing List, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Raymond Mao
Hi Tom,
On Tue, 29 Oct 2024 at 17:36, Tom Rini <trini@konsulko.com> wrote:
>
> On Tue, Oct 29, 2024 at 04:45:40PM +0100, Simon Glass wrote:
> > Hi Tom,
> >
> > On Mon, 28 Oct 2024 at 20:33, Tom Rini <trini@konsulko.com> wrote:
> > >
> > > On Mon, Oct 28, 2024 at 01:41:08PM +0100, Simon Glass wrote:
> > >
> > > > 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 <sjg@chromium.org>
> > >
> > > 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.
Old: test/bloblist.c
New: test/common/bloblist.c
It is only the directory that is changing.
>
> > 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
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 03/21] bloblist: test: doc: Move into the common suite
2024-10-31 18:00 ` Simon Glass
@ 2024-10-31 18:10 ` Tom Rini
2024-11-01 15:32 ` Simon Glass
0 siblings, 1 reply; 31+ messages in thread
From: Tom Rini @ 2024-10-31 18:10 UTC (permalink / raw)
To: Simon Glass
Cc: U-Boot Mailing List, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Raymond Mao
[-- Attachment #1: Type: text/plain, Size: 1381 bytes --]
On Thu, Oct 31, 2024 at 07:00:41PM +0100, Simon Glass wrote:
> Hi Tom,
>
> On Tue, 29 Oct 2024 at 17:36, Tom Rini <trini@konsulko.com> wrote:
> >
> > On Tue, Oct 29, 2024 at 04:45:40PM +0100, Simon Glass wrote:
> > > Hi Tom,
> > >
> > > On Mon, 28 Oct 2024 at 20:33, Tom Rini <trini@konsulko.com> wrote:
> > > >
> > > > On Mon, Oct 28, 2024 at 01:41:08PM +0100, Simon Glass wrote:
> > > >
> > > > > 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 <sjg@chromium.org>
> > > >
> > > > 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.
>
> Old: test/bloblist.c
> New: test/common/bloblist.c
>
> It 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.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 03/21] bloblist: test: doc: Move into the common suite
2024-10-31 18:10 ` Tom Rini
@ 2024-11-01 15:32 ` Simon Glass
2024-11-01 16:47 ` Tom Rini
0 siblings, 1 reply; 31+ messages in thread
From: Simon Glass @ 2024-11-01 15:32 UTC (permalink / raw)
To: Tom Rini
Cc: U-Boot Mailing List, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Raymond Mao
Hi Tom,
On Thu, 31 Oct 2024 at 19:10, Tom Rini <trini@konsulko.com> wrote:
>
> On Thu, Oct 31, 2024 at 07:00:41PM +0100, Simon Glass wrote:
> > Hi Tom,
> >
> > On Tue, 29 Oct 2024 at 17:36, Tom Rini <trini@konsulko.com> wrote:
> > >
> > > On Tue, Oct 29, 2024 at 04:45:40PM +0100, Simon Glass wrote:
> > > > Hi Tom,
> > > >
> > > > On Mon, 28 Oct 2024 at 20:33, Tom Rini <trini@konsulko.com> wrote:
> > > > >
> > > > > On Mon, Oct 28, 2024 at 01:41:08PM +0100, Simon Glass wrote:
> > > > >
> > > > > > 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 <sjg@chromium.org>
> > > > >
> > > > > 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.
> >
> > Old: test/bloblist.c
> > New: test/common/bloblist.c
> >
> > It 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
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 03/21] bloblist: test: doc: Move into the common suite
2024-11-01 15:32 ` Simon Glass
@ 2024-11-01 16:47 ` Tom Rini
0 siblings, 0 replies; 31+ messages in thread
From: Tom Rini @ 2024-11-01 16:47 UTC (permalink / raw)
To: Simon Glass
Cc: U-Boot Mailing List, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Raymond Mao
[-- Attachment #1: Type: text/plain, Size: 2107 bytes --]
On Fri, Nov 01, 2024 at 04:32:56PM +0100, Simon Glass wrote:
> Hi Tom,
>
> On Thu, 31 Oct 2024 at 19:10, Tom Rini <trini@konsulko.com> wrote:
> >
> > On Thu, Oct 31, 2024 at 07:00:41PM +0100, Simon Glass wrote:
> > > Hi Tom,
> > >
> > > On Tue, 29 Oct 2024 at 17:36, Tom Rini <trini@konsulko.com> wrote:
> > > >
> > > > On Tue, Oct 29, 2024 at 04:45:40PM +0100, Simon Glass wrote:
> > > > > Hi Tom,
> > > > >
> > > > > On Mon, 28 Oct 2024 at 20:33, Tom Rini <trini@konsulko.com> wrote:
> > > > > >
> > > > > > On Mon, Oct 28, 2024 at 01:41:08PM +0100, Simon Glass wrote:
> > > > > >
> > > > > > > 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 <sjg@chromium.org>
> > > > > >
> > > > > > 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.
> > >
> > > Old: test/bloblist.c
> > > New: test/common/bloblist.c
> > >
> > > It 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.
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".
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 04/21] test: Drop test-trace.sh and common.sh
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (2 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 03/21] bloblist: test: doc: Move into the common suite Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 05/21] compression: test: Move test into lib Simon Glass
` (16 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Simon Glass, Tom Rini
The trace feature is now tested in CI so there is no need for these old
script. Also they don't work. Drop them.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
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
diff --git a/test/common.sh b/test/common.sh
deleted file mode 100644
index 904d579b7bf..00000000000
--- a/test/common.sh
+++ /dev/null
@@ -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}
-}
diff --git a/test/trace/test-trace.sh b/test/trace/test-trace.sh
deleted file mode 100755
index 5130b2bf017..00000000000
--- a/test/trace/test-trace.sh
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0+
-# Copyright (c) 2013 The Chromium OS Authors.
-#
-
-# Simple test script for tracing with sandbox
-
-TRACE_OPT="FTRACE=1"
-
-BASE="$(dirname $0)/.."
-. $BASE/common.sh
-
-run_trace() {
- echo "Run trace"
- ./${OUTPUT_DIR}/u-boot <<END
-trace stats
-hash sha256 0 10000
-trace pause
-trace stats
-hash sha256 0 10000
-trace stats
-trace resume
-hash sha256 0 10000
-trace pause
-trace stats
-reset
-END
-}
-
-check_results() {
- echo "Check results"
-
- # Expect sha256 to run 3 times, so we see the string 6 times
- if [ $(grep -c sha256 ${tmp}) -ne 6 ]; then
- fail "sha256 error"
- fi
-
- # 4 sets of results (output of 'trace stats')
- if [ $(grep -c "traced function calls" ${tmp}) -ne 4 ]; then
- fail "trace output error"
- fi
-
- # Check trace counts. We expect to see an increase in the number of
- # traced function calls between each 'trace stats' command, except
- # between calls 2 and 3, where tracing is paused.
- # This code gets the sign of the difference between each number and
- # its predecessor.
- counts="$(tr -d ',\r' <${tmp} | awk \
- '/traced function calls/ { diff = $1 - upto; upto = $1; \
- printf "%d ", diff < 0 ? -1 : (diff > 0 ? 1 : 0)}')"
-
- if [ "${counts}" != "1 1 0 1 " ]; then
- fail "trace collection error: ${counts}"
- fi
-}
-
-echo "Simple trace test / sanity check using sandbox"
-echo
-tmp="$(tempfile)"
-build_uboot "${TRACE_OPT}"
-run_trace >${tmp}
-check_results ${tmp}
-rm ${tmp}
-echo "Test passed"
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 05/21] compression: test: Move test into lib
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (3 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 04/21] test: Drop test-trace.sh and common.sh Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 06/21] compression: test: Move into the lib suite Simon Glass
` (15 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Simon Glass, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Marek Vasut, Tom Rini
This test doesn't belong at the top level. Move it into the lib/
directory, since that is where compression is implemented.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
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%)
diff --git a/test/Makefile b/test/Makefile
index 2beff431899..fcd73f0b472 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -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
diff --git a/test/lib/Makefile b/test/lib/Makefile
index a54387a058e..ce22780eed8 100644
--- a/test/lib/Makefile
+++ b/test/lib/Makefile
@@ -2,6 +2,9 @@
#
# (C) Copyright 2018
# Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
+
+obj-$(CONFIG_$(XPL_)UT_COMPRESSION) += compression.o
+
ifeq ($(CONFIG_XPL_BUILD),)
obj-y += cmd_ut_lib.o
obj-y += abuf.o
diff --git a/test/compression.c b/test/lib/compression.c
similarity index 100%
rename from test/compression.c
rename to test/lib/compression.c
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 06/21] compression: test: Move into the lib suite
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (4 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 05/21] compression: test: Move test into lib Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 07/21] command_ut: test: Move test into lib Simon Glass
` (14 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Simon Glass, Francis Laniel, Marek Vasut, Tom Rini
There 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.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
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
diff --git a/include/test/compression.h b/include/test/compression.h
deleted file mode 100644
index 02fcfa49f65..00000000000
--- a/include/test/compression.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (c) 2017 Google, Inc
- * Written by Simon Glass <sjg@chromium.org>
- */
-
-#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__ */
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index cba97725f76..0d7d5009fef 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -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
diff --git a/test/lib/compression.c b/test/lib/compression.c
index 618a1936955..31b6e5b1eb4 100644
--- a/test/lib/compression.c
+++ b/test/lib/compression.c
@@ -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);
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 07/21] command_ut: test: Move test into lib
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (5 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 06/21] compression: test: Move into the lib suite Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 08/21] command: test: Move into the cmd suite Simon Glass
` (13 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Simon Glass, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Jerome Forissier, Rasmus Villemoes, Tom Rini
This 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.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
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%)
diff --git a/test/Makefile b/test/Makefile
index fcd73f0b472..283d97012cf 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -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
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index 4b487c1d2cb..b897636e44f 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -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
diff --git a/test/command_ut.c b/test/cmd/command.c
similarity index 100%
rename from test/command_ut.c
rename to test/cmd/command.c
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 08/21] command: test: Move into the cmd suite
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (6 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 07/21] command_ut: test: Move test into lib Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 09/21] test: Update command test to use unit-test functions Simon Glass
` (12 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Simon Glass, Tom Rini
The 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.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
test/cmd/command.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/test/cmd/command.c b/test/cmd/command.c
index 2b8d28d7ae3..77800687ec3 100644
--- a/test/cmd/command.c
+++ b/test/cmd/command.c
@@ -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);
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 09/21] test: Update command test to use unit-test functions
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (7 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 08/21] command: test: Move into the cmd suite Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 10/21] bootm: test: Move test into boot Simon Glass
` (11 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Simon Glass, Tom Rini
Rather than enabled DEBUG and using assert(), use the unit-test
functions now provided.
Drop a check that causes pytest to fail.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
test/cmd/command.c | 63 +++++++++++++++++++++++-----------------------
1 file changed, 32 insertions(+), 31 deletions(-)
diff --git a/test/cmd/command.c b/test/cmd/command.c
index 77800687ec3..5ec93d490ba 100644
--- a/test/cmd/command.c
+++ b/test/cmd/command.c
@@ -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"));
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 10/21] bootm: test: Move test into boot
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (8 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 09/21] test: Update command test to use unit-test functions Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 11/21] test: Move print_ut test into common Simon Glass
` (10 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Simon Glass, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Tom Rini
This test doesn't belong at the top level. Move it into the boot/
directory, to match its implementation.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
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%)
diff --git a/test/Makefile b/test/Makefile
index 283d97012cf..4366e495a15 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -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/
diff --git a/test/boot/Makefile b/test/boot/Makefile
index d8eded20d4f..4b5e8a692c9 100644
--- a/test/boot/Makefile
+++ b/test/boot/Makefile
@@ -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
diff --git a/test/bootm.c b/test/boot/bootm.c
similarity index 100%
rename from test/bootm.c
rename to test/boot/bootm.c
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 11/21] test: Move print_ut test into common
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (9 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 10/21] bootm: test: Move test into boot Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 12/21] test: Move print_ut into the common suite Simon Glass
` (9 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Simon Glass, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Mattijs Korpershoek, Raymond Mao, Tom Rini
This 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.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
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%)
diff --git a/test/Makefile b/test/Makefile
index 4366e495a15..9f19bfa472b 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -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
diff --git a/test/common/Makefile b/test/common/Makefile
index b6bff9201ec..53c4f16164d 100644
--- a/test/common/Makefile
+++ b/test/common/Makefile
@@ -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
diff --git a/test/print_ut.c b/test/common/print.c
similarity index 100%
rename from test/print_ut.c
rename to test/common/print.c
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 12/21] test: Move print_ut into the common suite
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (10 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 11/21] test: Move print_ut test into common Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 13/21] test: Move str_ut test into lib Simon Glass
` (8 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Simon Glass, Francis Laniel, Ilias Apalodimas,
Mattijs Korpershoek, Raymond Mao, Tom Rini
There is no particular need for bloblist to have its own test suite.
Move it into the common suite instead.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
test/cmd_ut.c | 2 --
test/common/print.c | 27 ++++++++-------------------
2 files changed, 8 insertions(+), 21 deletions(-)
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 0d7d5009fef..f4129dcf6cc 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -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"
diff --git a/test/common/print.c b/test/common/print.c
index f5e607b21a3..f1eb9072d97 100644
--- a/test/common/print.c
+++ b/test/common/print.c
@@ -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);
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 13/21] test: Move str_ut test into lib
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (11 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 12/21] test: Move print_ut into the common suite Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 14/21] str: test: Move into the lib suite Simon Glass
` (7 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Simon Glass, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Tom Rini
This 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.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
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%)
diff --git a/test/Makefile b/test/Makefile
index 9f19bfa472b..220a249c397 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -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
diff --git a/test/lib/Makefile b/test/lib/Makefile
index ce22780eed8..be20bbc047f 100644
--- a/test/lib/Makefile
+++ b/test/lib/Makefile
@@ -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
diff --git a/test/str_ut.c b/test/lib/str.c
similarity index 100%
rename from test/str_ut.c
rename to test/lib/str.c
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 14/21] str: test: Move into the lib suite
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (12 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 13/21] test: Move str_ut test into lib Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 15/21] test: Move unicode_ut test into lib Simon Glass
` (6 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Simon Glass, Francis Laniel, Tom Rini
There is no particular need for the str tests to have their own test
suite. Move them into the lib suite instead.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
test/cmd_ut.c | 4 ----
test/lib/str.c | 31 ++++++++++---------------------
2 files changed, 10 insertions(+), 25 deletions(-)
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index f4129dcf6cc..f064dd72461 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -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
diff --git a/test/lib/str.c b/test/lib/str.c
index 96e048975d8..3cc9dfea6aa 100644
--- a/test/lib/str.c
+++ b/test/lib/str.c
@@ -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);
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 15/21] test: Move unicode_ut test into lib
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (13 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 14/21] str: test: Move into the lib suite Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 16/21] test: Move unicode tests into the lib suite Simon Glass
` (5 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Simon Glass, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Tom Rini
This 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.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
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%)
diff --git a/test/Makefile b/test/Makefile
index 220a249c397..0b1affcf445 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -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
diff --git a/test/lib/Makefile b/test/lib/Makefile
index be20bbc047f..c36c8b0917d 100644
--- a/test/lib/Makefile
+++ b/test/lib/Makefile
@@ -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
diff --git a/test/unicode_ut.c b/test/lib/unicode.c
similarity index 100%
rename from test/unicode_ut.c
rename to test/lib/unicode.c
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 16/21] test: Move unicode tests into the lib suite
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (14 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 15/21] test: Move unicode_ut test into lib Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 17/21] test: Move time_ut test into lib Simon Glass
` (4 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Simon Glass, Francis Laniel, Heinrich Schuchardt, Tom Rini
There is no particular need for the unicode tests to have their own test
suite. Move them into the lib suite instead.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
test/cmd_ut.c | 7 -----
test/lib/unicode.c | 70 +++++++++++++++++++---------------------------
2 files changed, 29 insertions(+), 48 deletions(-)
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index f064dd72461..ef4f0ac607e 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -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
);
diff --git a/test/lib/unicode.c b/test/lib/unicode.c
index 13e29c9b9e3..673470c8d2c 100644
--- a/test/lib/unicode.c
+++ b/test/lib/unicode.c
@@ -11,13 +11,10 @@
#include <errno.h>
#include <log.h>
#include <malloc.h>
+#include <test/lib.h>
#include <test/test.h>
-#include <test/suites.h>
#include <test/ut.h>
-/* Linker list entry for a Unicode test */
-#define UNICODE_TEST(_name) UNIT_TEST(_name, 0, unicode_test)
-
/* Constants c1-c4 and d1-d4 encode the same letters */
/* Six characters translating to one utf-8 byte each. */
@@ -64,7 +61,7 @@ static int unicode_test_u16_strlen(struct unit_test_state *uts)
ut_asserteq(6, u16_strlen(c4));
return 0;
}
-UNICODE_TEST(unicode_test_u16_strlen);
+LIB_TEST(unicode_test_u16_strlen, 0);
static int unicode_test_u16_strnlen(struct unit_test_state *uts)
{
@@ -75,7 +72,7 @@ static int unicode_test_u16_strnlen(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_u16_strnlen);
+LIB_TEST(unicode_test_u16_strnlen, 0);
static int unicode_test_u16_strdup(struct unit_test_state *uts)
{
@@ -87,7 +84,7 @@ static int unicode_test_u16_strdup(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_u16_strdup);
+LIB_TEST(unicode_test_u16_strdup, 0);
static int unicode_test_u16_strcpy(struct unit_test_state *uts)
{
@@ -100,7 +97,7 @@ static int unicode_test_u16_strcpy(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_u16_strcpy);
+LIB_TEST(unicode_test_u16_strcpy, 0);
/* U-Boot uses UTF-16 strings in the EFI context only. */
#if CONFIG_IS_ENABLED(EFI_LOADER) && !defined(API_BUILD)
@@ -173,7 +170,7 @@ static int unicode_test_string16(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_string16);
+LIB_TEST(unicode_test_string16, 0);
#endif
static int unicode_test_utf8_get(struct unit_test_state *uts)
@@ -218,7 +215,7 @@ static int unicode_test_utf8_get(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf8_get);
+LIB_TEST(unicode_test_utf8_get, 0);
static int unicode_test_utf8_put(struct unit_test_state *uts)
{
@@ -256,7 +253,7 @@ static int unicode_test_utf8_put(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf8_put);
+LIB_TEST(unicode_test_utf8_put, 0);
static int unicode_test_utf8_utf16_strlen(struct unit_test_state *uts)
{
@@ -272,7 +269,7 @@ static int unicode_test_utf8_utf16_strlen(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf8_utf16_strlen);
+LIB_TEST(unicode_test_utf8_utf16_strlen, 0);
static int unicode_test_utf8_utf16_strnlen(struct unit_test_state *uts)
{
@@ -290,7 +287,7 @@ static int unicode_test_utf8_utf16_strnlen(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf8_utf16_strnlen);
+LIB_TEST(unicode_test_utf8_utf16_strnlen, 0);
/**
* ut_u16_strcmp() - Compare to u16 strings.
@@ -354,7 +351,7 @@ static int unicode_test_utf8_utf16_strcpy(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf8_utf16_strcpy);
+LIB_TEST(unicode_test_utf8_utf16_strcpy, 0);
static int unicode_test_utf8_utf16_strncpy(struct unit_test_state *uts)
{
@@ -398,7 +395,7 @@ static int unicode_test_utf8_utf16_strncpy(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf8_utf16_strncpy);
+LIB_TEST(unicode_test_utf8_utf16_strncpy, 0);
static int unicode_test_utf16_get(struct unit_test_state *uts)
{
@@ -424,7 +421,7 @@ static int unicode_test_utf16_get(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf16_get);
+LIB_TEST(unicode_test_utf16_get, 0);
static int unicode_test_utf16_put(struct unit_test_state *uts)
{
@@ -452,7 +449,7 @@ static int unicode_test_utf16_put(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf16_put);
+LIB_TEST(unicode_test_utf16_put, 0);
static int unicode_test_utf16_strnlen(struct unit_test_state *uts)
{
@@ -470,7 +467,7 @@ static int unicode_test_utf16_strnlen(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf16_strnlen);
+LIB_TEST(unicode_test_utf16_strnlen, 0);
static int unicode_test_utf16_utf8_strlen(struct unit_test_state *uts)
{
@@ -486,7 +483,7 @@ static int unicode_test_utf16_utf8_strlen(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf16_utf8_strlen);
+LIB_TEST(unicode_test_utf16_utf8_strlen, 0);
static int unicode_test_utf16_utf8_strnlen(struct unit_test_state *uts)
{
@@ -498,7 +495,7 @@ static int unicode_test_utf16_utf8_strnlen(struct unit_test_state *uts)
ut_asserteq(12, utf16_utf8_strnlen(c4, 3));
return 0;
}
-UNICODE_TEST(unicode_test_utf16_utf8_strnlen);
+LIB_TEST(unicode_test_utf16_utf8_strnlen, 0);
static int unicode_test_utf16_utf8_strcpy(struct unit_test_state *uts)
{
@@ -543,7 +540,7 @@ static int unicode_test_utf16_utf8_strcpy(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf16_utf8_strcpy);
+LIB_TEST(unicode_test_utf16_utf8_strcpy, 0);
static int unicode_test_utf16_utf8_strncpy(struct unit_test_state *uts)
{
@@ -587,7 +584,7 @@ static int unicode_test_utf16_utf8_strncpy(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf16_utf8_strncpy);
+LIB_TEST(unicode_test_utf16_utf8_strncpy, 0);
static int unicode_test_utf_to_lower(struct unit_test_state *uts)
{
@@ -604,7 +601,7 @@ static int unicode_test_utf_to_lower(struct unit_test_state *uts)
#endif
return 0;
}
-UNICODE_TEST(unicode_test_utf_to_lower);
+LIB_TEST(unicode_test_utf_to_lower, 0);
static int unicode_test_utf_to_upper(struct unit_test_state *uts)
{
@@ -621,7 +618,7 @@ static int unicode_test_utf_to_upper(struct unit_test_state *uts)
#endif
return 0;
}
-UNICODE_TEST(unicode_test_utf_to_upper);
+LIB_TEST(unicode_test_utf_to_upper, 0);
static int unicode_test_u16_strcasecmp(struct unit_test_state *uts)
{
@@ -646,7 +643,7 @@ static int unicode_test_u16_strcasecmp(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_u16_strcasecmp);
+LIB_TEST(unicode_test_u16_strcasecmp, 0);
static int unicode_test_u16_strncmp(struct unit_test_state *uts)
{
@@ -659,7 +656,7 @@ static int unicode_test_u16_strncmp(struct unit_test_state *uts)
ut_assert(u16_strcmp(u"deghi", u"abcdef") > 0);
return 0;
}
-UNICODE_TEST(unicode_test_u16_strncmp);
+LIB_TEST(unicode_test_u16_strncmp, 0);
static int unicode_test_u16_strsize(struct unit_test_state *uts)
{
@@ -669,7 +666,7 @@ static int unicode_test_u16_strsize(struct unit_test_state *uts)
ut_asserteq_64(u16_strsize(c4), 14);
return 0;
}
-UNICODE_TEST(unicode_test_u16_strsize);
+LIB_TEST(unicode_test_u16_strsize, 0);
static int unicode_test_utf_to_cp(struct unit_test_state *uts)
{
@@ -698,7 +695,7 @@ static int unicode_test_utf_to_cp(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf_to_cp);
+LIB_TEST(unicode_test_utf_to_cp, 0);
static void utf8_to_cp437_stream_helper(const char *in, char *out)
{
@@ -729,7 +726,7 @@ static int unicode_test_utf8_to_cp437_stream(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf8_to_cp437_stream);
+LIB_TEST(unicode_test_utf8_to_cp437_stream, 0);
static void utf8_to_utf32_stream_helper(const char *in, s32 *out)
{
@@ -778,7 +775,7 @@ static int unicode_test_utf8_to_utf32_stream(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_utf8_to_utf32_stream);
+LIB_TEST(unicode_test_utf8_to_utf32_stream, 0);
#ifdef CONFIG_EFI_LOADER
static int unicode_test_efi_create_indexed_name(struct unit_test_state *uts)
@@ -795,7 +792,7 @@ static int unicode_test_efi_create_indexed_name(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_efi_create_indexed_name);
+LIB_TEST(unicode_test_efi_create_indexed_name, 0);
#endif
static int unicode_test_u16_strlcat(struct unit_test_state *uts)
@@ -846,13 +843,4 @@ static int unicode_test_u16_strlcat(struct unit_test_state *uts)
return 0;
}
-UNICODE_TEST(unicode_test_u16_strlcat);
-
-int do_ut_unicode(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
- struct unit_test *tests = UNIT_TEST_SUITE_START(unicode_test);
- const int n_ents = UNIT_TEST_SUITE_COUNT(unicode_test);
-
- return cmd_ut_category("Unicode", "unicode_test_",
- tests, n_ents, argc, argv);
-}
+LIB_TEST(unicode_test_u16_strlcat, 0);
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 17/21] test: Move time_ut test into lib
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (15 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 16/21] test: Move unicode tests into the lib suite Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 18/21] test: Move time tests into the lib suite Simon Glass
` (3 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Simon Glass, Francis Laniel, Heinrich Schuchardt,
Ilias Apalodimas, Tom Rini
This 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.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
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%)
diff --git a/test/Makefile b/test/Makefile
index 0b1affcf445..47a07d653a9 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -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),)
diff --git a/test/lib/Makefile b/test/lib/Makefile
index c36c8b0917d..217c3baf881 100644
--- a/test/lib/Makefile
+++ b/test/lib/Makefile
@@ -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
diff --git a/test/time_ut.c b/test/lib/time.c
similarity index 100%
rename from test/time_ut.c
rename to test/lib/time.c
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 18/21] test: Move time tests into the lib suite
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (16 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 17/21] test: Move time_ut test into lib Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 19/21] test: Update time tests to use unit-test asserts Simon Glass
` (2 subsequent siblings)
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Simon Glass, Francis Laniel, Tom Rini
There 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.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
test/cmd_ut.c | 6 ------
test/lib/time.c | 29 ++++++++++-------------------
2 files changed, 10 insertions(+), 25 deletions(-)
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index ef4f0ac607e..5d440a964e1 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -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
);
diff --git a/test/lib/time.c b/test/lib/time.c
index 149c4b58f4a..2095bef7589 100644
--- a/test/lib/time.c
+++ b/test/lib/time.c
@@ -4,12 +4,13 @@
* Written by Simon Glass <sjg@chromium.org>
*/
-#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);
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 19/21] test: Update time tests to use unit-test asserts
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (17 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 18/21] test: Move time tests into the lib suite Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 20/21] test: Correct display of failing test Simon Glass
2024-10-28 12:41 ` [PATCH 21/21] test: Quote test names Simon Glass
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Simon Glass, Tom Rini
Rather than returning various error codes, use assertions to check that
the test passes.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
test/lib/time.c | 31 +++++++------------------------
1 file changed, 7 insertions(+), 24 deletions(-)
diff --git a/test/lib/time.c b/test/lib/time.c
index 2095bef7589..b99e738c500 100644
--- a/test/lib/time.c
+++ b/test/lib/time.c
@@ -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;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 20/21] test: Correct display of failing test
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (18 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 19/21] test: Update time tests to use unit-test asserts Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
2024-10-28 12:41 ` [PATCH 21/21] test: Quote test names Simon Glass
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Simon Glass, Mattijs Korpershoek, Tom Rini
This 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.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
test/test-main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/test-main.c b/test/test-main.c
index da5b07ce00b..e4f42689da4 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -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++;
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH 21/21] test: Quote test names
2024-10-28 12:41 [PATCH 00/21] test: Tidy up the test/ directory Simon Glass
` (19 preceding siblings ...)
2024-10-28 12:41 ` [PATCH 20/21] test: Correct display of failing test Simon Glass
@ 2024-10-28 12:41 ` Simon Glass
20 siblings, 0 replies; 31+ messages in thread
From: Simon Glass @ 2024-10-28 12:41 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Simon Glass, Mattijs Korpershoek, Tom Rini
When mentioning a test name, add single quotes to make it easier to see.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
test/test-main.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/test/test-main.c b/test/test-main.c
index e4f42689da4..c825f9c7797 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -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++;
--
2.43.0
^ permalink raw reply related [flat|nested] 31+ messages in thread