diff --git a/Makefile b/Makefile index d51bc74cb981e93d47426e3a5e45cc6a2ecac6f2..016818e98dcf6db4e5ab538fccfd9f9f6d4aa9db 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,6 @@ SUBDIRS = \ geoclue/automated/ \ gettext/automated/ \ glib/automated/ \ - grilo/automated/ \ gstreamer-buffering/automated/ \ gupnp/automated/ \ libreoffice/automated/ \ @@ -67,6 +66,7 @@ COPY = \ common \ dbus \ folks \ + grilo \ inherit-config.sh \ misc \ predeployed-misc \ diff --git a/common/grilo-playlist-browsing.yaml b/common/grilo-playlist-browsing.yaml deleted file mode 100644 index c565083521bd83c999542bcbd2809219d8d55a73..0000000000000000000000000000000000000000 --- a/common/grilo-playlist-browsing.yaml +++ /dev/null @@ -1,22 +0,0 @@ -metadata: - name: grilo-playlist-browsing - format: "Lava-Test-Shell Test Definition 1.0" - description: "Check grilo playlist browsing." - maintainer: "luis.araujo@collabora.co.uk" - scope: - - functional - devices: - - i386 - environment: - - lava-test-shell - -install: - deps: - - chaiwala-tests - -run: - steps: - - common/run-test-in-systemd --timeout=900 /usr/share/chaiwala-tests/grilo/automated/run-playlist-browsing-test.sh - -parse: - pattern: ^(?P<test_case_id>[a-zA-Z0-9_\-\./]+):\s*(?P<result>pass|fail|skip|unknown)$ diff --git a/common/grilo.yaml b/common/grilo.yaml index 02d6b07b938132c778475992c31486b70b97e021..d8c27e7f247e967b2130f681f463bf59ee1c5702 100644 --- a/common/grilo.yaml +++ b/common/grilo.yaml @@ -12,11 +12,12 @@ metadata: install: deps: - - chaiwala-tests + - apertis-tests + - gir1.2-grilo-0.2 run: steps: - - common/run-test-in-systemd --timeout=900 --basename /usr/share/chaiwala-tests/grilo/automated/run-test.sh + - common/run-test-in-systemd --timeout=900 --basename grilo/automated/test-grilo.py parse: pattern: ^(?P<test_case_id>[a-zA-Z0-9_\-\./]+):\s*(?P<result>pass|fail|skip|unknown)$ diff --git a/grilo/automated/Makefile b/grilo/automated/Makefile deleted file mode 100644 index 0faf814a1517c2406a41c787fe3a33923d7627bb..0000000000000000000000000000000000000000 --- a/grilo/automated/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# vim: set ts=8 tw=80 : - -progs := grilo-metadata-changes-notify grilo-filesystem-browse grilo-filesystem-browse-pls - -include ../../global-config.mk - -SCRIPTS := $(SCRIPTS) run-playlist-browsing-test.sh - -LIBS := $(shell $(PKG_CONFIG) --libs --cflags grilo-0.2 gio-2.0) - -PLS_LIBS := $(shell $(PKG_CONFIG) --libs --cflags grilo-pls-0.2) - -all: $(progs) - -%.o: %.c %.h - $(CC) $(CFLAGS) -o $@ -c $< $(LIBS) - -grilo-filesystem-browse: grilo-filesystem-browse.c util.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) - -grilo-filesystem-browse-pls: grilo-filesystem-browse-pls.c util.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(PLS_LIBS) - -grilo-metadata-changes-notify: grilo-metadata-changes-notify.c grilo-do-metadata-changes.c util.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) - -get-deps: - $(APT_GET) install pkg-config libgrilo-0.2-dev - -install: .INSTALL - -clean: .CLEAN - rm *.o diff --git a/grilo/automated/README b/grilo/automated/README index 5ef5751ecbffc07526b3674b6a4e3907cf30d360..82efd9a6612e0974d2eb5b6277f705e876807979 100644 --- a/grilo/automated/README +++ b/grilo/automated/README @@ -1,7 +1,5 @@ Debug output variables: -* DEBUG=1 will make the script show stdout -* DEBUG=2 will make the script show stderr+stdout * G_MESSAGES_DEBUG=all will make the test program display g_debug messages + Note: this will interfere with programs that read stdout output to verify that the test completed successfully diff --git a/grilo/automated/config.sh b/grilo/automated/config.sh deleted file mode 100644 index 7d6e7cf9969c4aa3a10b67005206647d1951c2bf..0000000000000000000000000000000000000000 --- a/grilo/automated/config.sh +++ /dev/null @@ -1 +0,0 @@ -. "${TESTDIR}/inherit-config.sh" diff --git a/grilo/automated/grilo-do-metadata-changes.c b/grilo/automated/grilo-do-metadata-changes.c deleted file mode 100644 index 905d49cc22d2a71ad123399cf3f9ab3af760baaf..0000000000000000000000000000000000000000 --- a/grilo/automated/grilo-do-metadata-changes.c +++ /dev/null @@ -1,186 +0,0 @@ -/* vim: set sts=2 sw=2 et : - * - * This program does file/directory metadata changes for the grilo monitor test - * - */ - -#include <gio/gio.h> -#include <glib.h> - -#include "grilo-do-metadata-changes.h" - -#define DATA "qwertyuiop" - -static GFile* -create_file_for_test (gchar *path) -{ - GFile *file; - GError *error = NULL; - GFileCreateFlags flags = G_FILE_CREATE_REPLACE_DESTINATION; - GriloTestAction *add_action = g_new0 (GriloTestAction, 1); - - g_debug ("Is stack stale?"); - while (stack_fresh) - g_thread_yield (); - g_debug ("Stack is stale! Creating %s", path); - - file = g_file_new_for_path (path); - g_file_create (file, flags, NULL, &error); - if (error) - g_error ("Unable to create file %s: %s", path, error->message); - - add_action->change_type = GRL_CONTENT_ADDED; - add_action->change_path = g_path_get_dirname (path); - g_mutex_lock (&mutex); - actions = g_slist_append (actions, add_action); - stack_fresh = TRUE; - g_mutex_unlock (&mutex); - - g_free (path); - return file; -} - -static GFile* -create_directory_for_test (gchar *path) -{ - GFile *dir; - GError *error = NULL; - GriloTestAction *add_action = g_new0 (GriloTestAction, 1); - - g_debug ("Is stack stale?"); - while (stack_fresh) - g_thread_yield (); - g_debug ("Stack is stale! Creating %s", path); - - dir = g_file_new_for_path (path); - g_file_make_directory (dir, NULL, &error); - if (error) - g_error ("Unable to create dir %s: %s", path, error->message); - - add_action->change_type = GRL_CONTENT_ADDED; - add_action->change_path = g_path_get_dirname (path); - g_mutex_lock (&mutex); - actions = g_slist_append (actions, add_action); - stack_fresh = TRUE; - g_mutex_unlock (&mutex); - - g_free (path); - return dir; -} - -static void -delete_gfile_for_test (GFile *file, - gboolean is_file) -{ - gchar *path; - GError *error = NULL; - GriloTestAction *remove_action = g_new0 (GriloTestAction, 1); - path = g_file_get_parse_name (file); - - g_debug ("Is stack stale?"); - while (stack_fresh) - g_thread_yield (); - g_debug ("Stack is stale! Deleting %s", path); - - g_file_delete (file, NULL, &error); - if (error) - g_error ("Unable to delete %s: %s", path, error->message); - - remove_action->change_type = GRL_CONTENT_REMOVED; - remove_action->change_path = g_path_get_dirname (path); - g_mutex_lock (&mutex); - actions = g_slist_append (actions, remove_action); - if (is_file) - actions = g_slist_append (actions, g_slice_dup (GriloTestAction, remove_action)); - stack_fresh = TRUE; - g_mutex_unlock (&mutex); - - g_free (path); - g_object_unref (file); -} - -static void -write_file_for_test (GFile *file) -{ - gchar *path; - GError *error = NULL; - GOutputStream *file_writer; - GriloTestAction *action = g_new0 (GriloTestAction, 1); - - path = g_file_get_parse_name (file); - g_debug ("Is stack stale?"); - while (stack_fresh) - g_thread_yield (); - g_debug ("Stack is stale! Writing to file: %s", path); - - file_writer = g_io_stream_get_output_stream (G_IO_STREAM (g_file_open_readwrite (file, NULL, &error))); - if (error) - g_error ("Unable to open file %s: %s", path, error->message); - g_output_stream_write (file_writer, DATA, sizeof(DATA), NULL, &error); - if (error) - g_error ("Unable to write to file %s: %s", path, error->message); - g_output_stream_close (file_writer, NULL, NULL); - - action->change_type = GRL_CONTENT_CHANGED; - action->change_path = g_path_get_dirname (path); - g_mutex_lock (&mutex); - actions = g_slist_append (actions, action); - stack_fresh = TRUE; - g_mutex_unlock (&mutex); - - g_free (path); -} - -/* Begin testing. Given a directory being monitored recursively, steps are: - * > Create file - * > Create sub-directory - * > Create file inside sub-directory - * > Create directory inside sub-directory - * > Write to file - * > Remove directory inside sub-directory - * > Remove file inside sub-directory - * > Remove sub-directory - * > Remove file */ -static void -begin_monitor_testing (void) -{ - GFile *file, *subdir, *subdir_file, *subdir_dir; - gchar *tmp; - GError *error = NULL; - - - g_printf ("Running test in: %s\n", toplevel_path); - /* Create files and directories */ - g_printf ("Testing notifications of created files ...\n"); - g_usleep (2*G_USEC_PER_SEC); /* Workaround races */ - tmp = g_build_filename (toplevel_path, "file", NULL); - file = create_file_for_test (tmp); - - g_usleep (2*G_USEC_PER_SEC); /* Workaround races */ - tmp = g_build_filename (toplevel_path, "subdir", NULL); - subdir = create_directory_for_test (tmp); - - g_usleep (2*G_USEC_PER_SEC); /* Workaround races */ - tmp = g_build_filename (toplevel_path, "subdir", "file", NULL); - subdir_file = create_file_for_test (tmp); - - g_usleep (2*G_USEC_PER_SEC); /* Workaround races */ - tmp = g_build_filename (toplevel_path, "subdir", "subdir", NULL); - subdir_dir = create_directory_for_test (tmp); - - /* Write to file */ - g_printf ("Testing notifications of changed files ...\n"); - write_file_for_test (file); - - /* Remove files and directories */ - g_printf ("Testing notifications of removed files ...\n"); - delete_gfile_for_test (subdir_dir, 0); - delete_gfile_for_test (subdir_file, 1); - delete_gfile_for_test (subdir, 0); - delete_gfile_for_test (file, 1); - - g_printf ("Success!\n"); - g_printf ("(Ignore any warnings by Grilo about non-existent files. It's fine.)\n"); - - g_main_loop_quit (loop); -} diff --git a/grilo/automated/grilo-do-metadata-changes.h b/grilo/automated/grilo-do-metadata-changes.h deleted file mode 100644 index c797186c5db598cde1d3969b01f0fdd0c3c0c1ec..0000000000000000000000000000000000000000 --- a/grilo/automated/grilo-do-metadata-changes.h +++ /dev/null @@ -1,19 +0,0 @@ -/* vim: set sts=2 sw=2 et : - */ - -#include <glib.h> -#include <grilo.h> -#include <gio/gio.h> - -static GMutex mutex; -static GMainLoop *loop; -static gboolean stack_fresh; -static const gchar *toplevel_path; -static GSList *actions; -static GThread *thread; - -typedef struct { - GrlSourceChangeType change_type; - const gchar *change_path; -} GriloTestAction; - diff --git a/grilo/automated/grilo-filesystem-browse-pls.c b/grilo/automated/grilo-filesystem-browse-pls.c deleted file mode 100644 index aa9f04cd87cbe6a1a5a0d703e5f7c7027d7c5410..0000000000000000000000000000000000000000 --- a/grilo/automated/grilo-filesystem-browse-pls.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * 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> -#include <gio/gio.h> -#include <glib.h> -#include <glib/gprintf.h> -#include <pls/grl-pls.h> - -#include "util.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); - -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); - const gchar *mime = grl_media_get_mime (media); - GDateTime *date = grl_media_get_modification_date (media); - time_t rawdate = g_date_time_to_unix(date); - g_printf ("\t Got '%s', of type '%s', ctime is '%s'\n", title, mime, ctime(&rawdate)); - g_printf ("\t\t URL: %s\n", url); - } - -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_URL, - GRL_METADATA_KEY_MODIFICATION_DATE, - GRL_METADATA_KEY_MIME, - 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_pls_browse_sync (GRL_SOURCE (source), - media, keys, - options, NULL, - &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); - g_object_unref (options); -} - -static void -load_plugins (gchar* playlist) -{ - GrlRegistry *registry; - GrlSource *source; - GError *error = NULL; - GList *keys; - GrlOperationOptions *options; - GrlCaps *caps; - GrlMedia* media; - gboolean pls_mime, pls_file, pls_media; - const gchar *mime; - gchar *filename; - - registry = grl_registry_get_default (); - - /* Load plugin */ - if (!grl_registry_load_plugin_by_id (registry, "grl-filesystem", &error)) - g_error ("Failed to load plugin: %s", error->message); - - source = grl_registry_lookup_source (registry, "grl-filesystem"); - if (!source) - g_error ("Unable to load grl-filesystem plugin"); - - if (!(grl_source_supported_operations (source) & GRL_OP_MEDIA_FROM_URI)) - g_error ("Unable to get media from URI"); - - keys = grl_metadata_key_list_new (GRL_METADATA_KEY_TITLE, GRL_METADATA_KEY_URL, GRL_METADATA_KEY_MIME, NULL); - if (!keys) - g_error ("Unable to create key list"); - - caps = grl_source_get_caps (source, GRL_OP_MEDIA_FROM_URI); - if (!caps) - g_error ("Unable to get source caps"); - - options = grl_operation_options_new (caps); - if (!options) - g_error ("Unable to create operation options"); - - media = grl_source_get_media_from_uri_sync (source, playlist, keys, options, &error); - if (!media) - g_error ("Unable to get GrlMedia for playlist %s", playlist); - - g_object_unref (caps); - g_object_unref (options); - - mime = grl_media_get_mime (media); - pls_media = grl_pls_media_is_playlist (media); - - g_printf("Got Media for %s - mime=%s\n", playlist, mime); - g_printf("\tgrl_pls_mime_is_playlist = %d\n", pls_mime); - - if (pls_media) { - source_browser (source, media); - } - - g_object_unref (media); - g_object_unref (source); -} - -gint -main (int argc, - gchar *argv[]) -{ - gchar *chosen_test_path; - gchar *file_uri; - GError *error = NULL; - - grl_init (&argc, &argv); - GRL_LOG_DOMAIN_INIT (example_log_domain, "example"); - - if (argc != 2) { - g_printf ("Usage: %s <path to browse>\n", argv[0]); - return 1; - } - - chosen_test_path = argv[1]; - GFile *file = g_file_new_for_path (chosen_test_path); - if (!file) { - g_printf ("Invalid file/directory %s\n", argv[1]); - return 1; - } - - GFileInfo *info = g_file_query_info (file, - G_FILE_ATTRIBUTE_STANDARD_TYPE, - 0, - NULL, - &error); - if (!info) { - g_printf ("Invalid file/directory information\n"); - return 1; - } - - if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR) { - return 1; - } - - gchar *dirname = g_path_get_dirname(chosen_test_path); - chaiwala_grilo_config_plugins (dirname); - g_free (dirname); - - file_uri = g_filename_to_uri (chosen_test_path, NULL, &error); - - g_object_unref (file); - g_object_unref (info); - load_plugins (file_uri); - g_free (file_uri); - - return 0; -} diff --git a/grilo/automated/grilo-filesystem-browse.c b/grilo/automated/grilo-filesystem-browse.c deleted file mode 100644 index 2d4e4df57fe6451a92edb4522aeee64e988913d9..0000000000000000000000000000000000000000 --- a/grilo/automated/grilo-filesystem-browse.c +++ /dev/null @@ -1,165 +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> - -#include "util.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); - -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); - const gchar *mime = grl_media_get_mime (media); - /* You can also retrieve the image data directly with - * grl_media_get_thumbnail_binary(). See the Grilo documentation for more - * details. */ - const gchar *thumb_uri = grl_media_get_thumbnail (media); - g_printf ("\t Got '%s', of type '%s'\n", title, mime); - g_printf ("\t\t URL: %s\n", url); - g_printf ("\t\t Thumbnail URI: %s\n", - thumb_uri ? thumb_uri : "(not thumbnailed)"); - g_printf ("\n"); - } - -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_URL, - GRL_METADATA_KEY_MODIFICATION_DATE, - GRL_METADATA_KEY_MIME, - GRL_METADATA_KEY_CHILDCOUNT, - GRL_METADATA_KEY_THUMBNAIL, - 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 -load_plugins (void) -{ - GrlRegistry *registry; - GrlSource *source; - GError *error = NULL; - - registry = grl_registry_get_default (); - - /* Load plugin */ - if (!grl_registry_load_plugin_by_id (registry, "grl-filesystem", &error)) - g_error ("Failed to load plugin: %s", error->message); - - source = grl_registry_lookup_source (registry, "grl-filesystem"); - if (!source) - g_error ("Unable to load grl-filesystem plugin"); - - source_browser (source, NULL); -} - -gint -main (int argc, - gchar *argv[]) -{ - gchar *chosen_test_path; - grl_init (&argc, &argv); - GRL_LOG_DOMAIN_INIT (example_log_domain, "example"); - - if (argc != 2) { - g_printf ("Usage: %s <path to browse>\n", argv[0]); - return 1; - } - - chosen_test_path = argv[1]; - - chaiwala_grilo_config_plugins (chosen_test_path); - load_plugins (); - - return 0; -} - diff --git a/grilo/automated/grilo-metadata-changes-notify.c b/grilo/automated/grilo-metadata-changes-notify.c deleted file mode 100644 index 2f8d1f15a9e911f489a4da1c90202c4d404a0ea4..0000000000000000000000000000000000000000 --- a/grilo/automated/grilo-metadata-changes-notify.c +++ /dev/null @@ -1,154 +0,0 @@ -/* vim: set sts=2 sw=2 et : - * - * File/Directory metadata change monitoring using Grilo - * - */ - -/* Don't look at me like that. It's fine. */ -#include "grilo-do-metadata-changes.c" - -#include "util.h" - -#define GRL_LOG_DOMAIN_DEFAULT example_log_domain -GRL_LOG_DOMAIN_STATIC(example_log_domain); - -#define BROWSE_CHUNK_SIZE 10 -#define TOPLEVEL_DIR "toplevel" - -static const gchar *chosen_test_path; - -static gchar* -get_grl_change_type_str (GrlSourceChangeType change_type) -{ - if (change_type == GRL_CONTENT_CHANGED) - return "GRL_CONTENT_CHANGED"; - if (change_type == GRL_CONTENT_ADDED) - return "GRL_CONTENT_ADDED"; - if (change_type == GRL_CONTENT_REMOVED) - return "GRL_CONTENT_REMOVED"; -} - -static void -change_handler_cb (gpointer data, - gpointer user_data) -{ - const gchar *change_path; - GrlMedia *media = GRL_MEDIA (data); - GriloTestAction *action = (GriloTestAction*) user_data; - - change_path = g_filename_from_uri (grl_media_get_url (GRL_MEDIA (data)), NULL, NULL); - - if (g_strcmp0 (action->change_path, change_path) != 0) - g_error ("Expected change path %s, got change path %s", - action->change_path, change_path); - g_debug ("Yey! %s == %s!", action->change_path, change_path); - actions = g_slist_delete_link (actions, actions); -} - -static void -content_changed_cb (GrlSource *source, - GPtrArray *changed_medias, - GrlSourceChangeType change_type, - gboolean location_unknown, - gboolean user_data) -{ - GriloTestAction *action; - g_debug ("Content changed!"); - - g_debug ("Is stack fresh?"); - while (!stack_fresh) - g_thread_yield (); - g_debug ("Stack is fresh! Time to make it stale"); - - g_mutex_lock (&mutex); - action = g_slist_nth_data (actions, 1); - if (action->change_type != change_type) - g_error ("Expected change type %s, got change type %s", - get_grl_change_type_str (action->change_type), - get_grl_change_type_str (change_type)); - - g_ptr_array_foreach (changed_medias, change_handler_cb, action); - stack_fresh = FALSE; - g_mutex_unlock (&mutex); -} - -static void -source_monitor (gpointer data, - gpointer user_data) -{ - GrlSource *source = GRL_SOURCE (data); - GrlMedia *media = GRL_MEDIA (user_data); - GError *error = NULL; - const gchar *source_name; - - source_name = grl_source_get_name (source); - - if (!(grl_source_supported_operations (source) & GRL_OP_NOTIFY_CHANGE)) { - g_warning ("Source '%s' doesn't support GRL_OP_NOTIFY_CHANGE", source_name); - return; - } - - g_debug ("Telling source '%s' to start notifying", source_name); - if (!grl_source_notify_change_start (GRL_SOURCE (source), NULL)) - g_critical ("Source '%s' can't start notifying!", source_name); - - g_signal_connect (GRL_SOURCE (source), "content-changed", - G_CALLBACK (content_changed_cb), NULL); - - thread = g_thread_new ("do-changes", (GThreadFunc) begin_monitor_testing, NULL); -} - -static void -load_plugins (void) -{ - GrlRegistry *registry; - GrlSource *source; - GError *error = NULL; - - registry = grl_registry_get_default (); - - /* Load plugin */ - if (!grl_registry_load_plugin_by_id (registry, "grl-filesystem", &error)) - g_error ("Failed to load plugin: %s", error->message); - - source = grl_registry_lookup_source (registry, "grl-filesystem"); - if (!source) - g_error ("Unable to load grl-filesystem plugin"); - - source_monitor (source, NULL); -} - -gint -main (int argc, - gchar *argv[]) -{ - GFile *toplevel_dir; - GError *error = NULL; - - grl_init (&argc, &argv); - GRL_LOG_DOMAIN_INIT (example_log_domain, "example"); - - if (argc != 2) { - g_printf ("Usage: %s <path to monitor>\n", argv[0]); - return 1; - } - - actions = g_slist_alloc (); - chosen_test_path = argv[1]; - toplevel_path = g_build_filename (chosen_test_path, TOPLEVEL_DIR, NULL); - toplevel_dir = g_file_new_for_commandline_arg (toplevel_path); - if (!g_file_make_directory_with_parents (toplevel_dir, NULL, &error)) - g_error ("Unable to create directory %s: %s\n", - toplevel_path, error->message); - - g_object_unref (toplevel_dir); - - chaiwala_grilo_config_plugins (chosen_test_path); - load_plugins (); - - /* Run the main loop */ - loop = g_main_loop_new (NULL, FALSE); - g_main_loop_run (loop); - return 0; -} - diff --git a/grilo/automated/inherit-config.sh b/grilo/automated/inherit-config.sh deleted file mode 120000 index 1746371b9ba1d6110c3ddc0842a0e6e65c31c415..0000000000000000000000000000000000000000 --- a/grilo/automated/inherit-config.sh +++ /dev/null @@ -1 +0,0 @@ -../../inherit-config.sh \ No newline at end of file diff --git a/grilo/automated/run-playlist-browsing-test.sh b/grilo/automated/run-playlist-browsing-test.sh deleted file mode 100755 index 65d69f40f8acd26c276d902746dda6f268c823fe..0000000000000000000000000000000000000000 --- a/grilo/automated/run-playlist-browsing-test.sh +++ /dev/null @@ -1,47 +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" - -######### -# Setup # -######### -trap "setup_failure" ERR - -setup_success - -########### -# Execute # -########### -test_grilo_playlist_browsing() { - set -e - local i pos ret=0 count=0 playlist_entries=() - local tempdir=$(create_temp_workdir) - local playlist="Generic_Sounds.pls" - local browsed_files_log="${WORKDIR}/browsed-files.log" - local expected_files_log="${WORKDIR}/expected-files.log" - - # 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}" - - grep File "${tempdir}/${playlist}" | cut -d '=' -f 2- > "${expected_files_log}" - "${TESTLIBDIR}/grilo-filesystem-browse-pls" "${tempdir}/${playlist}" | sed -n "s|\s\+URL: file://${tempdir}/\(.*\)|\1|p" > "${browsed_files_log}" - - # Sync logs to disk - sync - # Race condition in file syncing. Pfft. - _sleep 3 - diff -u "${expected_files_log}" "${browsed_files_log}" || return 1 -} - -trap "test_failure" ERR - -src_test_pass <<-EOF -test_grilo_playlist_browsing -EOF - -test_success diff --git a/grilo/automated/run-test.sh b/grilo/automated/run-test.sh deleted file mode 100755 index 9362e0fa057d638f4b0ce8cbc4175f4683bd8e8d..0000000000000000000000000000000000000000 --- a/grilo/automated/run-test.sh +++ /dev/null @@ -1,49 +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" - -######### -# Setup # -######### -trap "setup_failure" ERR - -setup_success - -########### -# Execute # -########### -test_notifications_on_metadata_changes() { - "${TESTLIBDIR}/grilo-metadata-changes-notify" $(create_temp_workdir) -} - -test_grilo_filesystem_browser() { - set -e - local browsed_files_log="${WORKDIR}/browsed-files.log" - local expected_files_log="${WORKDIR}/expected-files.log" - local tempdir=$(create_temp_workdir) - - # Compare expected media browsing results with actual results - find "${MEDIA_RESOURCE_DIR}" \ - -regex '\(.+\.jpg\|.+\.png\|.+\.oga\|.+\.mp3\|.+\.flac\|.+\.wav\|.+\.ogv\|.+\.pls\|.+\.m3u\)' \ - | sort > "${expected_files_log}" - # FIXME: does not un-escape whitespace/special characters - "${TESTLIBDIR}/grilo-filesystem-browse" "${RESOURCE_DIR}" | sed -n 's|\s\+URL: file://\(.*\)|\1|p' | sort > "${browsed_files_log}" - # Sync logs to disk - sync - # Race condition in file syncing. Pfft. - _sleep 3 - diff -u "${expected_files_log}" "${browsed_files_log}" || return 1 -} - -trap "test_failure" ERR - -src_test_pass <<-EOF -test_notifications_on_metadata_changes -test_grilo_filesystem_browser -EOF - -test_success diff --git a/grilo/automated/util.c b/grilo/automated/util.c deleted file mode 100644 index f65292ae4ec77bfe03c848ba7cdbae0790148b55..0000000000000000000000000000000000000000 --- a/grilo/automated/util.c +++ /dev/null @@ -1,40 +0,0 @@ -/* vim: set sts=2 sw=2 et : - */ - -#include <glib.h> -#include <grilo.h> - -#include "util.h" - -void -chaiwala_grilo_config_plugins (const gchar* chosen_test_path) -{ - GrlRegistry *registry; - GrlConfig *config; - gchar *base_uri; - gchar *filename; - GError *error = NULL; - - registry = grl_registry_get_default (); - - /* Configure plugin */ - config = grl_config_new ("grl-filesystem", "Filesystem"); - - if (g_path_is_absolute (chosen_test_path)) { - filename = g_strdup (chosen_test_path); - } else { - gchar *current_dir = g_get_current_dir (); - - filename = g_build_filename (current_dir, chosen_test_path, NULL); - g_free (current_dir); - } - - base_uri = g_filename_to_uri (filename, NULL, &error); - g_assert_no_error (error); - - grl_config_set_string (config, "base-uri", base_uri); - grl_registry_add_config (registry, config, NULL); - - g_free (filename); - g_free (base_uri); -} diff --git a/grilo/automated/util.h b/grilo/automated/util.h deleted file mode 100644 index 32c5326dfb4fc8b5369367f642713498a8869d7e..0000000000000000000000000000000000000000 --- a/grilo/automated/util.h +++ /dev/null @@ -1,15 +0,0 @@ -/* vim: set sts=2 sw=2 et : - */ - -#ifndef __CHAIWALA_GRILO_UTIL_H__ -#define __CHAIWALA_GRILO_UTIL_H__ - -#include <glib.h> - -G_BEGIN_DECLS - -void chaiwala_grilo_config_plugins (const gchar* chosen_test_path); - -G_END_DECLS - -#endif