Commit 2dd679b0 authored by Sam Thursfield's avatar Sam Thursfield

Make functional-tests work with the Meson build system

Based on tracker@9599f058
parent bba3ccef
...@@ -436,6 +436,9 @@ if test "$native_win32" = "yes" ; then ...@@ -436,6 +436,9 @@ if test "$native_win32" = "yes" ; then
AC_DEFINE(OS_WIN32, 1, [Define if we are on win32]) AC_DEFINE(OS_WIN32, 1, [Define if we are on win32])
fi fi
AC_SUBST(FUNCTIONAL_TESTS_ONTOLOGIES_DIR, "${datadir}/tracker-tests/test-ontologies")
AC_SUBST(FUNCTIONAL_TESTS_TRACKER_STORE_PATH, "${libexecdir}/tracker-store")
#################################################################### ####################################################################
# Check if we should disable the journal # Check if we should disable the journal
#################################################################### ####################################################################
...@@ -1808,8 +1811,8 @@ AC_CONFIG_FILES([ ...@@ -1808,8 +1811,8 @@ AC_CONFIG_FILES([
tests/libtracker-miners-common/Makefile tests/libtracker-miners-common/Makefile
tests/libtracker-extract/Makefile tests/libtracker-extract/Makefile
tests/functional-tests/Makefile tests/functional-tests/Makefile
tests/functional-tests/configuration.json
tests/functional-tests/common/Makefile tests/functional-tests/common/Makefile
tests/functional-tests/common/utils/configuration.py
tests/functional-tests/common/utils/Makefile tests/functional-tests/common/utils/Makefile
tests/functional-tests/unittest2/Makefile tests/functional-tests/unittest2/Makefile
tests/functional-tests/test-extraction-data/Makefile tests/functional-tests/test-extraction-data/Makefile
......
...@@ -23,6 +23,10 @@ if not tracker_sparql.found() or not tracker_miner.found() ...@@ -23,6 +23,10 @@ if not tracker_sparql.found() or not tracker_miner.found()
tracker_sparql = tracker_subproject.get_variable('tracker_sparql_dep') tracker_sparql = tracker_subproject.get_variable('tracker_sparql_dep')
tracker_miner = tracker_subproject.get_variable('tracker_miner_dep') tracker_miner = tracker_subproject.get_variable('tracker_miner_dep')
tracker_store = tracker_subproject.get_variable('tracker_store')
else
tracker_store = find_program(join_paths(get_option('prefix'), get_option('libexecdir'), 'tracker-store'))
endif endif
avcodec = dependency('libavcodec', version: '>= 0.8.4', required: false) avcodec = dependency('libavcodec', version: '>= 0.8.4', required: false)
...@@ -308,6 +312,9 @@ conf.set('TRACKER_BINARY_AGE', 100 * tracker_minor_version + tracker_micro_versi ...@@ -308,6 +312,9 @@ conf.set('TRACKER_BINARY_AGE', 100 * tracker_minor_version + tracker_micro_versi
# Config that goes in some other generated files (.desktop, .pc, etc) # Config that goes in some other generated files (.desktop, .pc, etc)
conf.set('exec_prefix', get_option('prefix')) conf.set('exec_prefix', get_option('prefix'))
conf.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
conf.set('datadir', join_paths(get_option('prefix'), get_option('datadir')))
conf.set('datarootdir', join_paths(get_option('prefix'), get_option('datadir')))
conf.set('includedir', join_paths(get_option('prefix'), get_option('includedir'))) conf.set('includedir', join_paths(get_option('prefix'), get_option('includedir')))
conf.set('libdir', join_paths(get_option('prefix'), get_option('libdir'))) conf.set('libdir', join_paths(get_option('prefix'), get_option('libdir')))
conf.set('libexecdir', join_paths(get_option('prefix'), get_option('libexecdir'))) conf.set('libexecdir', join_paths(get_option('prefix'), get_option('libexecdir')))
...@@ -315,6 +322,13 @@ conf.set('prefix', get_option('prefix')) ...@@ -315,6 +322,13 @@ conf.set('prefix', get_option('prefix'))
conf.set('TRACKER_API_VERSION', '1.0') conf.set('TRACKER_API_VERSION', '1.0')
conf.set('VERSION', meson.project_version()) conf.set('VERSION', meson.project_version())
# Configure functional tests to run completely from source tree.
conf.set('FUNCTIONAL_TESTS_TRACKER_EXTRACT_PATH', join_paths(meson.current_build_dir(), 'src', 'tracker-extract', 'tracker-extract'))
conf.set('FUNCTIONAL_TESTS_TRACKER_MINER_FS_PATH', join_paths(meson.current_build_dir(), 'src', 'miners', 'fs', 'tracker-miner-fs'))
conf.set('FUNCTIONAL_TESTS_TRACKER_WRITEBACK_PATH', join_paths(meson.current_build_dir(), 'src', 'tracker-writeback', 'tracker-writeback'))
conf.set('FUNCTIONAL_TESTS_TRACKER_STORE_PATH', tracker_store.path())
configure_file(input: 'config.h.meson.in', configure_file(input: 'config.h.meson.in',
output: 'config.h', output: 'config.h',
configuration: conf) configuration: conf)
......
...@@ -9,33 +9,16 @@ SUBDIRS = \ ...@@ -9,33 +9,16 @@ SUBDIRS = \
configdir = $(datadir)/tracker-tests configdir = $(datadir)/tracker-tests
config_DATA = \ config_DATA = \
configuration.json \
trackertest trackertest
config_SCRIPTS = \ config_SCRIPTS = \
__init__.py \ __init__.py \
$(slow_tests) \ $(tests)
$(standard_tests)
standard_tests = \ tests = \
01-insertion.py \
02-sparql-bugs.py
standard_tests += \
04-group-concat.py \
05-coalesce.py \
06-distance.py \
07-graph.py \
08-unique-insertions.py \
09-concurrent-query.py \
14-signals.py \
15-statistics.py \
16-collation.py \
17-ontology-changes.py \
200-backup-restore.py \
300-miner-basic-ops.py \ 300-miner-basic-ops.py \
301-miner-resource-removal.py 301-miner-resource-removal.py
standard_tests += \
400-extractor-metadata.py \ 400-extractor-metadata.py \
410-extractor-decorator.py \ 410-extractor-decorator.py \
500-writeback.py \ 500-writeback.py \
...@@ -43,24 +26,20 @@ standard_tests += \ ...@@ -43,24 +26,20 @@ standard_tests += \
600-applications-camera.py \ 600-applications-camera.py \
601-applications-sync.py 601-applications-sync.py
slow_tests = \
12-transactions.py \
13-threaded-store.py
TEST_RUNNER = $(top_srcdir)/tests/functional-tests/test-runner.sh TEST_RUNNER = $(top_srcdir)/tests/functional-tests/test-runner.sh
functional-test: ${standard_tests} functional-test: ${tests}
for test in ${standard_tests} ; do \ for test in ${tests} ; do \
$(TEST_RUNNER) python $(top_srcdir)/tests/functional-tests/$$test; \ export DCONF_PROFILE=$(abs_srcdir)/trackertest ; \
done export TRACKER_EXTRACTORS_DIR=$(top_builddir)/src/tracker-extract; \
export TRACKER_EXTRACTOR_RULES_DIR=$(top_srcdir)/src/tracker-extract; \
functional-test-slow: ${slow_tests} export TRACKER_FUNCTIONAL_TEST_CONFIG=$(top_builddir)/tests/functional-tests/configuration.json ; \
@for test in ${slow_tests} ; do \
$(TEST_RUNNER) python $(top_srcdir)/tests/functional-tests/$$test; \ $(TEST_RUNNER) python $(top_srcdir)/tests/functional-tests/$$test; \
done done
EXTRA_DIST = \ EXTRA_DIST = \
$(config_SCRIPTS) \ $(config_SCRIPTS) \
$(config_DATA) \ $(config_DATA) \
configuration.json.in \
test-runner.sh \ test-runner.sh \
meson.build meson.build
...@@ -13,6 +13,4 @@ utils_SCRIPTS = \ ...@@ -13,6 +13,4 @@ utils_SCRIPTS = \
options.py \ options.py \
system.py system.py
EXTRA_DIST = \ EXTRA_DIST = $(utils_SCRIPTS)
configuration.py.in \
$(utils_SCRIPTS)
...@@ -20,8 +20,17 @@ ...@@ -20,8 +20,17 @@
"Constants describing Tracker D-Bus services" "Constants describing Tracker D-Bus services"
import json
import os import os
if 'TRACKER_FUNCTIONAL_TEST_CONFIG' not in os.environ:
raise RuntimeError("The TRACKER_FUNCTIONAL_TEST_CONFIG environment "
"variable must be set to point to the location of "
"the generated configuration.json file.")
with open(os.environ['TRACKER_FUNCTIONAL_TEST_CONFIG']) as f:
config = json.load(f)
TRACKER_BUSNAME = 'org.freedesktop.Tracker1' TRACKER_BUSNAME = 'org.freedesktop.Tracker1'
TRACKER_OBJ_PATH = '/org/freedesktop/Tracker1/Resources' TRACKER_OBJ_PATH = '/org/freedesktop/Tracker1/Resources'
RESOURCES_IFACE = "org.freedesktop.Tracker1.Resources" RESOURCES_IFACE = "org.freedesktop.Tracker1.Resources"
...@@ -32,7 +41,7 @@ MINER_IFACE = "org.freedesktop.Tracker1.Miner" ...@@ -32,7 +41,7 @@ MINER_IFACE = "org.freedesktop.Tracker1.Miner"
MINERFS_INDEX_OBJ_PATH = "/org/freedesktop/Tracker1/Miner/Files/Index" MINERFS_INDEX_OBJ_PATH = "/org/freedesktop/Tracker1/Miner/Files/Index"
MINER_INDEX_IFACE = "org.freedesktop.Tracker1.Miner.Files.Index" MINER_INDEX_IFACE = "org.freedesktop.Tracker1.Miner.Files.Index"
TRACKER_BACKUP_OBJ_PATH = "/org/freedesktop/Tracker1/Backup" TRACKER_BACKUP_OBJ_PATH = "/org/freedesktop/Tracker1/Backup"
BACKUP_IFACE = "org.freedesktop.Tracker1.Backup" BACKUP_IFACE = "org.freedesktop.Tracker1.Backup"
TRACKER_STATS_OBJ_PATH = "/org/freedesktop/Tracker1/Statistics" TRACKER_STATS_OBJ_PATH = "/org/freedesktop/Tracker1/Statistics"
...@@ -49,6 +58,8 @@ WRITEBACK_BUSNAME = "org.freedesktop.Tracker1.Writeback" ...@@ -49,6 +58,8 @@ WRITEBACK_BUSNAME = "org.freedesktop.Tracker1.Writeback"
DCONF_MINER_SCHEMA = "org.freedesktop.Tracker.Miner.Files" DCONF_MINER_SCHEMA = "org.freedesktop.Tracker.Miner.Files"
# Autoconf substitutes paths in the configuration.json file without
# expanding variables, so we need to manually insert these.
def expandvars (variable): def expandvars (variable):
# Note: the order matters! # Note: the order matters!
result = variable result = variable
...@@ -62,25 +73,14 @@ def expandvars (variable): ...@@ -62,25 +73,14 @@ def expandvars (variable):
PREFIX = "@prefix@" PREFIX = config['PREFIX']
# RAW_EXEC_PREFIX = config['RAW_EXEC_PREFIX']
# This raw variables are set by autotools without translating vars: RAW_DATAROOT_DIR = config['RAW_DATAROOT_DIR']
# E.G. bindir='${exec_prefix}/bin
#
# So we do the translation by hand in the expandvars function
#
RAW_EXEC_PREFIX = "@exec_prefix@"
RAW_EXEC_DIR = "@libexecdir@"
RAW_DATA_DIR = "@datadir@"
RAW_DATAROOT_DIR = "@datarootdir@"
RAW_BINDIR = "@bindir@"
EXEC_PREFIX = os.path.normpath (expandvars (RAW_EXEC_DIR)) TRACKER_EXTRACT_PATH = os.path.normpath(expandvars(config['TRACKER_EXTRACT_PATH']))
DATADIR = os.path.normpath (expandvars (RAW_DATA_DIR)) TRACKER_MINER_FS_PATH = os.path.normpath(expandvars(config['TRACKER_MINER_FS_PATH']))
BINDIR = os.path.normpath (expandvars (RAW_BINDIR)) TRACKER_STORE_PATH = os.path.normpath(expandvars(config['TRACKER_STORE_PATH']))
TRACKER_WRITEBACK_PATH = os.path.normpath(expandvars(config['TRACKER_WRITEBACK_PATH']))
haveUpstart = ("@HAVE_UPSTART_TRUE@" == "")
disableJournal = ("@DISABLE_JOURNAL_TRUE@" == "")
TEST_TMP_DIR = os.path.join (os.environ["HOME"], "tracker-tests") TEST_TMP_DIR = os.path.join (os.environ["HOME"], "tracker-tests")
...@@ -93,3 +93,12 @@ if TEST_TMP_DIR.startswith('/tmp'): ...@@ -93,3 +93,12 @@ if TEST_TMP_DIR.startswith('/tmp'):
print ("HOME is in the /tmp prefix - this will cause tests that rely " + print ("HOME is in the /tmp prefix - this will cause tests that rely " +
"on filesystem monitoring to fail as changes in that prefix are " + "on filesystem monitoring to fail as changes in that prefix are " +
"ignored.") "ignored.")
BUILD_DIR = os.environ.get('TRACKER_FUNCTIONAL_TEST_BUILD_DIR')
def generated_ttl_dir():
if BUILD_DIR:
return os.path.join(BUILD_DIR, 'tests', 'functional-tests', 'ttl')
else:
return 'ttl'
...@@ -258,7 +258,7 @@ def get_tracker_extract_output(filename, mime_type=None): ...@@ -258,7 +258,7 @@ def get_tracker_extract_output(filename, mime_type=None):
Runs `tracker-extract --file` to extract metadata from a file. Runs `tracker-extract --file` to extract metadata from a file.
""" """
tracker_extract = os.path.join (cfg.EXEC_PREFIX, 'tracker-extract') tracker_extract = os.path.join (cfg.TRACKER_EXTRACT_PATH)
command = [tracker_extract, '--file', filename] command = [tracker_extract, '--file', filename]
if mime_type is not None: if mime_type is not None:
command.extend(['--mime', mime_type]) command.extend(['--mime', mime_type])
...@@ -267,8 +267,8 @@ def get_tracker_extract_output(filename, mime_type=None): ...@@ -267,8 +267,8 @@ def get_tracker_extract_output(filename, mime_type=None):
log ('Running: %s' % ' '.join(command)) log ('Running: %s' % ' '.join(command))
output = subprocess.check_output (command) output = subprocess.check_output (command)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
raise Exception("Error %i from tracker-extract, output: %s" % raise Exception("Error %i from %s, output: %s" %
(e.returncode, e.output)) (e.returncode, tracker_extract, e.output))
parser = ExtractorParser() parser = ExtractorParser()
return parser.parse_tracker_extract_output(output) return parser.parse_tracker_extract_output(output)
...@@ -78,9 +78,7 @@ class Helper: ...@@ -78,9 +78,7 @@ class Helper:
sys.excepthook = new_hook sys.excepthook = new_hook
def _start_process (self): def _start_process (self):
path = getattr (self, path = self.PROCESS_PATH
"PROCESS_PATH",
os.path.join (cfg.EXEC_PREFIX, self.PROCESS_NAME))
flags = getattr (self, flags = getattr (self,
"FLAGS", "FLAGS",
[]) [])
...@@ -93,7 +91,10 @@ class Helper: ...@@ -93,7 +91,10 @@ class Helper:
command = [path] + flags command = [path] + flags
log ("Starting %s" % ' '.join(command)) log ("Starting %s" % ' '.join(command))
return subprocess.Popen ([path] + flags, **kws) try:
return subprocess.Popen ([path] + flags, **kws)
except OSError as e:
raise RuntimeError("Error starting %s: %s" % (path, e))
def _bus_name_appeared(self, name, owner, data): def _bus_name_appeared(self, name, owner, data):
log ("[%s] appeared in the bus as %s" % (self.PROCESS_NAME, owner)) log ("[%s] appeared in the bus as %s" % (self.PROCESS_NAME, owner))
...@@ -212,6 +213,7 @@ class StoreHelper (Helper): ...@@ -212,6 +213,7 @@ class StoreHelper (Helper):
""" """
PROCESS_NAME = "tracker-store" PROCESS_NAME = "tracker-store"
PROCESS_PATH = cfg.TRACKER_STORE_PATH
BUS_NAME = cfg.TRACKER_BUSNAME BUS_NAME = cfg.TRACKER_BUSNAME
graph_updated_handler_id = 0 graph_updated_handler_id = 0
...@@ -469,6 +471,9 @@ class StoreHelper (Helper): ...@@ -469,6 +471,9 @@ class StoreHelper (Helper):
def update (self, update_sparql, timeout=5000, **kwargs): def update (self, update_sparql, timeout=5000, **kwargs):
return self.resources.SparqlUpdate ('(s)', update_sparql, timeout=timeout, **kwargs) return self.resources.SparqlUpdate ('(s)', update_sparql, timeout=timeout, **kwargs)
def load (self, ttl_uri, timeout=5000, **kwargs):
return self.resources.Load ('(s)', ttl_uri, timeout=timeout, **kwargs)
def batch_update (self, update_sparql, **kwargs): def batch_update (self, update_sparql, **kwargs):
return self.resources.BatchSparqlUpdate ('(s)', update_sparql, **kwargs) return self.resources.BatchSparqlUpdate ('(s)', update_sparql, **kwargs)
...@@ -542,7 +547,7 @@ class StoreHelper (Helper): ...@@ -542,7 +547,7 @@ class StoreHelper (Helper):
class MinerFsHelper (Helper): class MinerFsHelper (Helper):
PROCESS_NAME = 'tracker-miner-fs' PROCESS_NAME = 'tracker-miner-fs'
PROCESS_PATH = os.path.join (cfg.EXEC_PREFIX, "tracker-miner-fs") PROCESS_PATH = cfg.TRACKER_MINER_FS_PATH
BUS_NAME = cfg.MINERFS_BUSNAME BUS_NAME = cfg.MINERFS_BUSNAME
FLAGS = ['--initial-sleep=0'] FLAGS = ['--initial-sleep=0']
...@@ -567,11 +572,12 @@ class MinerFsHelper (Helper): ...@@ -567,11 +572,12 @@ class MinerFsHelper (Helper):
class ExtractorHelper (Helper): class ExtractorHelper (Helper):
PROCESS_NAME = 'tracker-extract' PROCESS_NAME = 'tracker-extract'
PROCESS_PATH = cfg.TRACKER_EXTRACT_PATH
BUS_NAME = cfg.TRACKER_EXTRACT_BUSNAME BUS_NAME = cfg.TRACKER_EXTRACT_BUSNAME
class WritebackHelper (Helper): class WritebackHelper (Helper):
PROCESS_NAME = 'tracker-writeback' PROCESS_NAME = 'tracker-writeback'
PROCESS_PATH = os.path.join (cfg.EXEC_PREFIX, 'tracker-writeback') PROCESS_PATH = cfg.TRACKER_WRITEBACK_PATH
BUS_NAME = cfg.WRITEBACK_BUSNAME BUS_NAME = cfg.WRITEBACK_BUSNAME
...@@ -19,9 +19,7 @@ import helpers ...@@ -19,9 +19,7 @@ import helpers
TEST_ENV_DIRS = { "XDG_DATA_HOME" : os.path.join (cfg.TEST_TMP_DIR, "data"), TEST_ENV_DIRS = { "XDG_DATA_HOME" : os.path.join (cfg.TEST_TMP_DIR, "data"),
"XDG_CACHE_HOME": os.path.join (cfg.TEST_TMP_DIR, "cache")} "XDG_CACHE_HOME": os.path.join (cfg.TEST_TMP_DIR, "cache")}
TEST_ENV_VARS = { "LC_COLLATE": "en_GB.utf8", TEST_ENV_VARS = { "LC_COLLATE": "en_GB.utf8" }
"DCONF_PROFILE": os.path.join (cfg.DATADIR, "tracker-tests",
"trackertest") }
EXTRA_DIRS = [os.path.join (cfg.TEST_TMP_DIR, "data", "tracker"), EXTRA_DIRS = [os.path.join (cfg.TEST_TMP_DIR, "data", "tracker"),
os.path.join (cfg.TEST_TMP_DIR, "cache", "tracker")] os.path.join (cfg.TEST_TMP_DIR, "cache", "tracker")]
...@@ -35,6 +33,7 @@ class UnableToBootException (Exception): ...@@ -35,6 +33,7 @@ class UnableToBootException (Exception):
class TrackerSystemAbstraction (object): class TrackerSystemAbstraction (object):
def __init__(self, settings=None, ontodir=None): def __init__(self, settings=None, ontodir=None):
self.set_up_environment (settings=settings, ontodir=ontodir) self.set_up_environment (settings=settings, ontodir=ontodir)
self.store = None
def set_up_environment (self, settings=None, ontodir=None): def set_up_environment (self, settings=None, ontodir=None):
""" """
......
{
"PREFIX": "@prefix@",
"RAW_EXEC_PREFIX": "@exec_prefix@",
"RAW_DATAROOT_DIR": "@datarootdir@",
"TRACKER_EXTRACT_PATH": "@FUNCTIONAL_TESTS_TRACKER_EXTRACT_PATH@",
"TRACKER_MINER_FS_PATH": "@FUNCTIONAL_TESTS_TRACKER_MINER_FS_PATH@",
"TRACKER_STORE_PATH": "@FUNCTIONAL_TESTS_TRACKER_STORE_PATH@",
"TRACKER_WRITEBACK_PATH": "@FUNCTIONAL_TESTS_TRACKER_WRITEBACK_PATH@"
}
test_runner = find_program('test-runner.sh') test_runner = find_program('test-runner.sh')
config_json = configure_file(
input: 'configuration.json.in',
output: 'configuration.json',
configuration: conf
)
functional_tests = [ functional_tests = [
'300-miner-basic-ops', '300-miner-basic-ops',
'301-miner-resource-removal', '301-miner-resource-removal',
...@@ -12,9 +18,22 @@ functional_tests = [ ...@@ -12,9 +18,22 @@ functional_tests = [
'601-applications-sync', '601-applications-sync',
] ]
config_json_full_path = join_paths(meson.current_build_dir(), 'configuration.json')
dconf_profile_full_path = join_paths(meson.current_source_dir(), 'trackertest')
tracker_extractors_dir = join_paths(meson.current_build_dir(), '..', '..', 'src', 'tracker-extract')
tracker_extractor_rules_dir = join_paths(meson.current_source_dir(), '..', '..', 'src', 'tracker-extract')
test_env = environment()
test_env.set('DCONF_PROFILE', dconf_profile_full_path)
test_env.set('TRACKER_EXTRACTORS_DIR', tracker_extractors_dir)
test_env.set('TRACKER_EXTRACTOR_RULES_DIR', tracker_extractor_rules_dir)
test_env.set('TRACKER_FUNCTIONAL_TEST_CONFIG', config_json_full_path)
foreach t: functional_tests foreach t: functional_tests
test('functional-' + t, test_runner, test('functional-' + t, test_runner,
args: './' + t + '.py', args: './' + t + '.py',
env: test_env,
workdir: meson.current_source_dir(), workdir: meson.current_source_dir(),
# FIXME: these tests are all too slow # FIXME: these tests are all too slow
timeout: 180) timeout: 180)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment