[Concept,5/5] test: trace: Handle trace-cmd caller-info output format

Message ID 20260219192130.737116-6-sjg@u-boot.org
State New
Headers
Series docker: Update Docker image and fix trace test |

Commit Message

Simon Glass Feb. 19, 2026, 7:21 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Newer versions of trace-cmd append a "<-- caller" suffix to function
trace lines, e.g.:

  u-boot-1  0.....  60.805596: function:  initf_malloc <-- initcall_run_f

This results in 7 fields per line instead of 5 after splitting, so the
existing `len(items) == 5` filter rejects every line, leaving the vals
dictionary empty and causing the test to fail.

Change the filter to `len(items) >= 5` so that the function name (at
index 4) and timestamp (at index 2) are extracted regardless of trailing
fields.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 test/py/tests/test_trace.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
  

Patch

diff --git a/test/py/tests/test_trace.py b/test/py/tests/test_trace.py
index 498949372aa..d82bae0acc0 100644
--- a/test/py/tests/test_trace.py
+++ b/test/py/tests/test_trace.py
@@ -144,14 +144,13 @@  def check_function(ubman, fname, proftool, map_fname, trace_dat):
     cmd = f"trace-cmd report -l {trace_dat} |grep -E '(initf_|initr_)'"
     out = utils.run_and_log(ubman, ['sh', '-c', cmd])
 
-    # Format:
+    # Format (older trace-cmd):
     #      u-boot-1     0.....    60.805596: function:             initf_malloc
-    #      u-boot-1     0.....    60.805597: function:             initf_malloc
-    #      u-boot-1     0.....    60.805601: function:             initf_bootstage
-    #      u-boot-1     0.....    60.805607: function:             initf_bootstage
+    # Format (newer trace-cmd, includes caller):
+    #      u-boot-1     0.....    60.805596: function:             initf_malloc <-- initcall_run_f
 
     lines = [line.replace(':', '').split() for line in out.splitlines()]
-    vals = {items[4]: float(items[2]) for items in lines if len(items) == 5}
+    vals = {items[4]: float(items[2]) for items in lines if len(items) >= 5}
     base = None
     max_delta = 0
     for timestamp in vals.values():