Skip to contentSkip to conversation

test: Tidy up the test/ directory

PATCH In review Simon Glass 3 participants 35 messages Nov 2, 2024 – Nov 15, 2024

lore
Share & tools
lore
#0 lore raw

v2 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.

Changes in v2:
- Leave the bootm rule alone, as the bootm test only runs on sandbox
- Make the test dependent on sandbox
- Add missing 'common' help in this patch instead of bloblist
- Drop patch to move bloblist into the common suite

Simon Glass (20):
bloblist: test: Move test into common
bloblist: test: Drop global_data declarations
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

 include/test/compression.h           |  16 ----
 test/Makefile                        |  10 ---
 test/boot/Makefile                   |   3 +
 test/{ => boot}/bootm.c              |   0
 test/cmd/Makefile                    |   1 +
 test/cmd/command.c                   | 108 +++++++++++++++++++++++++++
 test/cmd_ut.c                        |  25 +------
 test/command_ut.c                    | 104 --------------------------
 test/common.sh                       |  20 -----
 test/common/Makefile                 |   4 +
 test/{ => common}/bloblist.c         |   3 -
 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 ----------------
 19 files changed, 205 insertions(+), 394 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 (99%)
 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.sh
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/20 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.

---

Changes in v2:
- Leave the bootm rule alone, as the bootm test only runs on sandbox

 test/Makefile                | 1 -
 test/common/Makefile         | 3 +++
 test/{ => common}/bloblist.c | 0
 3 files changed, 3 insertions(+), 1 deletion(-)
 rename test/{ => common}/bloblist.c (100%)
test/Makefile +0 -1
index 145c952d2c3..5d62b5c3357 100644
@@ -5,7 +5,6 @@
 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/
test/common/Makefile +3 -0
index 12c65f8c951..b6bff9201ec 100644
@@ -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
similarity index 100%
rename from test/bloblist.c
rename to test/common/bloblist.c
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v2 01/20] bloblist: test: Move test into common

Quoted 21 lines · Simon Glass

This test doesn't belong at the top level. Move it into the common/ directory, to match its implementation.

---

Changes in v2:
- Leave the bootm rule alone, as the bootm test only runs on sandbox

  test/Makefile                | 1 -
  test/common/Makefile         | 3 +++
  test/{ => common}/bloblist.c | 0
  3 files changed, 3 insertions(+), 1 deletion(-)

rename test/{ => common}/bloblist.c (100%)

test/Makefile +0 -0
index 145c952d2c3..5d62b5c3357 100644

test/Makefile line 7

Quoted 3 lines
test/Makefile +0 -0
@@ -5,7 +5,6 @@
  obj-y += test-main.o
 
  ifneq ($(CONFIG_$(XPL_)BLOBLIST),)

Shouldn't this be CONFIG_$(PHASE_)BLOBLIST, see common/Makefile.

test/Makefile line 8

Quoted 1 line
test/Makefile +0 -1
-obj-$(CONFIG_$(XPL_)CMDLINE) += bloblist.o

Why do we need the command line for running this test?

The only thing we need the command line for is issuing the 'ut' command?

Can be remove the CMDLINE dependency or move it to 'config UNIT_TEST'.

test/common/Makefile line 4

Quoted 12 lines
test/Makefile +0 -0
  obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o
  endif
  obj-$(CONFIG_$(XPL_)CMDLINE) += cmd/
test/common/Makefile +1 -0
index 12c65f8c951..b6bff9201ec 100644
@@ -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),)

ditto

Best regards

Heinrich

Quoted 9 lines
test/common/Makefile +2 -0
+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
similarity index 100%
rename from test/bloblist.c
rename to test/common/bloblist.c
#3 lore raw

Re: [PATCH v2 01/20] bloblist: test: Move test into common

Hi Heinrich,

Quoted 25 lines · Heinrich Schuchardt
Quoted 23 lines · Simon Glass

This test doesn't belong at the top level. Move it into the common/ directory, to match its implementation.

---

Changes in v2:
- Leave the bootm rule alone, as the bootm test only runs on sandbox

  test/Makefile                | 1 -
  test/common/Makefile         | 3 +++
  test/{ => common}/bloblist.c | 0
  3 files changed, 3 insertions(+), 1 deletion(-)

rename test/{ => common}/bloblist.c (100%)

test/Makefile +0 -0
index 145c952d2c3..5d62b5c3357 100644
@@ -5,7 +5,6 @@
  obj-y += test-main.o
 
Quoted 3 lines

test/Makefile line 7

Quoted 1 line
test/Makefile +0 -0
  ifneq ($(CONFIG_$(XPL_)BLOBLIST),)

Shouldn't this be CONFIG_$(PHASE_)BLOBLIST, see common/Makefile.

As before, we don't run this test in any xPL build.

If we use PHASE_ that suggests that each xPL build has a different setting for this value.

If the final part of my xPL series[1] ever lands, all of these $(xxx) things in Makefiles will go away. For now, using PHASE_ just adds confusion and might even make that migration more difficult.

Quoted 4 lines

test/Makefile line 8

Quoted 2 lines
test/Makefile +0 -1
-obj-$(CONFIG_$(XPL_)CMDLINE) += bloblist.o

Why do we need the command line for running this test?

bloblist_test_cmd_info()

Quoted 4 lines

The only thing we need the command line for is issuing the 'ut' command?

Can be remove the CMDLINE dependency or move it to 'config UNIT_TEST'.

We could make the above test return -EAGAIN if
!CONFIG_IS_ENABLED(CMDLINE) I suppose.

Quoted 20 lines

test/common/Makefile line 4

Quoted 13 lines
test/Makefile +0 -0
  obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o
  endif
  obj-$(CONFIG_$(XPL_)CMDLINE) += cmd/
test/common/Makefile +1 -0
index 12c65f8c951..b6bff9201ec 100644
@@ -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),)

ditto

Best regards

Heinrich

Quoted 10 lines

test/common/bloblist.c

Quoted 9 lines
test/common/Makefile +2 -0
+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
similarity index 100%
rename from test/bloblist.c
rename to test/common/bloblist.c

Regards,
Simon

[1] https://patchwork.ozlabs.org/project/uboot/list/?series=341504&state=*

#4 lore raw

PATCH v2 2/20 bloblist: test: Drop global_data declarations

In reply to Simon Glass

This pointer is not used any more, so drop the declarations.

---

(no changes since v1)

 test/common/bloblist.c | 3 ---
 1 file changed, 3 deletions(-)
test/common/bloblist.c +0 -3
index fd85c7ab79e..7b90fa7f352 100644
@@ -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
#5 lore raw

PATCH v2 3/20 test: Drop test-trace.sh and common.sh

In reply to Simon Glass

The trace feature is now tested in CI so there is no need for these old script. Also they don't work. Drop them.

---

(no changes since v1)

 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
deleted file mode 100644
index 904d579b7bf..00000000000
@@ -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
#6 lore raw

PATCH v2 4/20 compression: test: Move test into lib

In reply to Simon Glass

This test doesn't belong at the top level. Move it into the lib/ directory, since that is where compression is implemented.

---

(no changes since v1)

 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
index 5d62b5c3357..ff621344a03 100644
@@ -10,7 +10,6 @@ endif
 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
index a54387a058e..ce22780eed8 100644
@@ -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
similarity index 100%
rename from test/compression.c
rename to test/lib/compression.c
Signature · 1 line
2.43.0
#7 lore raw

Re: [PATCH v2 04/20] compression: test: Move test into lib

test/lib/compression.c

Quoted 44 lines · Simon Glass

This test doesn't belong at the top level. Move it into the lib/ directory, since that is where compression is implemented.

---

(no changes since v1)

  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
index 5d62b5c3357..ff621344a03 100644
@@ -10,7 +10,6 @@ endif
  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
index a54387a058e..ce22780eed8 100644
@@ -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
similarity index 100%
rename from test/compression.c
rename to test/lib/compression.c

Can we now use LIB_TEST instead of the COMPRESSION_TEST macro?

Best regards

Heinrich

#8 lore raw

Re: [PATCH v2 04/20] compression: test: Move test into lib

Hi Heinrich,

Quoted 40 lines · Heinrich Schuchardt
Quoted 38 lines · Simon Glass

This test doesn't belong at the top level. Move it into the lib/ directory, since that is where compression is implemented.

---

(no changes since v1)

  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
index 5d62b5c3357..ff621344a03 100644
@@ -10,7 +10,6 @@ endif
  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
index a54387a058e..ce22780eed8 100644
@@ -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),)
Quoted 8 lines

test/lib/compression.c

Quoted 6 lines
test/lib/Makefile +0 -0
  obj-y += cmd_ut_lib.o
  obj-y += abuf.o
test/lib/compression.c renamed from test/compression.c +0 -0
similarity index 100%
rename from test/compression.c
rename to test/lib/compression.c

Can we now use LIB_TEST instead of the COMPRESSION_TEST macro?

Yes, we could.

There was some discussion (with Tom) as to whether we should break things up this way. For example I changed bloblist back to being separate, in the later version of this series.

I would be quite happy with just having ~one test suite per dir.

Regards,
Simon

#9 lore raw

PATCH v2 5/20 compression: test: Move into the lib suite

In reply to Simon Glass

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.

---

(no changes since v1)

 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
deleted file mode 100644
index 02fcfa49f65..00000000000
@@ -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
index 53fddebd49d..32403b48ca4 100644
@@ -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(bloblist, CONFIG_SYS_MAXARGS, 1, do_ut_bloblist,
 			 "", ""),
 	U_BOOT_CMD_MKENT(bootm, CONFIG_SYS_MAXARGS, 1, do_ut_bootm, "", ""),
@@ -207,9 +205,6 @@ U_BOOT_LONGHELP(ut,
 #ifdef CONFIG_CMDLINE
 	"\ncmd - test various commands"
 #endif
-#ifdef CONFIG_SANDBOX
-	"\ncompression - compressors and bootm decompression"
-#endif
 #ifdef CONFIG_UT_DM
 	"\ndm - driver model"
 #endif
test/lib/compression.c +14 -25
index 618a1936955..31b6e5b1eb4 100644
@@ -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
#10 lore raw

PATCH v2 6/20 command_ut: test: Move test into lib

In reply to Simon Glass

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.

---

(no changes since v1)

 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
index ff621344a03..48d8bc91ae6 100644
@@ -9,7 +9,6 @@ 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
 obj-y += dm/
 obj-$(CONFIG_FUZZ) += fuzz/
 ifndef CONFIG_SANDBOX_VPL
test/cmd/Makefile +1 -0
index fe7a2165af2..6231a08186d 100644
@@ -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
similarity index 100%
rename from test/command_ut.c
rename to test/cmd/command.c
Signature · 1 line
2.43.0
Reviewed-by on v2 6/20
#11 lore raw

Re: [PATCH v2 06/20] command_ut: test: Move test into lib

test/cmd/command.c

Quoted 46 lines · Simon Glass

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.

---

(no changes since v1)

  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
index ff621344a03..48d8bc91ae6 100644
@@ -9,7 +9,6 @@ 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
  obj-y += dm/
  obj-$(CONFIG_FUZZ) += fuzz/
  ifndef CONFIG_SANDBOX_VPL
test/cmd/Makefile +1 -0
index fe7a2165af2..6231a08186d 100644
@@ -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
similarity index 100%
rename from test/command_ut.c
rename to test/cmd/command.c

There are CLI variables using env and others that don't. The latter we seem not to be tested.

Maybe we can add a test like the following after your series is merged.

=> a=123
=> env set b 456
=> echo $a$b
123456
=> env print b
b=456
=> env print a
## Error: "a" not defined
=>

#12 lore raw

Re: [PATCH v2 06/20] command_ut: test: Move test into lib

Hi Heinrich,

Quoted 64 lines · Heinrich Schuchardt

test/cmd/command.c

Quoted 46 lines · Simon Glass

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.

---

(no changes since v1)

  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
index ff621344a03..48d8bc91ae6 100644
@@ -9,7 +9,6 @@ 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
  obj-y += dm/
  obj-$(CONFIG_FUZZ) += fuzz/
  ifndef CONFIG_SANDBOX_VPL
test/cmd/Makefile +1 -0
index fe7a2165af2..6231a08186d 100644
@@ -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
similarity index 100%
rename from test/command_ut.c
rename to test/cmd/command.c

There are CLI variables using env and others that don't. The latter we seem not to be tested.

Maybe we can add a test like the following after your series is merged.

=> a=123
=> env set b 456
=> echo $a$b
123456
=> env print b
b=456
=> env print a
## Error: "a" not defined
=>

Quoted 1 line

Hmm yes, that would be useful. See also test/hush/dollar.c for example, which has some related tests, but not quite the same.

Regards,
Simon

#13 lore raw

PATCH v2 7/20 command: test: Move into the cmd suite

In reply to Simon Glass

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.

---

(no changes since v1)

 test/cmd/command.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
test/cmd/command.c +13 -10
index 2b8d28d7ae3..77800687ec3 100644
@@ -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
#14 lore raw

PATCH v2 8/20 test: Update command test to use unit-test functions

In reply to Simon Glass

Rather than enabled DEBUG and using assert(), use the unit-test functions now provided.

Drop a check that causes pytest to fail.

---

(no changes since v1)

 test/cmd/command.c | 63 +++++++++++++++++++++++-----------------------
 1 file changed, 32 insertions(+), 31 deletions(-)
test/cmd/command.c +32 -31
index 77800687ec3..5ec93d490ba 100644
@@ -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
#15 lore raw

PATCH v2 9/20 bootm: test: Move test into boot

In reply to Simon Glass

This test doesn't belong at the top level. Move it into the boot/ directory, to match its implementation.

This test is currently dependent on bloblist, but the real dependency is on sandbox, so update that.

---

Changes in v2:
- Make the test dependent on sandbox

 test/Makefile           | 3 ---
 test/boot/Makefile      | 3 +++
 test/{ => boot}/bootm.c | 0
 3 files changed, 3 insertions(+), 3 deletions(-)
 rename test/{ => boot}/bootm.c (100%)
test/Makefile +0 -3
index 48d8bc91ae6..4366e495a15 100644
@@ -4,9 +4,6 @@
 
 obj-y += test-main.o
 
-ifneq ($(CONFIG_$(XPL_)BLOBLIST),)
-obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o
-endif
 obj-$(CONFIG_$(XPL_)CMDLINE) += cmd/
 obj-$(CONFIG_$(XPL_)CMDLINE) += cmd_ut.o
 obj-y += dm/
test/boot/Makefile +3 -0
index d8eded20d4f..63487e8d29e 100644
@@ -10,6 +10,9 @@ obj-$(CONFIG_EXPO) += expo.o
 obj-$(CONFIG_CEDIT) += cedit.o
 endif
 
+ifdef CONFIG_SANDBOX
+obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o
+endif
 obj-$(CONFIG_MEASURED_BOOT) += measurement.o
 
 ifdef CONFIG_OF_LIVE
test/boot/bootm.c renamed from test/bootm.c +0 -0
similarity index 100%
rename from test/bootm.c
rename to test/boot/bootm.c
Signature · 1 line
2.43.0
#16 lore raw

Re: [PATCH v2 09/20] bootm: test: Move test into boot

Quoted 23 lines · Simon Glass

This test doesn't belong at the top level. Move it into the boot/ directory, to match its implementation.

This test is currently dependent on bloblist, but the real dependency is on sandbox, so update that.

---

Changes in v2:
- Make the test dependent on sandbox

  test/Makefile           | 3 ---
  test/boot/Makefile      | 3 +++
  test/{ => boot}/bootm.c | 0
  3 files changed, 3 insertions(+), 3 deletions(-)

rename test/{ => boot}/bootm.c (100%)

test/Makefile +0 -0
index 48d8bc91ae6..4366e495a15 100644

test/Makefile line 7

Quoted 4 lines
test/Makefile +0 -1
@@ -4,9 +4,6 @@
 
  obj-y += test-main.o
 
-ifneq ($(CONFIG_$(XPL_)BLOBLIST),)

Shouldn't this be CONFIG_$(PHASE_)BLOBLIST, see common/Makefile.

Best regards

Heinrich

Quoted 23 lines
test/Makefile +0 -2
-obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o
-endif
  obj-$(CONFIG_$(XPL_)CMDLINE) += cmd/
  obj-$(CONFIG_$(XPL_)CMDLINE) += cmd_ut.o
  obj-y += dm/
test/boot/Makefile +3 -0
index d8eded20d4f..63487e8d29e 100644
@@ -10,6 +10,9 @@ obj-$(CONFIG_EXPO) += expo.o
  obj-$(CONFIG_CEDIT) += cedit.o
  endif
 
+ifdef CONFIG_SANDBOX
+obj-$(CONFIG_$(XPL_)CMDLINE) += bootm.o
+endif
  obj-$(CONFIG_MEASURED_BOOT) += measurement.o
 
  ifdef CONFIG_OF_LIVE
test/boot/bootm.c renamed from test/bootm.c +0 -0
similarity index 100%
rename from test/bootm.c
rename to test/boot/bootm.c
#17 lore raw

Re: [PATCH v2 09/20] bootm: test: Move test into boot

Hi Heinrich,

Quoted 26 lines · Heinrich Schuchardt
Quoted 24 lines · Simon Glass

This test doesn't belong at the top level. Move it into the boot/ directory, to match its implementation.

This test is currently dependent on bloblist, but the real dependency is on sandbox, so update that.

---

Changes in v2:
- Make the test dependent on sandbox

  test/Makefile           | 3 ---
  test/boot/Makefile      | 3 +++
  test/{ => boot}/bootm.c | 0
  3 files changed, 3 insertions(+), 3 deletions(-)

rename test/{ => boot}/bootm.c (100%)

test/Makefile +0 -0
index 48d8bc91ae6..4366e495a15 100644
@@ -4,9 +4,6 @@
 
Quoted 5 lines

test/Makefile line 7

Quoted 3 lines
test/Makefile +0 -1
  obj-y += test-main.o
 
-ifneq ($(CONFIG_$(XPL_)BLOBLIST),)

Shouldn't this be CONFIG_$(PHASE_)BLOBLIST, see common/Makefile.

There are a ton of these situations. Yes, it could be converted, but for now we don't run bloblist tests in anything other than U-Boot proper.

Regards,
Simon

#18 lore raw

PATCH v2 10/20 test: Move print_ut test into common

In reply to Simon Glass

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.

---

(no changes since v1)

 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
index 4366e495a15..9f19bfa472b 100644
@@ -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
index b6bff9201ec..53c4f16164d 100644
@@ -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
similarity index 100%
rename from test/print_ut.c
rename to test/common/print.c
Signature · 1 line
2.43.0
#19 lore raw

PATCH v2 11/20 test: Move print_ut into the common suite

In reply to 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'.

---

Changes in v2:
- Add missing 'common' help in this patch instead of bloblist

 test/cmd_ut.c       |  3 +--
 test/common/print.c | 27 ++++++++-------------------
 2 files changed, 9 insertions(+), 21 deletions(-)
test/cmd_ut.c +1 -2
index 32403b48ca4..9b47a2c1a93 100644
@@ -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
@@ -205,6 +204,7 @@ U_BOOT_LONGHELP(ut,
 #ifdef CONFIG_CMDLINE
 	"\ncmd - test various commands"
 #endif
+	"\ncommon   - tests for common/ directory"
 #ifdef CONFIG_UT_DM
 	"\ndm - driver model"
 #endif
@@ -239,7 +239,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
index f5e607b21a3..f1eb9072d97 100644
@@ -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
#20 lore raw

PATCH v2 12/20 test: Move str_ut test into lib

In reply to Simon Glass

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.

---

(no changes since v1)

 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
index 9f19bfa472b..220a249c397 100644
@@ -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
index ce22780eed8..be20bbc047f 100644
@@ -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
similarity index 100%
rename from test/str_ut.c
rename to test/lib/str.c
Signature · 1 line
2.43.0
#21 lore raw

Re: [PATCH v2 12/20] test: Move str_ut test into lib

Quoted 32 lines · Simon Glass

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.

---

(no changes since v1)

  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
index 9f19bfa472b..220a249c397 100644
@@ -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 +0 -0
index ce22780eed8..be20bbc047f 100644

test/lib/Makefile obj-y += lmb.o · line 20

Quoted 4 lines
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

Shouldn't this be CONFIG_$(PHASE_)STRTO, see lib/Makefile.

I would not know why we need *CMDLINE as dependency here.

Cf.
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Best regards

Heinrich

Quoted 7 lines
test/lib/Makefile +0 -0
  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
similarity index 100%
rename from test/str_ut.c
rename to test/lib/str.c
#22 lore raw

Re: [PATCH v2 12/20] test: Move str_ut test into lib

Hi Heinrich,

Quoted 29 lines · Heinrich Schuchardt
Quoted 27 lines · Simon Glass

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.

---

(no changes since v1)

  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
index 9f19bfa472b..220a249c397 100644
@@ -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
 
Quoted 11 lines

test/lib/Makefile obj-y += lmb.o · line 20

Quoted 9 lines
test/lib/Makefile +1 -0
index ce22780eed8..be20bbc047f 100644
@@ -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

Shouldn't this be CONFIG_$(PHASE_)STRTO, see lib/Makefile.

We don't allow the cmdline in any xPL build, so this is just checking for U-Boot proper, in fact.

Quoted 5 lines

I would not know why we need *CMDLINE as dependency here.

Cf.
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Yes, we don't.

Regards,
Simon

#23 lore raw

PATCH v2 13/20 str: test: Move into the lib suite

In reply to Simon Glass

There is no particular need for the str tests to have their own test suite. Move them into the lib suite instead.

---

(no changes since v1)

 test/cmd_ut.c  |  4 ----
 test/lib/str.c | 31 ++++++++++---------------------
 2 files changed, 10 insertions(+), 25 deletions(-)
test/cmd_ut.c +0 -4
index 9b47a2c1a93..96bea4747fd 100644
@@ -114,7 +114,6 @@ static struct cmd_tbl cmd_ut_sub[] = {
 			 "", ""),
 	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
@@ -240,9 +239,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
index 96e048975d8..3cc9dfea6aa 100644
@@ -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
#24 lore raw

PATCH v2 14/20 test: Move unicode_ut test into lib

In reply to Simon Glass

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.

---

(no changes since v1)

 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
index 220a249c397..0b1affcf445 100644
@@ -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
index be20bbc047f..c36c8b0917d 100644
@@ -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
similarity index 100%
rename from test/unicode_ut.c
rename to test/lib/unicode.c
Signature · 1 line
2.43.0
#26 lore raw

PATCH v2 15/20 test: Move unicode tests into the lib suite

In reply to Simon Glass

There is no particular need for the unicode tests to have their own test suite. Move them into the lib suite instead.

---

(no changes since v1)

 test/cmd_ut.c      |  7 -----
 test/lib/unicode.c | 70 +++++++++++++++++++---------------------------
 2 files changed, 29 insertions(+), 48 deletions(-)
test/cmd_ut.c +0 -7
index 96bea4747fd..f86757361db 100644
@@ -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,
 			 "", ""),
@@ -244,10 +241,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
#28 lore raw

PATCH v2 16/20 test: Move time_ut test into lib

In reply to Simon Glass

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.

---

(no changes since v1)

 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
index 0b1affcf445..47a07d653a9 100644
@@ -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
index c36c8b0917d..217c3baf881 100644
@@ -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
similarity index 100%
rename from test/time_ut.c
rename to test/lib/time.c
Signature · 1 line
2.43.0
#29 lore raw

PATCH v2 17/20 test: Move time tests into the lib suite

In reply to Simon Glass

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.

---

(no changes since v1)

 test/cmd_ut.c   |  6 ------
 test/lib/time.c | 29 ++++++++++-------------------
 2 files changed, 10 insertions(+), 25 deletions(-)
test/cmd_ut.c +0 -6
index f86757361db..195b7ea50ac 100644
@@ -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,
 			 "", ""),
@@ -238,9 +235,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
index 149c4b58f4a..2095bef7589 100644
@@ -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
#30 lore raw

PATCH v2 18/20 test: Update time tests to use unit-test asserts

In reply to Simon Glass

Rather than returning various error codes, use assertions to check that the test passes.

---

(no changes since v1)

 test/lib/time.c | 31 +++++++------------------------
 1 file changed, 7 insertions(+), 24 deletions(-)
test/lib/time.c +7 -24
index 2095bef7589..b99e738c500 100644
@@ -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
#31 lore raw

PATCH v2 19/20 test: Correct display of failing test

In reply to Simon Glass

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.

---

(no changes since v1)

 test/test-main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/test-main.c +1 -1
index da5b07ce00b..e4f42689da4 100644
@@ -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
#32 lore raw

PATCH v2 20/20 test: Quote test names

In reply to Simon Glass

When mentioning a test name, add single quotes to make it easier to see.

---

Changes in v2:
- Drop patch to move bloblist into the common suite

 test/test-main.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
test/test-main.c +4 -4
index e4f42689da4..c825f9c7797 100644
@@ -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
Tested-by on the v2 series
#33 lore raw
In reply to Simon Glass
Quoted 57 lines · Simon Glass

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.

Changes in v2:
- Leave the bootm rule alone, as the bootm test only runs on sandbox
- Make the test dependent on sandbox
- Add missing 'common' help in this patch instead of bloblist
- Drop patch to move bloblist into the common suite

Simon Glass (20):
bloblist: test: Move test into common
bloblist: test: Drop global_data declarations
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

 include/test/compression.h           |  16 ----
 test/Makefile                        |  10 ---
 test/boot/Makefile                   |   3 +
 test/{ => boot}/bootm.c              |   0
 test/cmd/Makefile                    |   1 +
 test/cmd/command.c                   | 108 +++++++++++++++++++++++++++
 test/cmd_ut.c                        |  25 +------
 test/command_ut.c                    | 104 --------------------------
 test/common.sh                       |  20 -----
 test/common/Makefile                 |   4 +
 test/{ => common}/bloblist.c         |   3 -
 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 ----------------
 19 files changed, 205 insertions(+), 394 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
Quoted 8 lines
 delete mode 100644 test/common.sh
 rename test/{ => common}/bloblist.c (99%)
 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.sh

For the series:

Quoted 4 lines
Signature · 2 lines
-- 
2.43.0
Signature · 1 line
Tom
#34 lore raw
In reply to Simon Glass
Quoted 5 lines · Simon Glass

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.

Quoted 7 lines

Changes in v2:
- Leave the bootm rule alone, as the bootm test only runs on sandbox
- Make the test dependent on sandbox
- Add missing 'common' help in this patch instead of bloblist
- Drop patch to move bloblist into the common suite

[...]

Applied to u-boot/master, thanks!

Signature · 1 line
Tom