From 67bc0739f83ba7db0ef1c22708e2f3636b2f5fb8 Mon Sep 17 00:00:00 2001
From: Xavier Claessens <xavier.claessens@collabora.com>
Date: Tue, 25 Aug 2015 14:54:24 +0000
Subject: [PATCH] tracker: Rewrite tests in python

Summary:
This is mostly a 1-1 translation. Tests are not smarter than
what they were before, to the exception that they don't include
sleep() of arbitrary duration everywhere.

Reviewers: smcv, pwith

Differential Revision: https://phabricator.apertis.org/D377
---
 common/tracker-utils.sh                       | 115 ------
 tracker-configuration/automated/Makefile      |  16 -
 tracker-configuration/automated/README        |   4 -
 tracker-configuration/automated/config.sh     |   1 -
 .../automated/inherit-config.sh               |  13 -
 tracker-configuration/automated/run-test.sh   |  63 ---
 tracker/automated/Makefile                    |  23 --
 tracker/automated/config.sh                   |   1 -
 .../grilo-local-storage-tracker-browse.c      | 173 --------
 tracker/automated/inherit-config.sh           |   1 -
 tracker/automated/run-test.sh                 | 370 ------------------
 tracker/automated/tracker-metadata-search.c   | 103 -----
 tracker/manual/Makefile                       |  24 --
 tracker/manual/automount-removable-device.c   | 179 ---------
 tracker/manual/config.sh                      |   1 -
 tracker/manual/inherit-config.sh              |   1 -
 tracker/manual/run-test.sh                    |  82 ----
 tracker/manual/wait-for-new-removable-mount.c |  52 ---
 18 files changed, 1222 deletions(-)
 delete mode 100644 common/tracker-utils.sh
 delete mode 100644 tracker-configuration/automated/Makefile
 delete mode 100644 tracker-configuration/automated/README
 delete mode 100644 tracker-configuration/automated/config.sh
 delete mode 100644 tracker-configuration/automated/inherit-config.sh
 delete mode 100755 tracker-configuration/automated/run-test.sh
 delete mode 100644 tracker/automated/Makefile
 delete mode 100644 tracker/automated/config.sh
 delete mode 100644 tracker/automated/grilo-local-storage-tracker-browse.c
 delete mode 120000 tracker/automated/inherit-config.sh
 delete mode 100755 tracker/automated/run-test.sh
 delete mode 100644 tracker/automated/tracker-metadata-search.c
 delete mode 100644 tracker/manual/Makefile
 delete mode 100644 tracker/manual/automount-removable-device.c
 delete mode 100644 tracker/manual/config.sh
 delete mode 120000 tracker/manual/inherit-config.sh
 delete mode 100755 tracker/manual/run-test.sh
 delete mode 100644 tracker/manual/wait-for-new-removable-mount.c

diff --git a/common/tracker-utils.sh b/common/tracker-utils.sh
deleted file mode 100644
index 9d42d0b..0000000
--- a/common/tracker-utils.sh
+++ /dev/null
@@ -1,115 +0,0 @@
-# Source me!
-# vim: set sts=4 sw=4 et :
-
-TRACKER_MINER_SCHEMA="org.freedesktop.Tracker.Miner.Files"
-TRACKER_CONTROL="${TRACKER_CONTROL:-tracker-control}"
-TRACKER_INFO="${TRACKER_INFO:-tracker-info}"
-
-_reset_tracker_config() {
-    # Flush all configuration, processes, and databases
-    tracker-control -r -c
-    reset_gsettings_schema "${TRACKER_MINER_SCHEMA}"
-}
-
-_monitor_indexing_status() {
-    ${TRACKER_CONTROL} -F > ${TRACKER_MINER_LOG} &
-    TRACKER_MONITOR_PID=$!
-    # Sync after writing to log
-    sync
-}
-
-# Wait till tracker-store commits all data
-_wait_tracker_store_commit() {
-    ${GDBUS} call --session \
-        --dest org.freedesktop.Tracker1 \
-        --object-path /org/freedesktop/Tracker1/Status \
-        --method org.freedesktop.Tracker1.Status.Wait
-    # The Resources.{BatchCommit,Sync} DBus methods are not enough to get rid
-    # of the race condition between completion of indexing and commit of all 
-    # data to disk, hence we flush tracker databases to disk manually
-    sync
-    _sleep 3
-}
-
-_kill_monitor() {
-    kill -s TERM ${TRACKER_MONITOR_PID}
-}
-
-_spin_on_indexing_restart() {
-    # Sync before file access
-    sync
-    # Spin till Tracker picks up changes and starts to re-index them
-    while ! grep -ae "File System.*Processing" "${TRACKER_MINER_LOG}"; do
-        sleep 0.1
-        tail -n 1 "${TRACKER_MINER_LOG}" | grep -e "File System"
-    done
-}
-
-_spin_on_indexing_finish() {
-    # Sync before file access
-    sync
-    # Spin till Tracker initialises and finishes indexing
-    while ! grep -ae "File System.*Idle" "${TRACKER_MINER_LOG}"; do
-        sleep 0.1
-        tail -n 1 "${TRACKER_MINER_LOG}" | grep -e "File System"
-    done
-    _wait_tracker_store_commit
-}
-
-_is_indexed() {
-    _sleep 3
-    ${TRACKER_INFO} "${@}" | grep -qe "'tracker:"
-}
-
-_is_playable() {
-    ${TRACKER_INFO} "${@}" | grep -qe "'bosch:playable' = 'true'"
-}
-
-_is_not_indexed() {
-    ! _is_indexed
-}
-
-_check_index_status() {
-    local j wait_t res ret=0
-    local check_function=$1
-    local err_msg=$2
-    shift 2
-    # Check if all the files have been indexed
-    for j in "$@"; do
-        ${check_function} "${j}"
-        # Complain for each file that wasn't indexed, and set the retcode
-        if [[ "$?" -ne 0 ]]; then
-            whine "${err_msg} '$j'!"
-            ret=1
-        fi
-    done
-    return ${ret}
-}
-
-_check_args_indexed() {
-    _check_index_status _is_indexed "Tracker didn't index the file" "$@"
-}
-
-_check_args_not_indexed() {
-    _check_index_status _is_not_indexed "Tracker *did* index the file" "$@"
-}
-
-_check_args_playable() {
-    _check_index_status _is_playable "Tracker didn't set playable flag" "$@"
-}
-
-_do_initial_indexing() {
-    # Write all data out to disk, to avoid races
-    sync
-    # Begin indexing
-    ${TRACKER_CONTROL} -s 
-    _monitor_indexing_status
-    # Wait for indexing to complete
-    _spin_on_indexing_finish
-}
-
-_get_tracker_info_values() {
-    local id=$1
-    local key=$2
-    ${TRACKER_INFO} "$id" | sed -ne "s/\s\+'$key' = '\(.*\)'/\1/p"
-}
diff --git a/tracker-configuration/automated/Makefile b/tracker-configuration/automated/Makefile
deleted file mode 100644
index 3f55428..0000000
--- a/tracker-configuration/automated/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# vim: set ts=8 tw=80 :
-
-progs		:= 
-
-include ../../global-config.mk
-
-all: $(progs)
-
-get-deps:
-	# libglib2.0-bin for `gsettings`
-	# binutils for `objdump`
-	$(APT_GET) install libglib2.0-bin binutils
-
-install: .INSTALL
-
-clean: .CLEAN
diff --git a/tracker-configuration/automated/README b/tracker-configuration/automated/README
deleted file mode 100644
index 1c66484..0000000
--- a/tracker-configuration/automated/README
+++ /dev/null
@@ -1,4 +0,0 @@
-Debug output variables:
-
-* DEBUG=1 will make the script show stdout
-* DEBUG=2 will make the script show stderr+stdout
diff --git a/tracker-configuration/automated/config.sh b/tracker-configuration/automated/config.sh
deleted file mode 100644
index 7d6e7cf..0000000
--- a/tracker-configuration/automated/config.sh
+++ /dev/null
@@ -1 +0,0 @@
-. "${TESTDIR}/inherit-config.sh"
diff --git a/tracker-configuration/automated/inherit-config.sh b/tracker-configuration/automated/inherit-config.sh
deleted file mode 100644
index 5a22577..0000000
--- a/tracker-configuration/automated/inherit-config.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-# This file should be symlinked inside your test directory,
-# and sourced from config.sh
-# It will be modified and copied to the install directory by make
-
-. "${TESTDIR}/../../common/common.sh"
-
-# These variables get modified by `make` during install
-TESTDATADIR="${TESTDIR}"
-TESTLIBDIR="${TESTDIR}"
-RESOURCE_DIR="$(_realpath ${TESTDIR}/../../resources)"
-
-# These are derived from the above
-MEDIA_RESOURCE_DIR="${RESOURCE_DIR}/media"
diff --git a/tracker-configuration/automated/run-test.sh b/tracker-configuration/automated/run-test.sh
deleted file mode 100755
index c3ea4a0..0000000
--- a/tracker-configuration/automated/run-test.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/bash
-# vim: set sts=4 sw=4 et tw=0 :
-
-set -e
-
-TESTDIR=$(cd $(dirname $0); pwd; cd - &>/dev/null)
-. "${TESTDIR}/config.sh"
-. "${TESTDIR}/../../common/tracker-utils.sh"
-
-#########
-# Setup #
-#########
-trap "setup_failure" ERR
-
-# Need a DBus session for this test
-ensure_dbus_session
-
-setup_success
-
-###########
-# Execute #
-###########
-test_removable_index_status() {
-    gsettings_key_is "${TRACKER_MINER_SCHEMA}" index-removable-devices true \
-        || return 1
-
-    # How long we should store data for files on removable media since the last
-    # time it was mounted, in days. This number is arbitrary but it needs to be
-    # reasonably large given that the penalty for aggressive cleanup is a slow
-    # indexing process for media the user probably wants to access immediately
-    gsettings_key_is "${TRACKER_MINER_SCHEMA}" removable-days-threshold 60 \
-        || return 1
-
-    # Never wait before starting to mine
-    gsettings_key_is "${TRACKER_MINER_SCHEMA}" initial-sleep 0 || return 1
-    gsettings_key_is "${TRACKER_MINER_SCHEMA}" sched-idle "'never'" || return 1
-    gsettings_key_is "${TRACKER_MINER_SCHEMA}" enable-monitors true || return 1
-}
-
-test_journal_disabled() {
-    local output=$(objdump -T /usr/lib*/tracker*/libtracker-data.so.0)
-    grep -qe tracker_db_journal_init <<<"${output}" && return 1
-    return 0
-}
-
-test_monitoring_enabled() {
-    gsettings_key_is "${TRACKER_MINER_SCHEMA}" enable-monitors true
-}
-
-test_writeback_disabled() {
-    gsettings_key_is "${TRACKER_MINER_SCHEMA}" enable-writeback false
-}
-
-trap "test_failure" ERR
-
-src_test_pass <<-EOF
-test_removable_index_status
-test_journal_disabled
-test_monitoring_enabled
-EOF
-#test_writeback_disabled
-
-test_success
diff --git a/tracker/automated/Makefile b/tracker/automated/Makefile
deleted file mode 100644
index 0937c2b..0000000
--- a/tracker/automated/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# vim: set ts=8 tw=80 :
-
-progs := \
-	grilo-local-storage-tracker-browse \
-	tracker-metadata-search \
-	$(NULL)
-
-include ../../global-config.mk
-
-all: $(progs)
-
-tracker-metadata-search: tracker-metadata-search.c
-	$(CC) $(CFLAGS) -o $@ $< $(shell $(PKG_CONFIG) --libs --cflags tracker-sparql-1.0)
-
-grilo-local-storage-tracker-browse: grilo-local-storage-tracker-browse.c
-	$(CC) $(CFLAGS) -o $@ $< $(shell $(PKG_CONFIG) --libs --cflags grilo-0.2)
-
-get-deps:
-	$(APT_GET) install libglib2.0-bin libtracker-sparql-1.0-dev pkg-config libgrilo-0.2-dev
-
-install: .INSTALL
-
-clean: .CLEAN
diff --git a/tracker/automated/config.sh b/tracker/automated/config.sh
deleted file mode 100644
index 7d6e7cf..0000000
--- a/tracker/automated/config.sh
+++ /dev/null
@@ -1 +0,0 @@
-. "${TESTDIR}/inherit-config.sh"
diff --git a/tracker/automated/grilo-local-storage-tracker-browse.c b/tracker/automated/grilo-local-storage-tracker-browse.c
deleted file mode 100644
index daa415d..0000000
--- a/tracker/automated/grilo-local-storage-tracker-browse.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/* vim: set sts=2 sw=2 et : */ 
-/*
- * Browsing in Grilo.
- * Shows the first BROWSE_CHUNK_SIZE elements of each browsable source
- *
- * XXX: No pagination yet! See grilo-test-ui. It's somewhat complicated.
- */
-
-#include <grilo.h>
-
-#define GRL_LOG_DOMAIN_DEFAULT  example_log_domain
-GRL_LOG_DOMAIN_STATIC(example_log_domain);
-
-#define BROWSE_CHUNK_SIZE 10
-
-static void source_browser (gpointer data,
-                            gpointer user_data);
-static void element_browser (gpointer data,
-                             gpointer user_data);
-
-/* The grl-tracker plugin returns no sources if it's loaded synchronously.
- * But we need a test program that runs and exits without interaction.
- * So, we use a global loop and quit once we're done. */
-static GMainLoop *loop;
-/* Once Tracker source is loaded we can quit */
-static gint sources_count = 0;
-
-static void
-element_browser (gpointer data,
-                 gpointer user_data)
-{
-  GrlMedia *media = GRL_MEDIA (data);
-  GrlSource *source = GRL_SOURCE (user_data);
-
-  /* Check if we got a valid media object as some plugins may call the callback
-     with a NULL media under certain circumstances (for example when they
-     cannot estimate the number of remaining results and they find suddenly they
-     don't have any more results to send) */
-  if (!media) {
-    g_debug ("Media element is NULL!");
-    goto out;
-  }
-  
-  const gchar *title = grl_media_get_title (media);
-
-  /* If the media is a container (box), that means we will browse it again */
-  if (GRL_IS_MEDIA_BOX (media)) {
-    guint childcount = grl_media_box_get_childcount (GRL_MEDIA_BOX (media));
-    g_debug ("\t Got '%s' (container with %d elements)", title, childcount);
-
-    source_browser (source, media);
-  } else {
-    const gchar *url = grl_media_get_url (media);
-    // Thumbnail fetching isn't working? Unsure.
-    const gchar *thumbnail = grl_media_get_thumbnail (media);
-    if (GRL_IS_MEDIA_AUDIO (media)) {
-      const gchar *artist = grl_media_audio_get_artist (GRL_MEDIA_AUDIO (media));
-      const gchar *album = grl_media_audio_get_album (GRL_MEDIA_AUDIO (media));
-      g_printf ("\t Got '%s' by the artist '%s' from the album '%s'\n",
-               title, artist, album);
-    } else {
-      g_printf ("\t Got '%s'\n", title);
-    }
-    g_printf ("\t\t URL: %s\n", url);
-    g_printf ("\t\t Thumbnail: %s\n", thumbnail);
-  }
-
-out:
-  g_object_unref (media);
-}
-
-static void
-source_browser (gpointer data,
-                gpointer user_data)
-{
-  GrlSource *source = GRL_SOURCE (data);
-  GrlMedia *media = GRL_MEDIA (user_data);
-  GList *media_elements;
-  GError *error = NULL;
-  GList *keys;
-  GrlOperationOptions *options;
-  GrlCaps *caps;
-
-  keys = grl_metadata_key_list_new (GRL_METADATA_KEY_TITLE,
-                                    GRL_METADATA_KEY_ALBUM,
-                                    GRL_METADATA_KEY_ARTIST,
-                                    GRL_METADATA_KEY_THUMBNAIL,
-                                    GRL_METADATA_KEY_URL,
-                                    GRL_METADATA_KEY_CHILDCOUNT,
-                                    NULL);
-
-  g_debug ("Detected new source available: '%s'",
-	   grl_source_get_name (source));
-
-  if (!(grl_source_supported_operations (source) & GRL_OP_BROWSE))
-    goto out;
-
-  g_debug ("Browsing source: %s", grl_source_get_name (source));
-  /* Here is how you can browse a source, you have to provide:
-     1) The source you want to browse contents from.
-     2) The container object you want to browse (NULL for the root container)
-     3) A list of metadata keys we are interested in.
-     4) Options to control certain aspects of the browse operation.
-     5) A callback that the framework will invoke for each available result
-     6) User data for the callback
-     It returns an operation identifier that you can use to match results
-     with the corresponding request (we ignore it here) */
-
-  caps = grl_source_get_caps (source, GRL_OP_BROWSE);
-  options = grl_operation_options_new (caps);
-  grl_operation_options_set_count (options, BROWSE_CHUNK_SIZE);
-  grl_operation_options_set_flags (options, GRL_RESOLVE_IDLE_RELAY);
-
-  media_elements = grl_source_browse_sync (GRL_SOURCE (source),
-                                           media, keys,
-                                           options,
-                                           &error);
-  if (!media_elements) {
-    g_debug ("No elements found for source: %s!",
-             grl_source_get_name (source));
-    goto out;
-  }
-
-  if (error)
-    g_error ("Failed to browse source: %s", error->message);
-
-  g_list_foreach (media_elements, element_browser, source);
-
-out:
-  g_list_free (keys);
-}
-
-static void
-source_added_cb (GrlRegistry *registry, gpointer user_data)
-{
-  GrlSource *source = GRL_SOURCE (user_data);
-  g_debug ("Detected new source available: '%s'",
-           grl_source_get_name (source));
-  sources_count++;
-
-  source_browser (source, NULL);
-
-  if (sources_count > 0)
-    g_main_loop_quit (loop);
-}
-
-static void
-load_plugins (void)
-{
-  GrlRegistry *registry;
-  GError *error = NULL;
-
-  registry = grl_registry_get_default ();
-
-  if (!grl_registry_load_plugin_by_id (registry, "grl-tracker", &error))
-    g_error ("Failed to load tracker plugin: %s", error->message);
-  
-  g_signal_connect (registry, "source-added",
-                    G_CALLBACK (source_added_cb), NULL);
-}
-
-gint
-main (int argc, gchar *argv[])
-{
-  grl_init (&argc, &argv);
-  GRL_LOG_DOMAIN_INIT (example_log_domain, "example");
-  load_plugins ();
-  /* Run the main loop */
-  loop = g_main_loop_new (NULL, FALSE);
-  g_main_loop_run (loop);
-  return 0;
-}
-
diff --git a/tracker/automated/inherit-config.sh b/tracker/automated/inherit-config.sh
deleted file mode 120000
index 1746371..0000000
--- a/tracker/automated/inherit-config.sh
+++ /dev/null
@@ -1 +0,0 @@
-../../inherit-config.sh
\ No newline at end of file
diff --git a/tracker/automated/run-test.sh b/tracker/automated/run-test.sh
deleted file mode 100755
index 3fc4634..0000000
--- a/tracker/automated/run-test.sh
+++ /dev/null
@@ -1,370 +0,0 @@
-#!/bin/bash
-# vim: set sts=4 sw=4 et tw=0 :
-#
-
-set -e
-
-TESTDIR=$(cd $(dirname $0); pwd; cd - &>/dev/null)
-
-. "${TESTDIR}/config.sh"
-. "${TESTDIR}/../../common/tracker-utils.sh"
-. "${TESTDIR}/../../common/thumbnailer-utils.sh"
-
-#########
-# Setup #
-#########
-configure_tracker() {
-    _reset_tracker_config
-    # Disable all indexing
-    set_gsettings_key "${TRACKER_MINER_SCHEMA}" index-recursive-directories "[]"
-    set_gsettings_key "${TRACKER_MINER_SCHEMA}" index-single-directories "[]"
-    # Never wait before starting to mine
-    set_gsettings_key "${TRACKER_MINER_SCHEMA}" initial-sleep 0
-    set_gsettings_key "${TRACKER_MINER_SCHEMA}" sched-idle never
-}
-
-trap "setup_failure" ERR
-
-set -x
-# Need a DBus session for this test
-ensure_dbus_session
-
-configure_tracker
-set +x
-
-setup_success
-
-###########
-# Execute #
-###########
-TRACKER_MINER_LOG="${WORKDIR}/tracker-miner.log"
-
-_reset_index_config() {
-    # Wipe the database so that we don't get unpredictable query replies
-    tracker-control -r
-
-    # Kill all tracker processes. Do this via systemctl rather than
-    # tracker-control to avoid systemd respawning the process.
-    tracker-control -t
-    systemctl --user stop tracker-store tracker-miner-fs
-
-    # Set indexing configuration
-    if [[ -n "$1" ]]; then
-        set_gsettings_key "${TRACKER_MINER_SCHEMA}" index-single-directories "['${1}']"
-    else
-        set_gsettings_key "${TRACKER_MINER_SCHEMA}" index-single-directories "[]"
-    fi
-    if [[ -n "$2" ]]; then
-        set_gsettings_key "${TRACKER_MINER_SCHEMA}" index-recursive-directories "['${2}']"
-    else
-        set_gsettings_key "${TRACKER_MINER_SCHEMA}" index-recursive-directories "[]"
-    fi
-}
-
-_test_indexing() {
-    set -x
-    local ret=0
-    local tempdir=$(create_temp_workdir)
-    local indexdir="${MEDIA_RESOURCE_DIR}/$1"
-
-    # Kill all tracker processes, reset configuration
-    _reset_index_config "${indexdir}"
-
-    _do_initial_indexing
-
-    _check_args_indexed "${indexdir}"/* || ret=1
-    _kill_monitor
-    _reset_tracker_config
-    set +x
-    return $ret
-}
-
-test_recursive_indexing() {
-    set -x
-    local i
-    local ret=0
-    local tempdir=$(create_temp_workdir)
-    local indexdir="${MEDIA_RESOURCE_DIR}"
-    local uris=()
-
-    # Kill all tracker processes, reset configuration
-    _reset_index_config "" "${indexdir}"
-
-    _do_initial_indexing
-
-    _check_args_indexed "${indexdir}/"*/* || ret=1
-    _check_args_playable "${indexdir}/"videos/* "${indexdir}/"audio/*.{flac,wav} || ret=1
-
-    for i in "${indexdir}/"*/*.{jpg,pdf,odt,ods,odp,png,ogv}; do
-        uris+=("file://$i")
-    done
-    _check_uris_have_thumbnail normal $uris || ret=1
-
-    _kill_monitor
-    _reset_tracker_config
-    set +x
-    return $ret
-}
-
-test_audio_indexing() {
-    _test_indexing audio
-}
-
-test_playlist_indexing() {
-    _test_indexing playlists
-}
-
-test_video_indexing() {
-    _test_indexing videos
-}
-
-test_image_indexing() {
-    _test_indexing images
-}
-
-test_document_indexing() {
-    _test_indexing documents
-}
-
-test_playlist_contents_indexing(){
-    set -x
-    local i pos ret=0 count=0 playlist_entries=()
-    local tempdir=$(create_temp_workdir)
-    local playlist="Generic_Sounds.pls"
-
-    # Kill all tracker processes, reset configuration
-    _reset_index_config "" "${tempdir}"
-
-    # Copy data to be indexed because we need a specific subset of it
-    src_copy "${MEDIA_RESOURCE_DIR}/playlists/${playlist}" "${tempdir}"
-    src_copy "${MEDIA_RESOURCE_DIR}/audio/" "${tempdir}"
-    _do_initial_indexing
-
-    playlist_entries=($(_get_tracker_info_values "${tempdir}/${playlist}" \
-                        "nfo:hasMediaFileListEntry"))
-
-    # Check if playlist contents were indexed
-    if [[ "${#playlist_entries[@]}" == 0 ]]; then
-        whine "Tracker didn't index the playlist's contents"
-        ret=1
-    fi
-
-    # Check if playlist contents match
-    for i in "${playlist_entries[@]}"; do
-        : $((count++))
-        pos=$(_get_tracker_info_values "${i}" "nfo:listPosition")
-        if [[ "$pos" != "$count.0" ]]; then
-            whine "Tracker didn't extract the listPosition properly!"
-            ret=1
-        fi
-    done
-
-    _kill_monitor
-    _reset_tracker_config
-    set +x
-    return $ret
-}
-
-test_journal_disabled() {
-    set -x
-    local ret=0
-    # Kill all tracker processes. Do this via systemctl rather than
-    # tracker-control to avoid systemd respawning the process.
-    tracker-control -t
-    systemctl --user stop tracker-store tracker-miner-fs
-
-    # Restart mining
-    tracker-control -s
-
-    # Is the journal around?
-    [[ ! -f "${XDG_DATA_HOME:-${HOME}/.local/share}"/tracker/data/tracker-store.journal ]] || ret=1
-    set +x
-    return $ret
-}
-
-test_monitoring_add() {
-    set -x
-    local ret=0
-    local tempdir=$(create_temp_workdir)
-
-    # Kill all tracker processes, reset configuration
-    _reset_index_config "${tempdir}"
-
-    # Add files!
-    src_copy_contents "${MEDIA_RESOURCE_DIR}/images" "${tempdir}" 2>&1
-    _do_initial_indexing
-
-    # Add files again!
-    src_copy_contents "${MEDIA_RESOURCE_DIR}/documents" "${tempdir}" 2>&1
-    sync
-
-    # Wait for reindexing to complete
-    _spin_on_indexing_restart
-    _spin_on_indexing_finish
-
-    _check_args_indexed "${tempdir}"/* || ret=1
-    _kill_monitor
-    _reset_tracker_config
-    set +x
-    return $ret
-}
-
-test_monitoring_delete() {
-    set -x
-    local i pdf_files ret=0
-    local tempdir=$(create_temp_workdir)
-
-    # Kill all tracker processes, reset configuration
-    _reset_index_config "${tempdir}"
-
-    # Add document files!
-    src_copy_contents "${MEDIA_RESOURCE_DIR}/documents" "${tempdir}" 2>&1
-    _do_initial_indexing
-
-    # Delete pdf files!
-    for i in "${tempdir}"/*.pdf; do
-        pdf_files+=($i)
-    done
-    rm -rvf "${pdf_files[@]}"
-    sync
-
-    # Wait for indexing to complete
-    _spin_on_indexing_restart
-    _spin_on_indexing_finish
-
-    _check_args_indexed "${tempdir}/"* || ret=1
-    _check_args_not_indexed "${pdf_files[@]}" || ret=1
-    _kill_monitor
-    _reset_tracker_config
-    set +x
-    return $ret
-}
-
-test_monitoring_modify() {
-    set -x
-    local ret=0
-    local mod_file="lorem_text.txt"
-    local old_filesize new_filesize
-    local tempdir=$(create_temp_workdir)
-
-    # Kill all tracker processes, reset configuration
-    _reset_index_config "${tempdir}"
-
-    # Add document files!
-    src_copy "${MEDIA_RESOURCE_DIR}/documents/${mod_file}" "${tempdir}"
-    _do_initial_indexing
-
-    old_filesize=$(_get_tracker_info_values "${tempdir}/${mod_file}" "nfo:fileSize")
-
-    # Modify file
-    echo "NEW TEXT SOMETHING SOMETHING" >> "${tempdir}/${mod_file}"
-    # Sync after writing to file
-    sync
-
-    # Wait for reindexing to complete
-    _spin_on_indexing_restart
-    _spin_on_indexing_finish
-
-    new_filesize=$(_get_tracker_info_values "${tempdir}/${mod_file}" "nfo:fileSize")
-    [[ ${new_filesize} -gt ${old_filesize} ]] || ret=1
-    _kill_monitor
-    _reset_tracker_config
-    set +x
-    return $ret
-}
-
-# Get the Media content URI using specific Album/Artist/Title query terms
-test_query_metadata_info() {
-    set -x
-    local ret=0
-    local tempdir=$(create_temp_workdir)
-
-    # Kill all tracker processes, reset configuration
-    _reset_index_config "${tempdir}"
-
-    # Add tagged audio files!
-    src_copy "${MEDIA_RESOURCE_DIR}/audio/"*.{oga,mp3,flac} "${tempdir}"
-    _do_initial_indexing
-
-    if ! _check_args_indexed "${tempdir}"/*; then
-        whine "Audio files didn't even get indexed!"
-        _kill_monitor
-        _reset_tracker_config
-        set +x
-        return 1
-    fi
-
-    if ! [[ $("${TESTLIBDIR}/tracker-metadata-search" --album "GNOME Audio" | wc -l) -eq 4 ]]; then
-        whine "Album search failed!"
-        ret=1
-    elif ! [[ $("${TESTLIBDIR}/tracker-metadata-search" --artist "Conrad Parker" | wc -l) -eq 4 ]]; then
-        whine "Artist search failed!"
-        ret=1
-    elif ! [[ $("${TESTLIBDIR}/tracker-metadata-search" --title "GNOME Generic Sound" | wc -l) -eq 4 ]]; then
-        whine "Title search failed!"
-        ret=1
-    fi
-    _kill_monitor
-    _reset_tracker_config
-    set +x
-    return $ret
-}
-
-test_grilo_local_storage_tracker() {
-    set -x
-    local ret=0
-    local browsed_files_log="${WORKDIR}/browsed-files.log"
-    local browse_output_log="${WORKDIR}/browse-output.log"
-    local expected_files_log="${WORKDIR}/expected-files.log"
-    local expected_output_string="Got 'GNOME Generic Sound' by the artist 'Conrad Parker' from the album 'GNOME Audio'"
-    local tempdir=$(create_temp_workdir)
-
-    # Kill all tracker processes, reset configuration
-    _reset_index_config "" "${tempdir}"
-
-    # Copy data to be indexed
-    src_copy "${MEDIA_RESOURCE_DIR}/"{audio,videos,images} "${tempdir}"
-    _do_initial_indexing
-
-    # Compare expected browsing results with actual results
-    ls -1 "$tempdir/"{audio,videos,images}/* | sort > "${expected_files_log}"
-    # Sync after writing to file
-    sync
-    "${TESTLIBDIR}/grilo-local-storage-tracker-browse" | tee "${browse_output_log}" | \
-        sed -n 's|\s\+URL: file://\(.*\)|\1|p' | sort > "${browsed_files_log}"
-    # Sync after writing to file
-    sync
-    # Test whether all the files are browsed
-    if ! diff -u "${expected_files_log}" "${browsed_files_log}"; then
-        whine "Some files aren't being browsed by grilo!"
-        ret=1
-    # Test whether audio metadata is extracted properly
-    elif [[ $(grep -e "${expected_output_string}" "${browse_output_log}" | wc -l) != 4 ]]; then
-        whine "Grilo isn't extracting audio metadata properly!"
-        ret=1
-    fi
-    _kill_monitor
-    _reset_tracker_config
-    set +x
-    return $ret
-}
-
-trap "test_failure" ERR
-
-src_test_pass <<-EOF
-test_audio_indexing
-test_playlist_indexing
-test_video_indexing
-test_image_indexing
-test_document_indexing
-test_recursive_indexing
-test_playlist_contents_indexing
-test_journal_disabled
-test_monitoring_add
-test_monitoring_delete
-test_monitoring_modify
-test_query_metadata_info
-test_grilo_local_storage_tracker
-EOF
-
-test_success
diff --git a/tracker/automated/tracker-metadata-search.c b/tracker/automated/tracker-metadata-search.c
deleted file mode 100644
index b0217ad..0000000
--- a/tracker/automated/tracker-metadata-search.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* vim: set sts=4 sw=4 et tw=0 :
- *
- * Short program to query for media files based on metadata
- *
- */
-
-#include <tracker-sparql.h>
-
-static gchar *audio_album = NULL;
-static gchar *audio_artist = NULL;
-static gchar *audio_title = NULL;
-static gchar *audio_filter = NULL;
-
-static GOptionEntry entries[] = 
-{
-    { "album", 0, 0, G_OPTION_ARG_STRING, &audio_album, "Find matching albums", "<album>" },
-    { "artist", 0, 0, G_OPTION_ARG_STRING, &audio_artist, "Find matching artists", "<artist>" },
-    { "title", 0, 0, G_OPTION_ARG_STRING, &audio_title, "Find matching titles", "<title>" },
-    { "filter", 0, 0, G_OPTION_ARG_STRING, &audio_filter, "Find matching titles", "<title>" },
-    { NULL },
-};
-
-int main (int argc, const char **argv)
-{
-    GError *error = NULL;
-    TrackerSparqlConnection *connection;
-    TrackerSparqlCursor *cursor;
-    GOptionContext *context;
-    const gchar *query;
-
-    context = g_option_context_new ("- Search using multimedia metadata");
-    g_option_context_add_main_entries (context, entries, NULL);
-    if (!g_option_context_parse (context, &argc, (gchar***)&argv, &error)) {
-        g_printf ("option parsing failed: %s\n", error->message);
-        exit(1);
-    }
-
-    /* Build query manually */
-    /* Don't care about memory leaks */
-    query = "SELECT nie:url(?u) WHERE {\n";
-    if (audio_album) {
-        query = g_strdup_printf ("%s?u nmm:musicAlbum ?album . ?album nmm:albumTitle '%s'.\n", query, audio_album);
-    } if (audio_artist) {
-        query = g_strdup_printf ("%s?u nmm:performer ?performer . ?performer nmm:artistName '%s'.\n", query, audio_artist);
-    } if (audio_title) {
-        query = g_strdup_printf ("%s?u nie:title '%s' \n", query, audio_title);
-    } if (audio_filter) {
-        query = g_strdup_printf ("%s?u nie:url ?url FILTER regex(str(?url), '%s')\n", query, audio_filter);
-    }
-    query = g_strdup_printf("%s}", query);
-
-    /* Everything after this is copied from the Tracker SPARQL Query example */
-
-    /* Initialize GLib type system */
-    g_type_init ();
-
-    /* As we know only read-only queries will be done, it's enough
-     * to use a connection with only direct-access setup. The NULL
-     * represents a possible GCancellable.
-     */
-    connection = tracker_sparql_connection_get_direct (NULL, &error);
-    if (!connection) {
-        g_printerr ("Couldn't obtain a direct connection to the Tracker store: %s",
-                    error ? error->message : "unknown error");
-        g_clear_error (&error);
-
-        return 1;
-    }
-
-    /* Make a synchronous query to the store */
-    cursor = tracker_sparql_connection_query (connection, query, NULL, &error);
-
-    if (error) {
-        /* Some error happened performing the query, not good */
-        g_printerr ("Couldn't query the Tracker Store: '%s'",
-                    error ? error->message : "unknown error");
-        g_clear_error (&error);
-
-        return 1;
-    }
-
-    /* Check results... */
-    if (!cursor) {
-        g_print ("No results found :-/\n");
-    } else {
-        gint i = 0;
-
-        /* Iterate, synchronously, the results... */
-        while (tracker_sparql_cursor_next (cursor, NULL, &error)) {
-            g_print ("Result [%d]: %s\n",
-	             i++,
-	             tracker_sparql_cursor_get_string (cursor, 0, NULL));
-        }
-
-        //g_print ("A total of '%d' results were found\n", i);
-
-        g_object_unref (cursor);
-    }
-
-    g_object_unref (connection);
-
-    return 0;
-}
diff --git a/tracker/manual/Makefile b/tracker/manual/Makefile
deleted file mode 100644
index 708e167..0000000
--- a/tracker/manual/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# vim: set ts=8 tw=80 :
-
-progs		:= automount-removable-device wait-for-new-removable-mount
-
-include ../../global-config.mk
-
-LIBS		:= $(shell $(PKG_CONFIG) --libs --cflags gio-2.0)
-
-all: $(progs)
-
-wait-for-new-removable-mount: wait-for-new-removable-mount.c
-	$(CC) $(CFLAGS) -o $@ $@.c $(LIBS)
-
-automount-removable-device: automount-removable-device.c
-	$(CC) $(CFLAGS) -o $@ $@.c $(LIBS)
-
-get-deps:
-	# libglib2.0-dev for headers
-	# libglib2.0-bin for gsettings
-	$(APT_GET) install libglib2.0-dev libglib2.0-bin pkg-config gvfs
-
-install: .INSTALL
-
-clean: .CLEAN
diff --git a/tracker/manual/automount-removable-device.c b/tracker/manual/automount-removable-device.c
deleted file mode 100644
index 962c353..0000000
--- a/tracker/manual/automount-removable-device.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/* vim: set sts=4 sw=4 et :
- *
- * Mounts any removable devices that are attached to the system, and umounts
- * them on SIGINT/SIGTERM.
- *
- * Usage:
- * 1. Compile it:
- *  gcc $(pkg-config --libs --cflags gio-2.0) -o automount-removable-device{,.c}
- * 2. Run it:
- *  ./automount-removable-device
- * 3. Monitor the output of the command `mount` to keep track of what's mounted
- * 4. Insert USB device, and notice that it gets automatically mounted
- *
- * To unmount all devices mounted by this program, send SIGINT or SIGTERM to it.
- */
-
-#include <gio/gio.h>
-#include <glib.h>
-#include <glib-unix.h>
-
-static GMainLoop *loop;
-
-static void
-unmount_finished (GMount       *mount,
-                  GAsyncResult *res,
-                  gpointer      user_data)
-{
-    char *name;
-    GError *error = NULL;
-
-    name = g_mount_get_name (mount);
-    if (!g_mount_unmount_with_operation_finish (mount, res, &error)) {
-        g_warning ("Unmount of '%s' failed: %s", name, error->message);
-        g_error_free (error);
-    } else {
-        g_debug ("Unmount of '%s' completed", name);
-    }
-
-    g_free (name);
-    g_object_unref (mount);
-}
-
-static void
-umount_each (GMount   *mount,
-             gpointer  user_data)
-{
-    char *name;
-
-    name = g_mount_get_name (mount);
-    g_debug ("Umounting '%s'", name);
-    if (!g_mount_can_unmount (mount))
-        g_warning ("Can't umount %s", name);
-    g_mount_unmount_with_operation (mount,
-                                    G_MOUNT_UNMOUNT_NONE,
-                                    NULL, /* GMountOperation */
-                                    NULL, /* GCancellable */
-                                    (GAsyncReadyCallback) unmount_finished,
-                                    NULL);
-    g_free (name);
-}
-
-static gboolean
-eject_all (GList **all_mounts)
-{
-    if (!all_mounts)
-        /* Nothing mounted? */
-        return G_SOURCE_CONTINUE;
-
-    g_debug ("'%u' volumes mounted", g_list_length (*all_mounts));
-    /* Umount ALL the things */
-    g_list_foreach (*all_mounts, (GFunc) umount_each, NULL);
-    g_list_free (*all_mounts);
-    *all_mounts = NULL;
-    g_main_loop_quit (loop);
-
-    return G_SOURCE_CONTINUE;
-}
-
-static void
-volume_mounted_cb (GVolume       *volume,
-                   GAsyncResult  *res,
-                   GList        **all_mounts)
-{
-    GMount *mount;
-    GFile *location;
-    gchar *mount_path;
-    gchar *volume_name;
-    GError *error = NULL;
-
-    volume_name = g_volume_get_name (volume);
-
-    if (!g_volume_mount_finish (volume, res, &error))
-        g_error ("Unable to mount volume '%s': %s",
-                 volume_name, error->message);
-
-    mount = g_volume_get_mount (volume);
-    if (!mount)
-        g_error ("Volume '%s' failed to automount!", volume_name);
-    location = g_mount_get_default_location (mount);
-    mount_path = g_file_get_path (location);
-
-    g_debug ("Mounting of volume '%s' succeeded at '%s'",
-             volume_name, mount_path);
-    *all_mounts = g_list_prepend (*all_mounts, mount);
-
-out:
-    g_object_unref (location);
-    g_object_unref (volume);
-    g_free (mount_path);
-}
-
-static void
-volume_added_cb (GVolumeMonitor  *volume_monitor,
-                 GVolume         *volume,
-                 GList          **all_mounts)
-{
-    gchar *volume_name;
-
-    volume_name = g_volume_get_name (volume);
-
-    g_debug ("Mounting volume, '%s'", volume_name);
-
-    if (!g_volume_can_mount (volume)) {
-        g_debug ("The volume '%s' inserted cannot be mounted", volume_name);
-        goto out;
-    }
-
-    if (!g_volume_should_automount (volume)) {
-        g_debug ("The volume '%s' inserted will not be automounted", volume_name);
-        goto out;
-    }
-
-    g_volume_mount (volume,
-                    G_MOUNT_MOUNT_NONE,
-                    NULL, /* GMountOperation */
-                    NULL, /* GCancellable */
-                    (GAsyncReadyCallback) volume_mounted_cb,
-                    all_mounts);
-out:
-    g_free (volume_name);
-}
-
-static void
-volume_removed_cb (GVolumeMonitor  *volume_monitor,
-                   GVolume         *volume,
-                   GList          **all_mounts)
-{
-    gchar *volume_name;
-
-    volume_name = g_volume_get_name (volume);
-    g_debug ("Volume '%s' was removed", volume_name);
-    g_free (volume_name);
-}
-
-int
-main (int   argc,
-      char *argv[])
-{
-    GVolumeMonitor *volume_monitor;
-    /* Keep track of all the mounts to umount them on exit */
-    GList *all_mounts = NULL;
-
-    volume_monitor = g_volume_monitor_get ();
-    loop = g_main_loop_new (NULL, FALSE);
-
-    g_unix_signal_add (SIGINT, (GSourceFunc) eject_all, &all_mounts);
-    g_unix_signal_add (SIGTERM, (GSourceFunc) eject_all, &all_mounts);
-    g_signal_connect (volume_monitor, "volume-added",
-                      G_CALLBACK (volume_added_cb), &all_mounts);
-    g_signal_connect (volume_monitor, "volume-removed",
-                      G_CALLBACK (volume_removed_cb), &all_mounts);
-/*    g_signal_connect (volume_monitor, "volume-changed",
-                      G_CALLBACK (volume_changed_cb), NULL);*/
-    g_main_loop_run (loop);
-    g_object_unref (volume_monitor);
-    g_main_loop_unref (loop);
-
-    return 0;
-}
diff --git a/tracker/manual/config.sh b/tracker/manual/config.sh
deleted file mode 100644
index 7d6e7cf..0000000
--- a/tracker/manual/config.sh
+++ /dev/null
@@ -1 +0,0 @@
-. "${TESTDIR}/inherit-config.sh"
diff --git a/tracker/manual/inherit-config.sh b/tracker/manual/inherit-config.sh
deleted file mode 120000
index 1746371..0000000
--- a/tracker/manual/inherit-config.sh
+++ /dev/null
@@ -1 +0,0 @@
-../../inherit-config.sh
\ No newline at end of file
diff --git a/tracker/manual/run-test.sh b/tracker/manual/run-test.sh
deleted file mode 100755
index bd03c77..0000000
--- a/tracker/manual/run-test.sh
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/bash
-# vim: set sts=4 sw=4 et tw=0 :
-
-set -e
-
-TESTDIR=$(cd $(dirname $0); pwd; cd - &>/dev/null)
-. "${TESTDIR}/config.sh"
-. "${TESTDIR}/../../common/tracker-utils.sh"
-
-#########
-# Setup #
-#########
-_no_index_dirs() {
-    local key
-    key=$(get_gsettings_key "${TRACKER_MINER_SCHEMA}" index-single-directories)
-    [[ $key != "@as []" ]] && return 1
-    key=$(get_gsettings_key "${TRACKER_MINER_SCHEMA}" index-recursive-directories)
-    [[ $key != "@as []" ]] && return 1
-    return 0
-}
-
-trap "setup_failure" ERR
-
-# Need a DBus session for this test
-ensure_dbus_session
-
-echo "Killing all tracker processes and wiping DB"
-# Kill all tracker processes, wipe db
-tracker-control -r
-
-setup_success
-
-###########
-# Execute #
-###########
-TRACKER_MINER_LOG="${WORKDIR}/tracker-miner.log"
-
-_run_automounter() {
-    "${TESTLIBDIR}/automount-removable-device" &
-    AUTOMOUNT_CMD_PID=$!
-}
-
-_kill_automounter() {
-    kill -s TERM $AUTOMOUNT_CMD_PID
-}
-
-_unmount_drive() {
-    umount "${MOUNT_PATH}"
-}
-
-check_index_mass_storage_results() {
-    local ret=0
-
-    say "Restarting Tracker miners ..."
-    tracker-control -s
-    _monitor_indexing_status
-
-    say "Waiting for indexing to finish ..."
-    _spin_on_indexing_finish
-
-    say "Checking index ..."
-    _check_args_indexed "${1}"/* || ret=1
-
-    say "Done; killing monitor ..."
-    _kill_monitor
-    _unmount_drive
-    return $ret
-}
-
-trap "_kill_automounter; test_failure" ERR
-trap "_kill_automounter" EXIT
-
-_run_automounter
-
-whine "Please insert storage ..."
-MOUNT_PATH=$("${TESTLIBDIR}/wait-for-new-removable-mount")
-say "Copying test media files to storage ..."
-src_copy_contents "${MEDIA_RESOURCE_DIR}" "${MOUNT_PATH}"
-
-src_test_pass "$MOUNT_PATH" <<<check_index_mass_storage_results
-
-test_success
diff --git a/tracker/manual/wait-for-new-removable-mount.c b/tracker/manual/wait-for-new-removable-mount.c
deleted file mode 100644
index da86d16..0000000
--- a/tracker/manual/wait-for-new-removable-mount.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* vim: set sts=4 sw=4 et :
- *
- * Waits for a removable drive to be mounted, and then returns the mount path
- *
- */
-
-#include <gio/gio.h>
-#include <glib.h>
-#include <glib/gprintf.h>
-
-static GMainLoop *loop;
-
-void
-mount_added_cb (GVolumeMonitor *volume_monitor,
-                GMount         *mount,
-                gpointer        user_data)
-{
-    GFile *file;
-    gchar *location;
-
-    /* We don't use g_drive_is_media_removable() because it doesn't work */
-    if (!g_mount_can_eject (mount)) {
-        g_debug ("The media inserted is not removable");
-        goto out;
-    }
-
-    file = g_mount_get_default_location (mount);
-    location = g_file_get_parse_name (file);
-
-    g_debug ("Removable drive found at: %s", location);
-    g_printf ("%s\n", location);
-
-    g_object_unref (file);
-    g_main_loop_quit (loop);
-out:
-    return;
-}
-
-int
-main (int   argc,
-      char *argv[])
-{
-    GVolumeMonitor *volume_monitor;
-
-    volume_monitor = g_volume_monitor_get ();
-
-    g_signal_connect (volume_monitor, "mount-added",
-                      G_CALLBACK (mount_added_cb), NULL);
-    loop = g_main_loop_new (NULL, FALSE);
-    g_main_loop_run (loop);
-    return 0;
-}
-- 
GitLab