summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2018-03-15 23:05:00 +0100
committerBenjamin Berg <bberg@redhat.com>2018-04-10 23:22:01 +0200
commit640d60855d7a9d86b28c9c80c1c2dc7d6fe2e8b6 (patch)
tree66bebb8542257fe69ab19379ee55ec8d70e1bc27
parent196daca42957e1c43dfbe2d7c0d4e63d3afa4250 (diff)
downloadgnome-settings-daemon-640d60855d7a9d86b28c9c80c1c2dc7d6fe2e8b6.tar.gz
tests: Disable buffering for most files
If the output (or input) is buffered, then the tests might not be able to read the log entries right away, causing the test to fail. Explicitly add buffering=0 to open calles where this might be relevant.
-rwxr-xr-xplugins/power/test.py8
-rw-r--r--tests/gsdtestcase.py4
2 files changed, 6 insertions, 6 deletions
diff --git a/plugins/power/test.py b/plugins/power/test.py
index 3157c6b0..b22bafed 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -50,7 +50,7 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
'gnome_screensaver', stdout=subprocess.PIPE)
gsdtestcase.set_nonblock(self.screensaver.stdout)
- self.session_log_write = open(os.path.join(self.workdir, 'gnome-session.log'), 'wb')
+ self.session_log_write = open(os.path.join(self.workdir, 'gnome-session.log'), 'wb', buffering=0)
self.session = subprocess.Popen(['gnome-session', '-f',
'-a', os.path.join(self.workdir, 'autostart'),
'--session=dummy', '--debug'],
@@ -67,7 +67,7 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
print('----- session log -----\n%s\n------' % f.read())
raise
- self.session_log = open(self.session_log_write.name)
+ self.session_log = open(self.session_log_write.name, buffering=0)
self.obj_session_mgr = self.session_bus_con.get_object(
'org.gnome.SessionManager', '/org/gnome/SessionManager')
@@ -90,7 +90,7 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
self.settings_gsd_power = Gio.Settings('org.gnome.settings-daemon.plugins.power')
Gio.Settings.sync()
- self.plugin_log_write = open(os.path.join(self.workdir, 'plugin_power.log'), 'wb')
+ self.plugin_log_write = open(os.path.join(self.workdir, 'plugin_power.log'), 'wb', buffering=0)
# avoid painfully long delays of actions for tests
env = os.environ.copy()
# Disable the use of the PolicyKit helper for brightness
@@ -106,7 +106,7 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
env=env)
# you can use this for reading the current daemon log in tests
- self.plugin_log = open(self.plugin_log_write.name)
+ self.plugin_log = open(self.plugin_log_write.name, buffering=0)
# wait until plugin is ready
timeout = 100
diff --git a/tests/gsdtestcase.py b/tests/gsdtestcase.py
index 67916330..a3515c07 100644
--- a/tests/gsdtestcase.py
+++ b/tests/gsdtestcase.py
@@ -137,7 +137,7 @@ class GSDTestCase(X11SessionTestCase):
# You can rename the log file to *.log if you want to see it on test
# case failures
- klass.monitor_log = open(os.path.join(klass.workdir, 'dbus-monitor.out'), 'wb')
+ klass.monitor_log = open(os.path.join(klass.workdir, 'dbus-monitor.out'), 'wb', buffering=0)
klass.monitor = subprocess.Popen(['dbus-monitor', '--monitor'],
stdout=klass.monitor_log,
stderr=subprocess.STDOUT)
@@ -172,7 +172,7 @@ class GSDTestCase(X11SessionTestCase):
def start_mutter(klass):
''' start mutter '''
- klass.mutter_log = open(os.path.join(klass.workdir, 'mutter.log'), 'wb')
+ klass.mutter_log = open(os.path.join(klass.workdir, 'mutter.log'), 'wb', buffering=0)
# See https://gitlab.gnome.org/GNOME/mutter/merge_requests/15
klass.mutter = subprocess.Popen(['mutter', '--x11'],
stdout=klass.mutter_log,