From b7586da9bf5039c82dca5b2093c407dfe637d087 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 27 Jan 2020 21:40:51 +0100 Subject: [PATCH] tests: Fix timeouts not working in GMemoryMonitor tests The loops should continue iterating if the timeout is non-zero and we're still waiting for the updated value. Otherwise, if things break, we'll be waiting until we receive a value that never arrives. --- gio/tests/memory-monitor-dbus.py.in | 4 ++-- gio/tests/memory-monitor-portal.py.in | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gio/tests/memory-monitor-dbus.py.in b/gio/tests/memory-monitor-dbus.py.in index 89906f482..43c6c63fd 100755 --- a/gio/tests/memory-monitor-dbus.py.in +++ b/gio/tests/memory-monitor-dbus.py.in @@ -75,7 +75,7 @@ class TestLowMemoryMonitor(dbusmock.DBusTestCase): self.dbusmock.EmitWarning(100) # Wait 2 seconds or until warning timeout = 2 - while timeout > 0 or self.last_warning != 100: + while timeout > 0 and self.last_warning != 100: time.sleep(0.5) timeout -= 0.5 self.main_context.iteration(False) @@ -84,7 +84,7 @@ class TestLowMemoryMonitor(dbusmock.DBusTestCase): self.dbusmock.EmitWarning(255) # Wait 2 seconds or until warning timeout = 2 - while timeout > 0 or self.last_warning != 255: + while timeout > 0 and self.last_warning != 255: time.sleep(0.5) timeout -= 0.5 self.main_context.iteration(False) diff --git a/gio/tests/memory-monitor-portal.py.in b/gio/tests/memory-monitor-portal.py.in index ae6d59d12..8572d8f69 100755 --- a/gio/tests/memory-monitor-portal.py.in +++ b/gio/tests/memory-monitor-portal.py.in @@ -91,7 +91,7 @@ class TestLowMemoryMonitorPortal(dbusmock.DBusTestCase): self.dbusmock.EmitWarning(100) # Wait 2 seconds or until warning timeout = 2 - while timeout > 0 or self.last_warning != 100: + while timeout > 0 and self.last_warning != 100: time.sleep(0.5) timeout -= 0.5 self.main_context.iteration(False) @@ -100,7 +100,7 @@ class TestLowMemoryMonitorPortal(dbusmock.DBusTestCase): self.dbusmock.EmitWarning(255) # Wait 2 seconds or until warning timeout = 2 - while timeout > 0 or self.last_warning != 255: + while timeout > 0 and self.last_warning != 255: time.sleep(0.5) timeout -= 0.5 self.main_context.iteration(False)