Skip to content

Commit 5a66cc7

Browse files
committed
contest: hw: make DmesgReader formatting more usual
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 44f0cd6 commit 5a66cc7

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

contest/hw/lib/runner.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,25 @@ def drain(self):
361361
if not data:
362362
break
363363
# kmsg format: "priority,sequence,timestamp,-;message\n"
364-
# Just keep the raw lines — hwksft doesn't parse them.
365-
lines.append(data.decode('utf-8', 'ignore'))
364+
# Convert to dmesg-style: "[ timestamp] message"
365+
raw = data.decode('utf-8', 'ignore')
366+
for raw_line in raw.splitlines():
367+
parts = raw_line.split(';', 1)
368+
if len(parts) == 2:
369+
header, msg = parts
370+
fields = header.split(',')
371+
if len(fields) >= 3:
372+
# timestamp is in microseconds
373+
try:
374+
ts_us = int(fields[2])
375+
ts_s = ts_us / 1_000_000
376+
lines.append(f'[{ts_s:>12.6f}] {msg}\n')
377+
except ValueError:
378+
lines.append(f'{msg}\n')
379+
else:
380+
lines.append(f'{msg}\n')
381+
else:
382+
lines.append(f'{raw_line}\n')
366383

367384
return ''.join(lines)
368385

0 commit comments

Comments
 (0)