[gnome-settings-daemon/benzea/tests-output-checker-testing] debug crap




commit a5c72c87e17e4a8ab1ab6aa7ff62d9044c0a1bd1
Author: Benjamin Berg <bberg redhat com>
Date:   Mon Feb 15 16:02:10 2021 +0100

    debug crap

 plugins/power/meson.build     |  2 +-
 plugins/power/test.py         | 56 +++++++++++++++++++++++++++++++++++++++++--
 plugins/xsettings/meson.build | 12 +++++-----
 tests/gsdtestcase.py          | 15 ++++++++++++
 tests/output_checker.py       |  3 +++
 5 files changed, 79 insertions(+), 9 deletions(-)
---
diff --git a/plugins/power/meson.build b/plugins/power/meson.build
index 69e619f2..11105910 100644
--- a/plugins/power/meson.build
+++ b/plugins/power/meson.build
@@ -137,7 +137,7 @@ if get_option('b_sanitize').split(',').contains('address')
   envs.set('POWER_LD_PRELOAD', 'libasan.so.5')
 endif
 
-foreach i : [ 1, 2, 3, 4, 5, 6, 7, 8 ]
+foreach i : [ 2 ]
   test(
     'test-power @0@/8'.format(i),
     test_py,
diff --git a/plugins/power/test.py b/plugins/power/test.py
index a8ce32d2..c1180c11 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -44,22 +44,30 @@ class PowerPluginBase(gsdtestcase.GSDTestCase):
     COMMON_SUSPEND_METHODS=['Suspend', 'Hibernate', 'SuspendThenHibernate']
 
     def setUp(self):
+        print("setup 0\n")
         self.mock_external_monitor_file = os.path.join(self.workdir, 'GSD_MOCK_EXTERNAL_MONITOR')
         os.environ['GSD_MOCK_EXTERNAL_MONITOR_FILE'] = self.mock_external_monitor_file
 
+        print("setup 0.1\n")
+
         self.check_logind_gnome_session()
+        print("setup 0.2\n")
         self.start_logind()
+        print("setup 0.3\n")
         self.daemon_death_expected = False
+        print("setup 1\n")
 
 
         # Setup umockdev testbed
         self.testbed = UMockdev.Testbed.new()
         os.environ['UMOCKDEV_DIR'] = self.testbed.get_root_dir()
+        print("setup 2\n")
 
         # Create a mock backlight device
         # Note that this function creates a different or even no backlight
         # device based on the name of the test.
         self.add_backlight()
+        print("setup 3\n")
 
         if 'HAVE_SYSFS_BACKLIGHT' in os.environ and os.environ['HAVE_SYSFS_BACKLIGHT'] == '1':
             self.skip_sysfs_backlight = False
@@ -71,11 +79,15 @@ class PowerPluginBase(gsdtestcase.GSDTestCase):
             'upower', {'DaemonVersion': '0.99', 'OnBattery': True, 'LidIsClosed': False}, 
stdout=subprocess.PIPE)
         gsdtestcase.set_nonblock(self.upowerd.stdout)
 
+        print("setup 4\n")
+
         # start mock gnome-shell screensaver
         (self.screensaver, self.obj_screensaver) = self.spawn_server_template(
             'gnome_screensaver', stdout=subprocess.PIPE)
         gsdtestcase.set_nonblock(self.screensaver.stdout)
 
+        print("setup 5\n")
+
         self.session_log = OutputChecker()
         self.session = subprocess.Popen(['gnome-session', '-f',
                                          '-a', os.path.join(self.workdir, 'autostart'),
@@ -84,6 +96,8 @@ class PowerPluginBase(gsdtestcase.GSDTestCase):
                                         stderr=subprocess.STDOUT)
         self.session_log.writer_attached()
 
+        print("setup 6\n")
+
         # wait until the daemon is on the bus
         self.wait_for_bus_object('org.gnome.SessionManager',
                                  '/org/gnome/SessionManager')
@@ -93,21 +107,29 @@ class PowerPluginBase(gsdtestcase.GSDTestCase):
 
         self.start_mutter()
 
+        print("setup 7\n")
+
         # Set up the gnome-session presence
         obj_session_presence = self.session_bus_con.get_object(
             'org.gnome.SessionManager', '/org/gnome/SessionManager/Presence')
         self.obj_session_presence_props = dbus.Interface(obj_session_presence, dbus.PROPERTIES_IFACE)
 
+        print("setup 8\n")
+
         # ensure that our tests don't lock the screen when the screensaver
         # gets active
         self.settings_screensaver = Gio.Settings(schema_id='org.gnome.desktop.screensaver')
         self.settings_screensaver['lock-enabled'] = False
 
+        print("setup 9\n")
+
         # Ensure we set up the external monitor state
         self.set_has_external_monitor(False)
 
         self.settings_gsd_power = Gio.Settings(schema_id='org.gnome.settings-daemon.plugins.power')
 
+        print("setup 10\n")
+
         Gio.Settings.sync()
         # avoid painfully long delays of actions for tests
         env = os.environ.copy()
@@ -122,6 +144,8 @@ class PowerPluginBase(gsdtestcase.GSDTestCase):
             else:
                 env['LD_PRELOAD'] = env['POWER_LD_PRELOAD']
 
+        print("setup 11\n")
+
         # We need to redirect stdout to grab the debug messages.
         # stderr is not needed by the testing infrastructure but is useful to
         # see warnings and errors.
@@ -133,30 +157,52 @@ class PowerPluginBase(gsdtestcase.GSDTestCase):
             env=env)
         self.plugin_log.writer_attached()
 
+        print("setup 12\n")
+
         # Store the early-init messages, some tests need them.
         self.plugin_startup_msgs = self.plugin_log.check_line(b'System inhibitor fd is', timeout=10)
 
+        print("setup 13\n")
+
         # always start with zero idle time
         self.reset_idle_timer()
 
+        print("setup 14\n")
+
         # flush notification log
         self.p_notify.stdout.read()
 
+        print("setup 15 and done!\n")
+
     def tearDown(self):
 
+        print("tear down\n")
         daemon_running = self.daemon.poll() == None
         if daemon_running:
+            print("terminating daemon\n")
             self.daemon.terminate()
+            print("waiting daemon\n")
             self.daemon.wait()
+            print("daemon done\n")
+        print("checking log is closed\n")
         self.plugin_log.assert_closed()
+        print("log closed\n")
 
+        print("terminating upowerd\n")
         self.upowerd.terminate()
+        print("terminating upowerd done\n")
         self.upowerd.wait()
+        print("waiting upowerd done\n")
         self.screensaver.terminate()
+        print("terminating screensaver done\n")
         self.screensaver.wait()
+        print("waiting screensaver done\n")
         self.stop_session()
+        print("session stopped\n")
         self.stop_mutter()
+        print("mutter stopped\n")
         self.stop_logind()
+        print("logind stopped\n")
 
         # reset all changed gsettings, so that tests are independent from each
         # other
@@ -177,10 +223,15 @@ class PowerPluginBase(gsdtestcase.GSDTestCase):
 
     def stop_session(self):
         '''Stop GNOME session'''
+        print("stop GNOME session\n")
 
         assert self.session
+        print("terminating session\n")
+
         self.session.terminate()
+        print("waiting for process to finish\n")
         self.session.wait()
+        print("force closing log next\n")
         # dummyapp.desktop survives the session. This keeps the FD open in the
         # CI environment when gnome-session fails to redirect the child output
         # to journald.
@@ -530,6 +581,7 @@ class PowerPluginTest2(PowerPluginBase):
 
     def test_idle_time_reset_on_resume(self):
         '''Check that the IDLETIME is reset when resuming'''
+        print("test_idle_time_reset_on_resume\n")
 
         self.settings_screensaver['lock-enabled'] = False
 
@@ -1047,7 +1099,7 @@ class PowerPluginTest7(PowerPluginBase):
             kbd_brightness = obj_gsd_power_kbd_props.Get('org.gnome.SettingsDaemon.Power.Keyboard', 
'Brightness')
 
             # We should not have arrived here, if we did then the test failed, let's print this to help 
debugging
-            print('Got keyboard brightness: {}'.format(kbd_brightness))
+            os.write(1, 'Got keyboard brightness: {}'.format(kbd_brightness))
 
         self.assertEqual(exc.exception.get_dbus_message(), 'Failed to get property Brightness on interface 
org.gnome.SettingsDaemon.Power.Keyboard')
 
@@ -1303,4 +1355,4 @@ class PowerPluginTest8(PowerPluginBase):
         self.assertEqual(exc.exception.get_dbus_message(), 'No usable backlight could be found!')
 
 # avoid writing to stderr
-unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=2))
+unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=2, buffer=False))
diff --git a/plugins/xsettings/meson.build b/plugins/xsettings/meson.build
index b4a2b39f..064599f7 100644
--- a/plugins/xsettings/meson.build
+++ b/plugins/xsettings/meson.build
@@ -60,9 +60,9 @@ envs = [
   'TOP_BUILDDIR=' + meson.build_root()
 ]
 
-test(
-  'test-xsettings',
-  test_py,
-  env: envs,
-  timeout: 300
-)
+#test(
+#  'test-xsettings',
+#  test_py,
+#  env: envs,
+#  timeout: 300
+#)
diff --git a/tests/gsdtestcase.py b/tests/gsdtestcase.py
index 6c7168f9..daec4b4a 100644
--- a/tests/gsdtestcase.py
+++ b/tests/gsdtestcase.py
@@ -57,6 +57,7 @@ class GSDTestCase(X11SessionTestCase):
     '''
     @classmethod
     def setUpClass(klass):
+        print("class setup 1")
         os.environ['GIO_USE_VFS'] = 'local'
         os.environ['GVFS_DISABLE_FUSE'] = '1'
         # we do some string checks, disable translations
@@ -74,6 +75,7 @@ class GSDTestCase(X11SessionTestCase):
         os.environ['XDG_DATA_HOME'] = os.path.join(klass.workdir, 'data')
         os.environ['XDG_RUNTIME_DIR'] = os.path.join(klass.workdir, 'runtime')
 
+        print("class setup 2")
         # Copy gschema file into XDG_DATA_HOME
         gschema_dir = os.path.join(os.environ['XDG_DATA_HOME'], 'glib-2.0', 'schemas')
         os.makedirs(gschema_dir)
@@ -83,21 +85,32 @@ class GSDTestCase(X11SessionTestCase):
         os.makedirs(os.path.join(os.environ['XDG_CONFIG_HOME'], 'dconf'))
         os.makedirs(os.environ['XDG_RUNTIME_DIR'], mode=0o700)
 
+        print("class setup 3")
+
         # Starts Xvfb and dbus busses
         X11SessionTestCase.setUpClass()
 
+        print("class setup 4")
+
         klass.system_bus_con = klass.get_dbus(True)
         klass.session_bus_con = klass.get_dbus(False)
 
+        print("class setup 5")
+
         # we never want to cause notifications on the actual GUI
         klass.p_notify = klass.spawn_server_template(
             'notification_daemon', {}, stdout=subprocess.PIPE)[0]
         set_nonblock(klass.p_notify.stdout)
 
+        print("class setup 6")
+
         klass.start_session()
+        print("class setup 7")
         klass.start_monitor()
+        print("class setup 8")
 
         klass.settings_session = Gio.Settings(schema_id='org.gnome.desktop.session')
+        print("class setup 9")
 
     @classmethod
     def tearDownClass(klass):
@@ -116,7 +129,9 @@ class GSDTestCase(X11SessionTestCase):
         '''
         if result:
             orig_err_fail = len(result.errors) + len(result.failures)
+        print("running test")
         super(GSDTestCase, self).run(result)
+        print("test run completed")
         if result and len(result.errors) + len(result.failures) > orig_err_fail:
             if 'SHELL_ON_FAIL' in os.environ:
                 subprocess.call(['bash', '-i'], cwd=self.workdir)
diff --git a/tests/output_checker.py b/tests/output_checker.py
index 24a390be..e9c0e1b9 100644
--- a/tests/output_checker.py
+++ b/tests/output_checker.py
@@ -149,12 +149,15 @@ class OutputChecker(object):
             raise AssertionError("OutputCheck: Write side has not been closed yet!")
 
     def force_close(self):
+        print("force closing pipe %d" % self._pipe_fd_r);
 
         fd = self._pipe_fd_r
         self._pipe_fd_r = -1
         os.close(fd)
 
+        print("pipe closed, waiting\n");
         self._thread.join()
+        print("reader thread joined\n");
 
     @property
     def fd(self):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]