summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam@afuera.me.uk>2020-03-21 18:16:47 +0100
committerSam Thursfield <sam@afuera.me.uk>2020-03-23 02:51:31 +0100
commit3673002145363acdf83c79c96f14eb1b28d16183 (patch)
treec8c0f7c151ab25c7ee3b53fdc4b74ea81d2bab14
parentcea00f6b139098a962f2fa0908618bade2e6c936 (diff)
downloadtracker-sam/test-utils.tar.gz
trackertestutils: Add some utils needed in tracker-miner testssam/test-utils
-rw-r--r--utils/trackertestutils/dbusdaemon.py15
-rw-r--r--utils/trackertestutils/helpers.py6
2 files changed, 17 insertions, 4 deletions
diff --git a/utils/trackertestutils/dbusdaemon.py b/utils/trackertestutils/dbusdaemon.py
index abd8c6b02..59de04ecf 100644
--- a/utils/trackertestutils/dbusdaemon.py
+++ b/utils/trackertestutils/dbusdaemon.py
@@ -54,7 +54,17 @@ class DBusDaemon:
raise DaemonNotStartedError()
return self.address
+ def create_connection(self):
+ """Creates a new GDBusConnection."""
+ if self.address is None:
+ raise DaemonNotStartedError()
+ return Gio.DBusConnection.new_for_address_sync(
+ self.address,
+ Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT |
+ Gio.DBusConnectionFlags.MESSAGE_BUS_CONNECTION, None, None)
+
def get_connection(self):
+ """Returns a shared GDBusConnection for general use."""
if self._gdbus_connection is None:
raise DaemonNotStartedError()
return self._gdbus_connection
@@ -98,10 +108,7 @@ class DBusDaemon:
self._threads[0].start()
self._threads[1].start()
- self._gdbus_connection = Gio.DBusConnection.new_for_address_sync(
- self.address,
- Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT |
- Gio.DBusConnectionFlags.MESSAGE_BUS_CONNECTION, None, None)
+ self._gdbus_connection = self.create_connection()
log.debug("Pinging the new D-Bus daemon...")
self.ping_sync()
diff --git a/utils/trackertestutils/helpers.py b/utils/trackertestutils/helpers.py
index 79c19ee6a..db24b4b9a 100644
--- a/utils/trackertestutils/helpers.py
+++ b/utils/trackertestutils/helpers.py
@@ -497,5 +497,11 @@ class TrackerDBusSandbox:
log.info("Stopping D-Bus daemon for sandbox.")
self.daemon.stop()
+ def stop_miner_fs(self):
+ log.info("Stopping tracker-miner-fs process.")
+ pid = self.daemon.get_connection_unix_process_id_sync('org.freedesktop.Tracker1.Miner.Files')
+ os.kill(pid, signal.SIGTERM)
+ psutil.wait_pid(pid)
+
def get_connection(self):
return self.daemon.get_connection()