Skip to content

Commit 8208ee8

Browse files
committed
fix(test): correct operator precedence
bitshift shift has lower precedence than division, meaning in MemoryUsageExceededError.__init__ we end up trying to bitshift a float, which is nonsense (as the expression in the f-string gets interpreted as (threshold / 1) << 20, and the result of all divisions in python is a float). Add some parenthesis. We cannot just write this as `threshold >> 20`, as we care about the fractional part. Fixes: 7d1549f ("tests: fix MMIO gaps in memory monitor tool") Signed-off-by: Patrick Roy <[email protected]>
1 parent 0cd25f0 commit 8208ee8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/host_tools/memory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class MemoryUsageExceededError(Exception):
1717
def __init__(self, usage, threshold, *args):
1818
"""Compose the error message containing the memory consumption."""
1919
super().__init__(
20-
f"Memory usage ({usage / 1 << 20:.2f} MiB) exceeded maximum threshold "
21-
f"({threshold / 1 << 20} MiB)",
20+
f"Memory usage ({usage / (1 << 20):.2f} MiB) exceeded maximum threshold "
21+
f"({threshold / (1 << 20)} MiB)",
2222
*args,
2323
)
2424

0 commit comments

Comments
 (0)