[glib/wip/hadess/update-docker-packages: 44/44] tests: Fix timeouts not working in GMemoryMonitor tests
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/hadess/update-docker-packages: 44/44] tests: Fix timeouts not working in GMemoryMonitor tests
- Date: Tue, 4 Feb 2020 16:52:10 +0000 (UTC)
commit b7586da9bf5039c82dca5b2093c407dfe637d087
Author: Bastien Nocera <hadess hadess net>
Date: Mon Jan 27 21:40:51 2020 +0100
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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]