summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorhathach <[email protected]>2026-03-26 22:41:28 +0700
committerhathach <[email protected]>2026-03-27 13:04:59 +0700
commit9b3d51790f19676c6863f3362608794eff02bfa2 (patch)
tree3d7a51c3a75c6387ce389b89b5aa54ca53d2fe39 /test
parent94f48272c79310c5ab47c79c7b57a1be7bdee901 (diff)
clean up hw_endpoint_open(), still has issue with E15 and ping-pong (slow read).
Diffstat (limited to 'test')
-rwxr-xr-xtest/hil/hil_test.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py
index 154a251c1..04dd4e2bc 100755
--- a/test/hil/hil_test.py
+++ b/test/hil/hil_test.py
@@ -749,27 +749,27 @@ def test_device_cdc_msc(board):
block_size = 512
tmp_file = f'/tmp/msc_dd_{uid}.bin'
+ # dd reports speed based on payload only. Each block also transfers 31-byte CBW + 13-byte CSW on USB.
+ scsi_ratio = (block_size + 31 + 13) / block_size
+
+ def parse_dd_speed(dd_output):
+ """Parse dd output, return USB-adjusted speed string"""
+ for line in dd_output.splitlines():
+ m = re.search(r'([\d.]+)\s+([kMG]?B/s)', line)
+ if m:
+ speed_val = float(m.group(1)) * scsi_ratio
+ return f'{speed_val:.1f} {m.group(2)}'
+ return ''
+
# Read: dd from device to file
ret = run_cmd(f'dd if={dev} of={tmp_file} bs={block_size} count={block_count} iflag=direct 2>&1')
assert ret.returncode == 0, f'dd read failed: {ret.stdout.decode()}'
- dd_out = ret.stdout.decode()
- read_speed = ''
- for line in dd_out.splitlines():
- m = re.search(r'(\d+[\.\d]*\s+[kMG]?B/s)', line)
- if m:
- read_speed = m.group(1)
- break
+ read_speed = parse_dd_speed(ret.stdout.decode())
# Write back the same data to avoid corrupting the disk
ret = run_cmd(f'dd if={tmp_file} of={dev} bs={block_size} count={block_count} oflag=direct 2>&1')
assert ret.returncode == 0, f'dd write failed: {ret.stdout.decode()}'
- dd_out = ret.stdout.decode()
- write_speed = ''
- for line in dd_out.splitlines():
- m = re.search(r'(\d+[\.\d]*\s+[kMG]?B/s)', line)
- if m:
- write_speed = m.group(1)
- break
+ write_speed = parse_dd_speed(ret.stdout.decode())
try:
os.remove(tmp_file)