Skip to content

Commit 1dac3b6

Browse files
committed
fix(test): add some tolerance in test_serial_dos
test_serial_dos ensures that the internal FIFO buffer used for storing the bytes to be written does not grow indefinitely. Some times during the test we observe small allocations that make the assertion fail. Add some tolerance to the test (1%) to avoid false positives. Signed-off-by: Babis Chalios <[email protected]>
1 parent 304c393 commit 1dac3b6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/integration_tests/functional/test_serial_io.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ def get_total_mem_size(pid):
120120
_, stdout, stderr = utils.check_output(cmd)
121121
assert stderr == ""
122122

123-
return stdout
123+
# This assumes that the pmap returns something in the form of
124+
# 123456789K (which is typically the case for us)
125+
return float(stdout.strip()[:-1] * 1000)
124126

125127

126128
def send_bytes(tty, bytes_count, timeout=60):
@@ -156,7 +158,9 @@ def test_serial_dos(uvm_plain_any):
156158
before_size = get_total_mem_size(microvm.firecracker_pid)
157159
send_bytes(tty_fd, 100000000, timeout=1)
158160
after_size = get_total_mem_size(microvm.firecracker_pid)
159-
assert before_size == after_size, (
161+
# Give the check a bit of tolerance (1%) since sometimes random unrelated
162+
# allocations break it.
163+
assert after_size <= (before_size * 1.01), (
160164
"The memory size of the "
161165
"Firecracker process "
162166
"changed from {} to {}.".format(before_size, after_size)

0 commit comments

Comments
 (0)