[tracker-miners/sam/index-location: 9/21] functional-tests: Add a way to debug miner-fs during tests
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/sam/index-location: 9/21] functional-tests: Add a way to debug miner-fs during tests
- Date: Thu, 9 Jul 2020 23:04:31 +0000 (UTC)
commit b976fecde30ec889d8261807af12059d7880834a
Author: Sam Thursfield <sam afuera me uk>
Date: Wed Jul 8 00:56:48 2020 +0200
functional-tests: Add a way to debug miner-fs during tests
HACKING.md | 10 ++++++++++
tests/functional-tests/helpers.py | 32 ++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+)
---
diff --git a/HACKING.md b/HACKING.md
index 6f7edbe7e..628f5ef96 100644
--- a/HACKING.md
+++ b/HACKING.md
@@ -1,2 +1,12 @@
Please see the file HACKING.md in Tracker core:
https://gitlab.gnome.org/GNOME/tracker/blob/master/HACKING.md
+
+The ENVIRONMENT sections of `docs/man/tracker-miners-fs.1.txt` and
+`docs/man/tracker-extract.1.txt` document available debugging tools
+for these daemons.
+
+Set `TRACKER_TESTS_MINER_FS_COMMAND` when running the functional-tests
+to help debugging tracker-miner-fs issues. For example, you can debug
+the miner-fs process during the 'miner-basic' functional tests like this:
+
+ env TRACKER_TESTS_MINER_FS_COMMAND="/usr/bin/gdb ./src/miners/fs/tracker-miner-fs-3" meson test
miner-basic -t 100000 --verbose
diff --git a/tests/functional-tests/helpers.py b/tests/functional-tests/helpers.py
index 62a6068c3..9c18ebcd4 100644
--- a/tests/functional-tests/helpers.py
+++ b/tests/functional-tests/helpers.py
@@ -25,7 +25,9 @@ from gi.repository import Tracker
import dataclasses
import logging
+import os
import pathlib
+import subprocess
import trackertestutils.mainloop
@@ -127,6 +129,22 @@ class await_files_processed():
return True
+def await_bus_name(connection, name):
+ loop = trackertestutils.mainloop.MainLoop()
+
+ def appeared_cb(connection, name, name_owner):
+ log.debug("%s appeared (owner: %s)", name, name_owner)
+ loop.quit()
+
+ def vanished_cb(connection, name):
+ log.debug("%s vanished", name)
+
+ Gio.bus_watch_name_on_connection(
+ connection, name, Gio.BusNameWatcherFlags.NONE, appeared_cb,
+ vanished_cb);
+ loop.run_checked()
+
+
class MinerFsHelper ():
MINERFS_BUSNAME = "org.freedesktop.Tracker3.Miner.Files"
@@ -151,6 +169,20 @@ class MinerFsHelper ():
self.MINERFS_BUSNAME, self.MINERFS_INDEX_OBJ_PATH, self.MINER_INDEX_IFACE)
def start(self):
+ if 'TRACKER_TESTS_MINER_FS_COMMAND' in os.environ:
+ # This can be used to manually run the miner-fs instead of using
+ # D-Bus autoactivation. Useful if you want to use a debugging tool.
+ # The process should exit when sandbox D-Bus daemon exits.
+ command = os.environ['TRACKER_TESTS_MINER_FS_COMMAND']
+ logging.info("Manually starting tracker-miner-fs using TRACKER_TESTS_MINER_FS_COMMAND %s",
command)
+ p = subprocess.Popen(command, shell=True)
+ if p.poll():
+ raise RuntimeError("Error manually starting miner-fs")
+ # Wait for the process to connect to D-Bus. Autoactivation has a
+ # hard timeout of 25 seconds, which can be too short if running
+ # under Valgrind.
+ await_bus_name(self.bus, self.MINERFS_BUSNAME)
+
self.miner_iface.Start()
def stop(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]