mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
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.
This commit is contained in:
parent
4fe2c7ffdb
commit
b7586da9bf
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user