From cb9a8919e59698a21d360e9d97a22dd0b63b9eb8 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Wed, 11 Jun 2025 10:56:07 +0300 Subject: [PATCH] test(core): don't fail next tests in case of a GC leak Also, add more details to the assertion failure message. [no changelog] --- python/src/trezorlib/debuglink.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/python/src/trezorlib/debuglink.py b/python/src/trezorlib/debuglink.py index 2c5c7b1022..b96ec946f1 100644 --- a/python/src/trezorlib/debuglink.py +++ b/python/src/trezorlib/debuglink.py @@ -861,11 +861,23 @@ class DebugLink: resp = self._read() info = dict(sorted((item.name, item.value) for item in resp.items)) - if self.prev_gc_info: - # Free heap memory should not decrease - assert info["free"] >= self.prev_gc_info["free"] + if info["total"]: + LOG.debug( + "GC info: free=%.2f%% max_free=%.2f%%", + 100 * info["free"] / info["total"], + 100 * info["max_free"] / info["total"], + ) + + prev_info = self.prev_gc_info self.prev_gc_info = info + if not prev_info: + return + # Free heap memory should not decrease + if info["free"] < prev_info["free"]: + msg = f"GC leak found: {prev_info} -> {info}" + raise AssertionError(msg) + del _make_input_func