From 460fba63b5d204d02e5bec5e710b16c41766e3ca Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 21 Dec 2025 02:58:56 +0100 Subject: cmd/meminfo: display of addresses above 4 GiB Addresses above 4 GiB don't fit into 8 digits. Use 13 digits which encompass up to 15 TiB. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- test/cmd/meminfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/cmd/meminfo.c b/test/cmd/meminfo.c index 40c3520496e..9224b9589f3 100644 --- a/test/cmd/meminfo.c +++ b/test/cmd/meminfo.c @@ -17,7 +17,7 @@ static int cmd_test_meminfo(struct unit_test_state *uts) ut_assert_nextlinen("DRAM: "); ut_assert_nextline_empty(); - ut_assert_nextline("Region Base Size End Gap"); + ut_assert_nextline("Region Base Size End Gap"); ut_assert_nextlinen("-"); /* For now we don't worry about checking the values */ -- cgit v1.2.3 From e7bbbd8e094cada44234130ac94ed847506d3c4f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 21 Dec 2025 02:58:57 +0100 Subject: test: cmd: consider configuration in meminfo test The output of the meminfo command depends on several Kconfig variables. These need to be taken into account to provide valid test results. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- test/cmd/meminfo.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/cmd/meminfo.c b/test/cmd/meminfo.c index 9224b9589f3..d91fa6fcead 100644 --- a/test/cmd/meminfo.c +++ b/test/cmd/meminfo.c @@ -15,24 +15,34 @@ static int cmd_test_meminfo(struct unit_test_state *uts) { ut_assertok(run_command("meminfo", 0)); ut_assert_nextlinen("DRAM: "); + + if (!IS_ENABLED(CMD_MEMINFO_MAP)) + return 0; + ut_assert_nextline_empty(); ut_assert_nextline("Region Base Size End Gap"); ut_assert_nextlinen("-"); /* For now we don't worry about checking the values */ - ut_assert_nextlinen("video"); + if (IS_ENABLED(CONFIG_VIDEO)) + ut_assert_nextlinen("video"); + if (IS_ENABLED(CONFIG_TRACE)) + ut_assert_nextlinen("trace"); ut_assert_nextlinen("code"); ut_assert_nextlinen("malloc"); ut_assert_nextlinen("board_info"); ut_assert_nextlinen("global_data"); ut_assert_nextlinen("devicetree"); - ut_assert_nextlinen("bootstage"); - ut_assert_nextlinen("bloblist"); + if (IS_ENABLED(CONFIG_BOOTSTAGE)) + ut_assert_nextlinen("bootstage"); + if (IS_ENABLED(CONFIG_BLOBLIST)) + ut_assert_nextlinen("bloblist"); ut_assert_nextlinen("stack"); /* we expect at least one lmb line, but don't know how many */ - ut_assert_nextlinen("lmb"); + if (IS_ENABLED(CONFIG_LMB)) + ut_assert_nextlinen("lmb"); ut_assert_skip_to_linen("free"); ut_assert_console_end(); -- cgit v1.2.3 From ddfb487a280497f7f4f4efcc092257ab4bc05341 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 21 Dec 2025 02:58:58 +0100 Subject: test: initf_malloc is only traced with EARLY_TRACE Only if early tracing is enable the function initf_malloc can be traced. Add a configuration check. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- test/py/tests/test_trace.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/py/tests/test_trace.py b/test/py/tests/test_trace.py index fcdcbe2c6db..3cb14b1c6b9 100644 --- a/test/py/tests/test_trace.py +++ b/test/py/tests/test_trace.py @@ -159,7 +159,8 @@ def check_function(ubman, fname, proftool, map_fname, trace_dat): base = timestamp # Check for some expected functions - assert 'initf_malloc' in vals.keys() + if ubman.config.buildconfig.get('config_trace_early'): + assert 'initf_malloc' in vals.keys() assert 'initr_watchdog' in vals.keys() assert 'initr_dm' in vals.keys() -- cgit v1.2.3 From 36262661d0f220fc2d992f4cc553335b484d12a2 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 21 Dec 2025 02:58:59 +0100 Subject: test: clean up test_trace.py code * Add module doc string * Correct sequence of imports * Correct long exceeding 100 characters * Remove unused variables * Remove module level invocation of check_flamegraph * Add encoding to open() calls Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Acked-by: Ilias Apalodimas --- test/py/tests/test_trace.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'test') diff --git a/test/py/tests/test_trace.py b/test/py/tests/test_trace.py index 3cb14b1c6b9..36a3c4e8fe9 100644 --- a/test/py/tests/test_trace.py +++ b/test/py/tests/test_trace.py @@ -2,9 +2,11 @@ # Copyright 2022 Google LLC # Written by Simon Glass +"""Tests for the function trace facility""" + import os -import pytest import re +import pytest import utils @@ -183,26 +185,25 @@ def check_funcgraph(ubman, fname, proftool, map_fname, trace_dat): """ # Generate the funcgraph format - out = utils.run_and_log( - ubman, [proftool, '-t', fname, '-o', trace_dat, '-m', map_fname, - 'dump-ftrace', '-f', 'funcgraph']) + utils.run_and_log(ubman, [proftool, '-t', fname, '-o', trace_dat, '-m', + map_fname, 'dump-ftrace', '-f', 'funcgraph']) # Check that the trace has what we expect cmd = f'trace-cmd report -l {trace_dat} |head -n 70' out = utils.run_and_log(ubman, ['sh', '-c', cmd]) # First look for this: - # u-boot-1 0..... 282.101360: funcgraph_entry: 0.004 us | initf_malloc(); + # u-boot-1 0..... 282.101360: funcgraph_entry: 0.004 us | initf_malloc(); # ... - # u-boot-1 0..... 282.101369: funcgraph_entry: | initf_bootstage() { - # u-boot-1 0..... 282.101369: funcgraph_entry: | bootstage_init() { - # u-boot-1 0..... 282.101369: funcgraph_entry: | dlmalloc() { + # u-boot-1 0..... 282.101369: funcgraph_entry: | initf_bootstage() { + # u-boot-1 0..... 282.101369: funcgraph_entry: | bootstage_init() { + # u-boot-1 0..... 282.101369: funcgraph_entry: | dlmalloc() { # ... - # u-boot-1 0..... 282.101375: funcgraph_exit: 0.001 us | } + # u-boot-1 0..... 282.101375: funcgraph_exit: 0.001 us | } # Then look for this: - # u-boot-1 0..... 282.101375: funcgraph_exit: 0.006 us | } + # u-boot-1 0..... 282.101375: funcgraph_exit: 0.006 us | } # Then check for this: - # u-boot-1 0..... 282.101375: funcgraph_entry: 0.000 us | event_init(); + # u-boot-1 0..... 282.101375: funcgraph_entry: 0.000 us | event_init(); expected_indent = None found_start = False @@ -218,7 +219,7 @@ def check_funcgraph(ubman, fname, proftool, map_fname, trace_dat): if found_end: upto = func break - elif func == 'initf_bootstage() ': + if func == 'initf_bootstage() ': found_start = True expected_indent = indent + ' ' elif found_start and indent == expected_indent and brace == '}': @@ -268,9 +269,8 @@ def check_flamegraph(ubman, fname, proftool, map_fname, trace_fg): """ # Generate the flamegraph format - out = utils.run_and_log( - ubman, [proftool, '-t', fname, '-o', trace_fg, '-m', map_fname, - 'dump-flamegraph']) + utils.run_and_log(ubman, [proftool, '-t', fname, '-o', trace_fg, '-m', map_fname, + 'dump-flamegraph']) # We expect dm_timer_init() to be called twice: once before relocation and # once after @@ -291,16 +291,15 @@ def check_flamegraph(ubman, fname, proftool, map_fname, trace_fg): # Add up all the time spend in initf_dm() and its children total = 0 - with open(trace_fg, 'r') as fd: + with open(trace_fg, 'r', encoding='utf-8') as fd: for line in fd: line = line.strip() if line.startswith('initf_dm'): - func, val = line.split() + _, val = line.split() count = int(val) total += count return total -check_flamegraph @pytest.mark.slow @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('trace') -- cgit v1.2.3