[gnome-settings-daemon] power: Add helper to read plugin log during test
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] power: Add helper to read plugin log during test
- Date: Mon, 15 Jan 2018 16:21:03 +0000 (UTC)
commit 450a9361915ad08ee5716f65d7858683e2c160e5
Author: Benjamin Berg <bberg redhat com>
Date: Thu Jan 4 15:46:01 2018 +0100
power: Add helper to read plugin log during test
Add a generic helper to find needles in the gsd-power plugin log.
https://bugzilla.gnome.org/show_bug.cgi?id=792210
plugins/power/test.py | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/plugins/power/test.py b/plugins/power/test.py
index 938064f..b88adc6 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -291,6 +291,31 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
self.assertTrue(b' Suspend' in log, 'missing Suspend request')
self.assertFalse(b' Hibernate' in log, 'unexpected Hibernate request')
+ def check_plugin_log(self, needle, timeout=0, failmsg=None):
+ '''Check that needle is found in the log within the given timeout.
+ Returns immediately when found.
+
+ Fail after the given timeout.
+ '''
+ # Fast path if the message was already logged
+ log = self.plugin_log.read()
+ if needle in log:
+ return
+
+ while timeout > 0:
+ time.sleep(0.5)
+ timeout -= 0.5
+
+ # read new data (lines) from the log
+ log = self.plugin_log.read()
+ if needle in log:
+ break
+ else:
+ if failmsg is not None:
+ self.fail(failmsg)
+ else:
+ self.fail('timed out waiting for needle "%s"' % needle)
+
def check_no_dim(self, seconds):
'''Check that mode is not set to dim in the given time'''
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]