[PATCH] test: test_trace.py: Handle newer trace-cmd report formats

Tom Rini trini at konsulko.com
Wed Jan 17 22:43:57 CET 2024


With newer versions of trace-cmd we have another column in the report
that we need to handle. We don't care about it, so just use a regex to
remove it from the output that we then parse.

Signed-off-by: Tom Rini <trini at konsulko.com>
---
 test/py/tests/test_trace.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/test/py/tests/test_trace.py b/test/py/tests/test_trace.py
index 28a6e72f525f..9cb5aa939c55 100644
--- a/test/py/tests/test_trace.py
+++ b/test/py/tests/test_trace.py
@@ -117,12 +117,17 @@ def check_function(cons, fname, proftool, map_fname, trace_dat):
     out = util.run_and_log(cons, ['sh', '-c', cmd])
 
     # Format:
-    # unknown option 14
     #      u-boot-1     [000]    60.805596: function:             initf_malloc
     #      u-boot-1     [000]    60.805597: function:             initf_malloc
     #      u-boot-1     [000]    60.805601: function:             initf_bootstage
     #      u-boot-1     [000]    60.805607: function:             initf_bootstage
-    lines = [line.replace(':', '').split() for line in out.splitlines()]
+    # OR:
+    #      u-boot-1     [000] .....    60.805596: function:             initf_malloc
+    #      u-boot-1     [000] .....    60.805597: function:             initf_malloc
+    #      u-boot-1     [000] .....    60.805601: function:             initf_bootstage
+    #      u-boot-1     [000] .....    60.805607: function:             initf_bootstage
+
+    lines = [re.sub(r'(:|\.\.\.\.\.)', '', line).split() for line in out.splitlines()]
     vals = {items[4]: float(items[2]) for items in lines if len(items) == 5}
     base = None
     max_delta = 0
@@ -176,6 +181,7 @@ def check_funcgraph(cons, fname, proftool, map_fname, trace_dat):
     #  u-boot-1     [000]   282.101375: funcgraph_exit:         0.006 us   |      }
     # Then check for this:
     #  u-boot-1     [000]   282.101375: funcgraph_entry:        0.000 us   |    initcall_is_event();
+    # And this all may be '[000] .....    282.' instead.
 
     expected_indent = None
     found_start = False
@@ -185,7 +191,7 @@ def check_funcgraph(cons, fname, proftool, map_fname, trace_dat):
     # Look for initf_bootstage() entry and make sure we see the exit
     # Collect the time for initf_dm()
     for line in out.splitlines():
-        m = RE_LINE.match(line)
+        m = RE_LINE.match(re.sub(r'\.\.\.\.\.', '', line))
         if m:
             timestamp, indent, func, brace = m.groups()
             if found_end:
@@ -209,7 +215,7 @@ def check_funcgraph(cons, fname, proftool, map_fname, trace_dat):
     start_timestamp = None
     end_timestamp = None
     for line in out.splitlines():
-        m = RE_LINE.match(line)
+        m = RE_LINE.match(re.sub(r'\.\.\.\.\.', '', line))
         if m:
             timestamp, indent, func, brace = m.groups()
             if func == 'initf_dm() ':
-- 
2.34.1



More information about the U-Boot mailing list