[PATCH 0/3] sandox: test: activate tests for the command LOG

This patches activate the command LOG and the associated tests in sandbox with CONFIG_CMD_LOG=y and solve the associated issues when these tests are executed.
Patrick
Patrick Delaunay (3): dm: fix up documentation for uclass_get_by_name_len dm: compare full name in uclass_get_by_name sandox: test: activate tests for the command LOG
configs/sandbox_defconfig | 2 +- drivers/core/uclass.c | 11 ++++++++++- include/dm/uclass.h | 4 ++-- test/py/tests/test_log.py | 8 ++++---- 4 files changed, 17 insertions(+), 8 deletions(-)

Fix up the comment for uclass_get_by_name_len() to avoid confusion.
Fixes: 4b030177b660 ("dm: core: Allow finding children / uclasses by partial name") Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com ---
include/dm/uclass.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/dm/uclass.h b/include/dm/uclass.h index f1fd2ba246..a606b6a20b 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -173,10 +173,10 @@ int uclass_get(enum uclass_id key, struct uclass **ucp); const char *uclass_get_name(enum uclass_id id);
/** - * uclass_get_by_name() - Look up a uclass by its driver name + * uclass_get_by_name_len() - Look up a uclass by its partial driver name * * @name: Name to look up - * @len: Length of name + * @len: Length of the partial name * @returns the associated uclass ID, or UCLASS_INVALID if not found */ enum uclass_id uclass_get_by_name_len(const char *name, int len);

Change uclass_get_by_name to use a strict string compare function "strcmp" with the parameter 'name'.
This patch avoids issues when strlen(name)<strlen(uc_drv->name) as the function uclass_get_by_name() no more use uclass_get_by_name_len(), which limit the check with "strncmp" and length of name.
This problem is detected by the sandbox test for log filter: in log_get_cat_by_name(), uclass_get_by_name("spi") = UCLASS_SPI_EMUL for "spi_emul", it is not the expected result = UCLASS_SPI for a search by name. But it is the expected result for search with partial name uclass_get_by_name_len("spi", 3).
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com ---
drivers/core/uclass.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 336ea8d243..32b6cef167 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -196,7 +196,16 @@ enum uclass_id uclass_get_by_name_len(const char *name, int len)
enum uclass_id uclass_get_by_name(const char *name) { - return uclass_get_by_name_len(name, strlen(name)); + int i; + + for (i = 0; i < UCLASS_COUNT; i++) { + struct uclass_driver *uc_drv = lists_uclass_lookup(i); + + if (uc_drv && !strcmp(uc_drv->name, name)) + return i; + } + + return UCLASS_INVALID; }
int dev_get_uclass_index(struct udevice *dev, struct uclass **ucp)

Activate the CONFIG_CMD_LOG in sandbox to execute the LOG tests by default and correct the test log format after 72fa1ad8d9 ("log: Allow padding of the function name").
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com ---
configs/sandbox_defconfig | 2 +- test/py/tests/test_log.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 4f413582fb..a4aeee062f 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -30,7 +30,6 @@ CONFIG_AUTOBOOT_STOP_STR_CRYPT="$5$rounds=640000$HrpE65IkB8CM5nCL$BKT3QdF98Bo8fJ CONFIG_CONSOLE_RECORD=y CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000 CONFIG_PRE_CONSOLE_BUFFER=y -CONFIG_LOG=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_MISC_INIT_F=y CONFIG_STACKPROTECTOR=y @@ -108,6 +107,7 @@ CONFIG_CMD_CRAMFS=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_SQUASHFS=y CONFIG_CMD_MTDPARTS=y +CONFIG_CMD_LOG=y CONFIG_CMD_STACKPROTECTOR_TEST=y CONFIG_MAC_PARTITION=y CONFIG_AMIGA_PARTITION=y diff --git a/test/py/tests/test_log.py b/test/py/tests/test_log.py index 140dcb9aa2..20a3e56301 100644 --- a/test/py/tests/test_log.py +++ b/test/py/tests/test_log.py @@ -27,13 +27,13 @@ def test_log_format(u_boot_console):
cons = u_boot_console with cons.log.section('format'): - run_with_format('all', 'NOTICE.arch,file.c:123-func() msg') + run_with_format('all', 'NOTICE.arch,file.c:123- func() msg') output = cons.run_command('log format') assert output == 'Log format: clFLfm'
- run_with_format('fm', 'func() msg') - run_with_format('clfm', 'NOTICE.arch,func() msg') - run_with_format('FLfm', 'file.c:123-func() msg') + run_with_format('fm', ' func() msg') + run_with_format('clfm', 'NOTICE.arch, func() msg') + run_with_format('FLfm', 'file.c:123- func() msg') run_with_format('lm', 'NOTICE. msg') run_with_format('m', 'msg')

On Tue, 2022-01-11 at 17:27 +0100, Patrick Delaunay wrote:
This patches activate the command LOG and the associated tests in sandbox with CONFIG_CMD_LOG=y and solve the associated issues when these tests are executed.
Patrick
Patrick Delaunay (3): dm: fix up documentation for uclass_get_by_name_len dm: compare full name in uclass_get_by_name sandox: test: activate tests for the command LOG
Probably should read sandbox. Same for this cover-letter's subject ;-p.
configs/sandbox_defconfig | 2 +- drivers/core/uclass.c | 11 ++++++++++- include/dm/uclass.h | 4 ++-- test/py/tests/test_log.py | 8 ++++---- 4 files changed, 17 insertions(+), 8 deletions(-)

On Tue, 2022-01-11 at 17:27 +0100, Patrick Delaunay wrote:
This patches activate the command LOG and the associated tests in sandbox with CONFIG_CMD_LOG=y and solve the associated issues when these tests are executed.
Patrick
Patrick Delaunay (3): dm: fix up documentation for uclass_get_by_name_len dm: compare full name in uclass_get_by_name sandox: test: activate tests for the command LOG
Probably should read sandbox. Same for this cover-letter's subject ;-p.
configs/sandbox_defconfig | 2 +- drivers/core/uclass.c | 11 ++++++++++- include/dm/uclass.h | 4 ++-- test/py/tests/test_log.py | 8 ++++---- 4 files changed, 17 insertions(+), 8 deletions(-)

On 1/12/22 10:29 AM, Marcel Ziswiler wrote:
On Tue, 2022-01-11 at 17:27 +0100, Patrick Delaunay wrote:
This patches activate the command LOG and the associated tests in sandbox with CONFIG_CMD_LOG=y and solve the associated issues when these tests are executed.
Patrick
Patrick Delaunay (3): dm: fix up documentation for uclass_get_by_name_len dm: compare full name in uclass_get_by_name sandox: test: activate tests for the command LOG
Probably should read sandbox. Same for this cover-letter's subject ;-p.
oups, yes
configs/sandbox_defconfig | 2 +- drivers/core/uclass.c | 11 ++++++++++- include/dm/uclass.h | 4 ++-- test/py/tests/test_log.py | 8 ++++---- 4 files changed, 17 insertions(+), 8 deletions(-)
participants (4)
-
Marcel Ziswiler
-
Marcel Ziswiler
-
Patrick DELAUNAY
-
Patrick Delaunay