tests: rename lib plugins test files
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 15 Jan 2024 19:22:41 +0000 (14:22 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 29 Jan 2024 16:38:19 +0000 (11:38 -0500)
Standardize the names for this test a bit.

Change-Id: I2d70332ed6f25505aac36be7da7a1bdb63da72b6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11678
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
13 files changed:
configure.ac
tests/Makefile.am
tests/lib/Makefile.am
tests/lib/plugin.c [deleted file]
tests/lib/test-plugin-plugins/Makefile.am [deleted file]
tests/lib/test-plugin-plugins/minimal.c [deleted file]
tests/lib/test-plugin-plugins/sfs.c [deleted file]
tests/lib/test-plugin.sh [deleted file]
tests/lib/test-plugins-plugins/Makefile.am [new file with mode: 0644]
tests/lib/test-plugins-plugins/minimal.c [new file with mode: 0644]
tests/lib/test-plugins-plugins/sfs.c [new file with mode: 0644]
tests/lib/test-plugins.c [new file with mode: 0644]
tests/lib/test-plugins.sh [new file with mode: 0755]

index 21c829214deb33f4d8276aaa9a0ef2cad4b5cf3c..53b92cbcf64b117cc9c460d6f95b5f93efecb196 100644 (file)
@@ -822,8 +822,8 @@ AC_CONFIG_FILES([
   tests/bitfield/Makefile
   tests/ctf-writer/Makefile
   tests/lib/Makefile
-  tests/lib/test-plugin-plugins/Makefile
   tests/lib/conds/Makefile
+  tests/lib/test-plugins-plugins/Makefile
   tests/lib/utils/Makefile
   tests/Makefile
   tests/param-validation/Makefile
index baed64e6644ba98bf6ce6028ea1af2b5cabbf93a..90382fb429ae20fce5f151155fea9d8f97a85851 100644 (file)
@@ -96,7 +96,7 @@ TESTS_CTF_WRITER = \
        ctf-writer/test-ctf-writer.sh
 
 if !ENABLE_BUILT_IN_PLUGINS
-TESTS_LIB += lib/test-plugin.sh
+TESTS_LIB += lib/test-plugins.sh
 endif
 
 TESTS_PLUGINS = \
index 643b7e000e4543f80e8a85ef0ddc3396afd2d830..9392f9005441c4c85f867f8aeff9b06d25e3dbe2 100644 (file)
@@ -52,14 +52,14 @@ test_remove_destruction_listener_in_destruction_listener_SOURCES = \
        test-remove-destruction-listener-in-destruction-listener.c
 
 if !ENABLE_BUILT_IN_PLUGINS
-noinst_PROGRAMS += plugin
-plugin_LDADD = $(COMMON_TEST_LDADD) \
+noinst_PROGRAMS += test-plugins
+test_plugins_LDADD = $(COMMON_TEST_LDADD) \
        $(top_builddir)/src/lib/libbabeltrace2.la
-plugin_SOURCES = plugin.c
-SUBDIRS += test-plugin-plugins
+test_plugins_SOURCES = test-plugins.c
+SUBDIRS += test-plugins-plugins
 endif
 
-dist_check_SCRIPTS = test-plugin.sh test-fields.sh
+dist_check_SCRIPTS = test-plugins.sh test-fields.sh
 
 if HAVE_PYTHON
 if DEV_MODE
diff --git a/tests/lib/plugin.c b/tests/lib/plugin.c
deleted file mode 100644 (file)
index 7e3c3e7..0000000
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
- */
-
-#include <babeltrace2/babeltrace.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include "common/assert.h"
-#include <glib.h>
-#include "tap/tap.h"
-#include "common.h"
-
-#define NR_TESTS               38
-#define NON_EXISTING_PATH      "/this/hopefully/does/not/exist/5bc75f8d-0dba-4043-a509-d7984b97e42b.so"
-
-/* Those symbols are written to by some test plugins */
-static int check_env_var(const char *name)
-{
-       const char *val = getenv(name);
-
-       if (!val) {
-               return -1;
-       }
-
-       return atoi(val);
-}
-
-static void reset_test_plugin_env_vars(void)
-{
-       g_setenv("BT_TEST_PLUGIN_INITIALIZE_CALLED", "0", 1);
-       g_setenv("BT_TEST_PLUGIN_FINALIZE_CALLED", "0", 1);
-}
-
-static char *get_test_plugin_path(const char *plugin_dir,
-               const char *plugin_name)
-{
-       char *ret;
-       char *plugin_file_name;
-
-       if (asprintf(&plugin_file_name, "plugin-%s." G_MODULE_SUFFIX,
-                       plugin_name) == -1) {
-               abort();
-       }
-
-       ret = g_build_filename(plugin_dir, plugin_file_name, NULL);
-       free(plugin_file_name);
-
-       return ret;
-}
-
-static void test_minimal(const char *plugin_dir)
-{
-       const bt_plugin_set *plugin_set = NULL;
-       const bt_plugin *plugin;
-       char *minimal_path = get_test_plugin_path(plugin_dir, "minimal");
-       bt_plugin_find_all_from_file_status status;
-
-       BT_ASSERT(minimal_path);
-       diag("minimal plugin test below");
-
-       reset_test_plugin_env_vars();
-       status = bt_plugin_find_all_from_file(minimal_path, BT_FALSE,
-               &plugin_set);
-       ok(status == BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_OK,
-               "bt_plugin_find_all_from_file() succeeds with a valid file");
-       ok(plugin_set,
-               "bt_plugin_find_all_from_file() returns a plugin set");
-       ok(check_env_var("BT_TEST_PLUGIN_INITIALIZE_CALLED") == 1,
-               "plugin's initialization function is called during bt_plugin_find_all_from_file()");
-       ok(bt_plugin_set_get_plugin_count(plugin_set) == 1,
-               "bt_plugin_find_all_from_file() returns the expected number of plugins");
-       plugin = bt_plugin_set_borrow_plugin_by_index_const(plugin_set, 0);
-       ok(strcmp(bt_plugin_get_name(plugin), "test_minimal") == 0,
-               "bt_plugin_get_name() returns the expected name");
-       ok(strcmp(bt_plugin_get_description(plugin),
-               "Minimal Babeltrace plugin with no component classes") == 0,
-               "bt_plugin_get_description() returns the expected description");
-       ok(bt_plugin_get_version(plugin, NULL, NULL, NULL, NULL) ==
-               BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE,
-               "bt_plugin_get_version() fails when there's no version");
-       ok(strcmp(bt_plugin_get_author(plugin), "Janine Sutto") == 0,
-               "bt_plugin_get_author() returns the expected author");
-       ok(strcmp(bt_plugin_get_license(plugin), "Beerware") == 0,
-               "bt_plugin_get_license() returns the expected license");
-       ok(strcmp(bt_plugin_get_path(plugin), minimal_path) == 0,
-               "bt_plugin_get_path() returns the expected path");
-       ok(bt_plugin_get_source_component_class_count(plugin) == 0,
-               "bt_plugin_get_source_component_class_count() returns the expected value");
-       ok(bt_plugin_get_filter_component_class_count(plugin) == 0,
-               "bt_plugin_get_filter_component_class_count() returns the expected value");
-       ok(bt_plugin_get_sink_component_class_count(plugin) == 0,
-               "bt_plugin_get_sink_component_class_count() returns the expected value");
-       bt_plugin_set_put_ref(plugin_set);
-       ok(check_env_var("BT_TEST_PLUGIN_FINALIZE_CALLED") == 1,
-               "plugin's finalize function is called when the plugin is destroyed");
-
-       free(minimal_path);
-}
-
-static void test_sfs(const char *plugin_dir)
-{
-       const bt_plugin_set *plugin_set = NULL;
-       const bt_plugin *plugin;
-       const bt_component_class_sink *sink_comp_class;
-       const bt_component_class_source *source_comp_class;
-       const bt_component_class_filter *filter_comp_class;
-       const bt_component_sink *sink_component;
-       char *sfs_path = get_test_plugin_path(plugin_dir, "sfs");
-       unsigned int major, minor, patch;
-       const char *extra;
-       bt_value *params;
-       const bt_value *results;
-       const bt_value *object;
-       const bt_value *res_params;
-       bt_graph *graph;
-       const char *object_str;
-       bt_graph_add_component_status graph_ret;
-       bt_query_executor *query_exec;
-       int ret;
-       bt_plugin_find_all_from_file_status status;
-
-       BT_ASSERT(sfs_path);
-       diag("sfs plugin test below");
-
-       status = bt_plugin_find_all_from_file(sfs_path, BT_FALSE, &plugin_set);
-       BT_ASSERT(status == BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_OK &&
-               plugin_set && bt_plugin_set_get_plugin_count(plugin_set) == 1);
-       plugin = bt_plugin_set_borrow_plugin_by_index_const(plugin_set, 0);
-       ok(bt_plugin_get_version(plugin, &major, &minor, &patch, &extra) ==
-               BT_PROPERTY_AVAILABILITY_AVAILABLE,
-               "bt_plugin_get_version() succeeds when there's a version");
-       ok(major == 1,
-               "bt_plugin_get_version() returns the expected major version");
-       ok(minor == 2,
-               "bt_plugin_get_version() returns the expected minor version");
-       ok(patch == 3,
-               "bt_plugin_get_version() returns the expected patch version");
-       ok(strcmp(extra, "yes") == 0,
-               "bt_plugin_get_version() returns the expected extra version");
-       ok(bt_plugin_get_source_component_class_count(plugin) == 1,
-               "bt_plugin_get_source_component_class_count() returns the expected value");
-       ok(bt_plugin_get_filter_component_class_count(plugin) == 1,
-               "bt_plugin_get_filter_component_class_count() returns the expected value");
-       ok(bt_plugin_get_sink_component_class_count(plugin) == 1,
-               "bt_plugin_get_sink_component_class_count() returns the expected value");
-
-       source_comp_class = bt_plugin_borrow_source_component_class_by_name_const(
-               plugin, "source");
-       ok(source_comp_class,
-               "bt_plugin_borrow_source_component_class_by_name_const() finds a source component class");
-
-       sink_comp_class = bt_plugin_borrow_sink_component_class_by_name_const(
-               plugin, "sink");
-       ok(sink_comp_class,
-               "bt_plugin_borrow_sink_component_class_by_name_const() finds a sink component class");
-       ok(strcmp(bt_component_class_get_help(bt_component_class_sink_as_component_class_const(sink_comp_class)),
-                 "Bacon ipsum dolor amet strip steak cupim pastrami venison shoulder.\n"
-                 "Prosciutto beef ribs flank meatloaf pancetta brisket kielbasa drumstick\n"
-                 "venison tenderloin cow tail. Beef short loin shoulder meatball, sirloin\n"
-                 "ground round brisket salami cupim pork bresaola turkey bacon boudin.\n") == 0,
-               "bt_component_class_get_help() returns the expected help text");
-
-       filter_comp_class = bt_plugin_borrow_filter_component_class_by_name_const(
-               plugin, "filter");
-       ok(filter_comp_class,
-               "bt_plugin_borrow_filter_component_class_by_name_const() finds a filter component class");
-       params = bt_value_integer_signed_create_init(23);
-       BT_ASSERT(params);
-       query_exec = bt_query_executor_create(
-               bt_component_class_filter_as_component_class_const(
-                       filter_comp_class), "get-something", params);
-       BT_ASSERT(query_exec);
-       ret = bt_query_executor_query(query_exec, &results);
-       ok(ret == 0 && results, "bt_query_executor_query() succeeds");
-       BT_ASSERT(bt_value_is_array(results) && bt_value_array_get_length(results) == 2);
-       object = bt_value_array_borrow_element_by_index_const(results, 0);
-       BT_ASSERT(bt_value_is_string(object));
-       object_str = bt_value_string_get(object);
-       ok(strcmp(object_str, "get-something") == 0,
-               "bt_component_class_query() receives the expected object name");
-       res_params = bt_value_array_borrow_element_by_index_const(results, 1);
-       ok(bt_value_is_equal(res_params, params),
-               "bt_component_class_query() receives the expected parameters");
-
-       bt_component_class_sink_get_ref(sink_comp_class);
-       BT_PLUGIN_SET_PUT_REF_AND_RESET(plugin_set);
-       graph = bt_graph_create(0);
-       BT_ASSERT(graph);
-       graph_ret = bt_graph_add_sink_component(graph, sink_comp_class,
-               "the-sink", NULL, BT_LOGGING_LEVEL_NONE, &sink_component);
-       ok(graph_ret == BT_GRAPH_ADD_COMPONENT_STATUS_OK && sink_component,
-               "bt_graph_add_sink_component() still works after the plugin object is destroyed");
-       bt_graph_put_ref(graph);
-
-       free(sfs_path);
-       bt_component_class_sink_put_ref(sink_comp_class);
-       bt_value_put_ref(results);
-       bt_value_put_ref(params);
-       bt_query_executor_put_ref(query_exec);
-}
-
-static void test_create_all_from_dir(const char *plugin_dir)
-{
-       const bt_plugin_set *plugin_set;
-       bt_plugin_find_all_from_dir_status status;
-
-       diag("create from all test below");
-
-       status = bt_plugin_find_all_from_dir(NON_EXISTING_PATH, BT_FALSE,
-               BT_FALSE, &plugin_set);
-       ok(status == BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_ERROR,
-               "bt_plugin_find_all_from_dir() fails with an invalid path");
-       bt_current_thread_clear_error();
-
-       plugin_set = NULL;
-       status = bt_plugin_find_all_from_dir(plugin_dir, BT_FALSE, BT_FALSE,
-               &plugin_set);
-       ok(status == BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_OK,
-               "bt_plugin_find_all_from_dir() succeeds with a valid path");
-       ok(plugin_set,
-               "bt_plugin_find_all_from_dir() returns a plugin set with a valid path");
-
-       /* 2 or 4, if `.la` files are considered or not */
-       ok(bt_plugin_set_get_plugin_count(plugin_set) == 2 ||
-               bt_plugin_set_get_plugin_count(plugin_set) == 4,
-               "bt_plugin_find_all_from_dir() returns the expected number of plugin objects");
-
-       bt_plugin_set_put_ref(plugin_set);
-}
-
-static void test_find(const char *plugin_dir)
-{
-       int ret;
-       const bt_plugin *plugin;
-       char *plugin_path;
-       bt_plugin_find_status status;
-
-       ok(bt_plugin_find(NON_EXISTING_PATH, BT_TRUE, BT_FALSE, BT_FALSE,
-               BT_FALSE, BT_FALSE, &plugin) == BT_PLUGIN_FIND_STATUS_NOT_FOUND,
-               "bt_plugin_find() returns BT_PLUGIN_STATUS_NOT_FOUND with an unknown plugin name");
-       ret = asprintf(&plugin_path, "%s" G_SEARCHPATH_SEPARATOR_S
-                       G_DIR_SEPARATOR_S "ec1d09e5-696c-442e-b1c3-f9c6cf7f5958"
-                       G_SEARCHPATH_SEPARATOR_S G_SEARCHPATH_SEPARATOR_S
-                       G_SEARCHPATH_SEPARATOR_S "%s" G_SEARCHPATH_SEPARATOR_S
-                       "8db46494-a398-466a-9649-c765ae077629"
-                       G_SEARCHPATH_SEPARATOR_S,
-               NON_EXISTING_PATH, plugin_dir);
-       BT_ASSERT(ret > 0 && plugin_path);
-       g_setenv("BABELTRACE_PLUGIN_PATH", plugin_path, 1);
-       plugin = NULL;
-       status = bt_plugin_find("test_minimal", BT_TRUE, BT_FALSE, BT_FALSE,
-               BT_FALSE, BT_FALSE, &plugin);
-       ok(status == BT_PLUGIN_FIND_STATUS_OK,
-               "bt_plugin_find() succeeds with a plugin name it can find");
-       ok(plugin, "bt_plugin_find() returns a plugin object");
-       ok(strcmp(bt_plugin_get_author(plugin), "Janine Sutto") == 0,
-               "bt_plugin_find() finds the correct plugin for a given name");
-       BT_PLUGIN_PUT_REF_AND_RESET(plugin);
-       free(plugin_path);
-}
-
-int main(int argc, char **argv)
-{
-       int ret;
-       const char *plugin_dir;
-
-       if (argc != 2) {
-               puts("Usage: test_plugin plugin_directory");
-               ret = 1;
-               goto end;
-       }
-
-       plugin_dir = argv[1];
-       plan_tests(NR_TESTS);
-       test_minimal(plugin_dir);
-       test_sfs(plugin_dir);
-       test_create_all_from_dir(plugin_dir);
-       test_find(plugin_dir);
-       ret = exit_status();
-end:
-       return ret;
-}
diff --git a/tests/lib/test-plugin-plugins/Makefile.am b/tests/lib/test-plugin-plugins/Makefile.am
deleted file mode 100644 (file)
index 7c1ae9d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-# SPDX-License-Identifier: MIT
-
-noinst_LTLIBRARIES = plugin-minimal.la plugin-sfs.la
-
-# the minimal plugin
-plugin_minimal_la_SOURCES = minimal.c
-plugin_minimal_la_LDFLAGS = \
-       $(AM_LDFLAGS) \
-       $(LT_NO_UNDEFINED) \
-       -rpath / -avoid-version -module $(LD_NOTEXT)
-plugin_minimal_la_LIBADD = \
-       $(top_builddir)/src/lib/libbabeltrace2.la \
-       $(top_builddir)/src/common/libcommon.la \
-       $(top_builddir)/src/logging/liblogging.la
-
-# source/filter/sink plugin
-plugin_sfs_la_SOURCES = sfs.c
-plugin_sfs_la_LDFLAGS = \
-       $(AM_LDFLAGS) \
-       $(LT_NO_UNDEFINED) \
-       -rpath / -avoid-version -module $(LD_NOTEXT)
-plugin_sfs_la_LIBADD = \
-       $(top_builddir)/src/lib/libbabeltrace2.la \
-       $(top_builddir)/src/common/libcommon.la \
-       $(top_builddir)/src/logging/liblogging.la
diff --git a/tests/lib/test-plugin-plugins/minimal.c b/tests/lib/test-plugin-plugins/minimal.c
deleted file mode 100644 (file)
index 7f9e016..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
- */
-
-#include <babeltrace2/babeltrace.h>
-#include <stdlib.h>
-#include <glib.h>
-
-static bt_plugin_initialize_func_status plugin_init(
-               bt_self_plugin *plugin __attribute__((unused)))
-{
-       g_setenv("BT_TEST_PLUGIN_INITIALIZE_CALLED", "1", 1);
-       return BT_PLUGIN_INITIALIZE_FUNC_STATUS_OK;
-}
-
-static void plugin_finalize(void)
-{
-       g_setenv("BT_TEST_PLUGIN_FINALIZE_CALLED", "1", 1);
-}
-
-BT_PLUGIN_MODULE();
-BT_PLUGIN(test_minimal);
-BT_PLUGIN_DESCRIPTION("Minimal Babeltrace plugin with no component classes");
-BT_PLUGIN_AUTHOR("Janine Sutto");
-BT_PLUGIN_LICENSE("Beerware");
-BT_PLUGIN_INITIALIZE_FUNC(plugin_init);
-BT_PLUGIN_FINALIZE_FUNC(plugin_finalize);
diff --git a/tests/lib/test-plugin-plugins/sfs.c b/tests/lib/test-plugin-plugins/sfs.c
deleted file mode 100644 (file)
index d060879..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * SPDX-License-Identifier: GPL-2.0-only
- *
- * Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
- */
-
-#include <babeltrace2/babeltrace.h>
-#include "common/assert.h"
-
-static bt_component_class_sink_consume_method_status sink_consume(
-               bt_self_component_sink *self_comp __attribute__((unused)))
-{
-       return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
-}
-
-static bt_component_class_get_supported_mip_versions_method_status
-sink_get_supported_mip_versions(
-               bt_self_component_class_sink *source_component_class __attribute__((unused)),
-               const bt_value *params __attribute__((unused)),
-               void *initialize_method_data __attribute__((unused)),
-               bt_logging_level logging_level __attribute__((unused)),
-               bt_integer_range_set_unsigned *supported_versions)
-{
-       return (int) bt_integer_range_set_unsigned_add_range(
-               supported_versions, 0, 0);
-}
-
-static bt_message_iterator_class_initialize_method_status
-src_dummy_iterator_init_method(
-               bt_self_message_iterator *self_msg_iter __attribute__((unused)),
-               bt_self_message_iterator_configuration *config __attribute__((unused)),
-               bt_self_component_port_output *self_port __attribute__((unused)))
-{
-       return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
-}
-
-static bt_message_iterator_class_initialize_method_status
-flt_dummy_iterator_init_method(
-               bt_self_message_iterator *self_msg_iter __attribute__((unused)),
-               bt_self_message_iterator_configuration *config __attribute__((unused)),
-               bt_self_component_port_output *self_port __attribute__((unused)))
-{
-       return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
-}
-
-static void dummy_iterator_finalize_method(
-               bt_self_message_iterator *self_msg_iter __attribute__((unused)))
-{
-}
-
-static bt_message_iterator_class_next_method_status
-dummy_iterator_next_method(
-               bt_self_message_iterator *self_msg_iter __attribute__((unused)),
-               bt_message_array_const msgs __attribute__((unused)),
-               uint64_t capacity __attribute__((unused)),
-               uint64_t *count __attribute__((unused)))
-{
-       return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
-}
-
-static bt_component_class_query_method_status flt_query_method(
-               bt_self_component_class_filter *component_class __attribute__((unused)),
-               bt_private_query_executor *priv_query_exec __attribute__((unused)),
-               const char *object, const bt_value *params,
-               __attribute__((unused)) void *method_data,
-               const bt_value **result)
-{
-       bt_value *res = bt_value_array_create();
-       bt_value *val;
-       *result = res;
-       int iret;
-
-       BT_ASSERT(*result);
-       iret = bt_value_array_append_string_element(res, object);
-       BT_ASSERT(iret == 0);
-       iret = bt_value_copy(params, &val);
-       BT_ASSERT(iret == 0);
-       iret = bt_value_array_append_element(res, val);
-       BT_ASSERT(iret == 0);
-       bt_value_put_ref(val);
-       return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK;
-}
-
-BT_PLUGIN_MODULE();
-BT_PLUGIN(test_sfs);
-BT_PLUGIN_DESCRIPTION("Babeltrace plugin with source, sink, and filter component classes");
-BT_PLUGIN_AUTHOR("Janine Sutto");
-BT_PLUGIN_LICENSE("Beerware");
-BT_PLUGIN_VERSION(1, 2, 3, "yes");
-
-BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_next_method);
-BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source.");
-BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(source,
-       src_dummy_iterator_init_method);
-BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(source,
-       dummy_iterator_finalize_method);
-
-BT_PLUGIN_SINK_COMPONENT_CLASS(sink, sink_consume);
-BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(sink, "A sink.");
-BT_PLUGIN_SINK_COMPONENT_CLASS_HELP(sink,
-       "Bacon ipsum dolor amet strip steak cupim pastrami venison shoulder.\n"
-       "Prosciutto beef ribs flank meatloaf pancetta brisket kielbasa drumstick\n"
-       "venison tenderloin cow tail. Beef short loin shoulder meatball, sirloin\n"
-       "ground round brisket salami cupim pork bresaola turkey bacon boudin.\n"
-);
-BT_PLUGIN_SINK_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD(sink,
-       sink_get_supported_mip_versions);
-
-BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_next_method);
-BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter.");
-BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(filter,
-       flt_dummy_iterator_init_method);
-BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(filter,
-       dummy_iterator_finalize_method);
-BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter, flt_query_method);
diff --git a/tests/lib/test-plugin.sh b/tests/lib/test-plugin.sh
deleted file mode 100755 (executable)
index b9a3fcd..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-#
-# SPDX-License-Identifier: GPL-2.0-only
-#
-# Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
-#
-
-if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
-       UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
-else
-       UTILSSH="$(dirname "$0")/../utils/utils.sh"
-fi
-
-# shellcheck source=../utils/utils.sh
-source "$UTILSSH"
-
-"${BT_TESTS_BUILDDIR}/lib/plugin" "${BT_TESTS_BUILDDIR}/lib/test-plugin-plugins/.libs"
diff --git a/tests/lib/test-plugins-plugins/Makefile.am b/tests/lib/test-plugins-plugins/Makefile.am
new file mode 100644 (file)
index 0000000..7c1ae9d
--- /dev/null
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: MIT
+
+noinst_LTLIBRARIES = plugin-minimal.la plugin-sfs.la
+
+# the minimal plugin
+plugin_minimal_la_SOURCES = minimal.c
+plugin_minimal_la_LDFLAGS = \
+       $(AM_LDFLAGS) \
+       $(LT_NO_UNDEFINED) \
+       -rpath / -avoid-version -module $(LD_NOTEXT)
+plugin_minimal_la_LIBADD = \
+       $(top_builddir)/src/lib/libbabeltrace2.la \
+       $(top_builddir)/src/common/libcommon.la \
+       $(top_builddir)/src/logging/liblogging.la
+
+# source/filter/sink plugin
+plugin_sfs_la_SOURCES = sfs.c
+plugin_sfs_la_LDFLAGS = \
+       $(AM_LDFLAGS) \
+       $(LT_NO_UNDEFINED) \
+       -rpath / -avoid-version -module $(LD_NOTEXT)
+plugin_sfs_la_LIBADD = \
+       $(top_builddir)/src/lib/libbabeltrace2.la \
+       $(top_builddir)/src/common/libcommon.la \
+       $(top_builddir)/src/logging/liblogging.la
diff --git a/tests/lib/test-plugins-plugins/minimal.c b/tests/lib/test-plugins-plugins/minimal.c
new file mode 100644 (file)
index 0000000..7f9e016
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ * Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
+ */
+
+#include <babeltrace2/babeltrace.h>
+#include <stdlib.h>
+#include <glib.h>
+
+static bt_plugin_initialize_func_status plugin_init(
+               bt_self_plugin *plugin __attribute__((unused)))
+{
+       g_setenv("BT_TEST_PLUGIN_INITIALIZE_CALLED", "1", 1);
+       return BT_PLUGIN_INITIALIZE_FUNC_STATUS_OK;
+}
+
+static void plugin_finalize(void)
+{
+       g_setenv("BT_TEST_PLUGIN_FINALIZE_CALLED", "1", 1);
+}
+
+BT_PLUGIN_MODULE();
+BT_PLUGIN(test_minimal);
+BT_PLUGIN_DESCRIPTION("Minimal Babeltrace plugin with no component classes");
+BT_PLUGIN_AUTHOR("Janine Sutto");
+BT_PLUGIN_LICENSE("Beerware");
+BT_PLUGIN_INITIALIZE_FUNC(plugin_init);
+BT_PLUGIN_FINALIZE_FUNC(plugin_finalize);
diff --git a/tests/lib/test-plugins-plugins/sfs.c b/tests/lib/test-plugins-plugins/sfs.c
new file mode 100644 (file)
index 0000000..d060879
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ * Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
+ */
+
+#include <babeltrace2/babeltrace.h>
+#include "common/assert.h"
+
+static bt_component_class_sink_consume_method_status sink_consume(
+               bt_self_component_sink *self_comp __attribute__((unused)))
+{
+       return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
+}
+
+static bt_component_class_get_supported_mip_versions_method_status
+sink_get_supported_mip_versions(
+               bt_self_component_class_sink *source_component_class __attribute__((unused)),
+               const bt_value *params __attribute__((unused)),
+               void *initialize_method_data __attribute__((unused)),
+               bt_logging_level logging_level __attribute__((unused)),
+               bt_integer_range_set_unsigned *supported_versions)
+{
+       return (int) bt_integer_range_set_unsigned_add_range(
+               supported_versions, 0, 0);
+}
+
+static bt_message_iterator_class_initialize_method_status
+src_dummy_iterator_init_method(
+               bt_self_message_iterator *self_msg_iter __attribute__((unused)),
+               bt_self_message_iterator_configuration *config __attribute__((unused)),
+               bt_self_component_port_output *self_port __attribute__((unused)))
+{
+       return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
+}
+
+static bt_message_iterator_class_initialize_method_status
+flt_dummy_iterator_init_method(
+               bt_self_message_iterator *self_msg_iter __attribute__((unused)),
+               bt_self_message_iterator_configuration *config __attribute__((unused)),
+               bt_self_component_port_output *self_port __attribute__((unused)))
+{
+       return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
+}
+
+static void dummy_iterator_finalize_method(
+               bt_self_message_iterator *self_msg_iter __attribute__((unused)))
+{
+}
+
+static bt_message_iterator_class_next_method_status
+dummy_iterator_next_method(
+               bt_self_message_iterator *self_msg_iter __attribute__((unused)),
+               bt_message_array_const msgs __attribute__((unused)),
+               uint64_t capacity __attribute__((unused)),
+               uint64_t *count __attribute__((unused)))
+{
+       return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
+}
+
+static bt_component_class_query_method_status flt_query_method(
+               bt_self_component_class_filter *component_class __attribute__((unused)),
+               bt_private_query_executor *priv_query_exec __attribute__((unused)),
+               const char *object, const bt_value *params,
+               __attribute__((unused)) void *method_data,
+               const bt_value **result)
+{
+       bt_value *res = bt_value_array_create();
+       bt_value *val;
+       *result = res;
+       int iret;
+
+       BT_ASSERT(*result);
+       iret = bt_value_array_append_string_element(res, object);
+       BT_ASSERT(iret == 0);
+       iret = bt_value_copy(params, &val);
+       BT_ASSERT(iret == 0);
+       iret = bt_value_array_append_element(res, val);
+       BT_ASSERT(iret == 0);
+       bt_value_put_ref(val);
+       return BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_OK;
+}
+
+BT_PLUGIN_MODULE();
+BT_PLUGIN(test_sfs);
+BT_PLUGIN_DESCRIPTION("Babeltrace plugin with source, sink, and filter component classes");
+BT_PLUGIN_AUTHOR("Janine Sutto");
+BT_PLUGIN_LICENSE("Beerware");
+BT_PLUGIN_VERSION(1, 2, 3, "yes");
+
+BT_PLUGIN_SOURCE_COMPONENT_CLASS(source, dummy_iterator_next_method);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(source, "A source.");
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(source,
+       src_dummy_iterator_init_method);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(source,
+       dummy_iterator_finalize_method);
+
+BT_PLUGIN_SINK_COMPONENT_CLASS(sink, sink_consume);
+BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(sink, "A sink.");
+BT_PLUGIN_SINK_COMPONENT_CLASS_HELP(sink,
+       "Bacon ipsum dolor amet strip steak cupim pastrami venison shoulder.\n"
+       "Prosciutto beef ribs flank meatloaf pancetta brisket kielbasa drumstick\n"
+       "venison tenderloin cow tail. Beef short loin shoulder meatball, sirloin\n"
+       "ground round brisket salami cupim pork bresaola turkey bacon boudin.\n"
+);
+BT_PLUGIN_SINK_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD(sink,
+       sink_get_supported_mip_versions);
+
+BT_PLUGIN_FILTER_COMPONENT_CLASS(filter, dummy_iterator_next_method);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_DESCRIPTION(filter, "A filter.");
+BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD(filter,
+       flt_dummy_iterator_init_method);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_CLASS_FINALIZE_METHOD(filter,
+       dummy_iterator_finalize_method);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter, flt_query_method);
diff --git a/tests/lib/test-plugins.c b/tests/lib/test-plugins.c
new file mode 100644 (file)
index 0000000..7e3c3e7
--- /dev/null
@@ -0,0 +1,285 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ * Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
+ */
+
+#include <babeltrace2/babeltrace.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "common/assert.h"
+#include <glib.h>
+#include "tap/tap.h"
+#include "common.h"
+
+#define NR_TESTS               38
+#define NON_EXISTING_PATH      "/this/hopefully/does/not/exist/5bc75f8d-0dba-4043-a509-d7984b97e42b.so"
+
+/* Those symbols are written to by some test plugins */
+static int check_env_var(const char *name)
+{
+       const char *val = getenv(name);
+
+       if (!val) {
+               return -1;
+       }
+
+       return atoi(val);
+}
+
+static void reset_test_plugin_env_vars(void)
+{
+       g_setenv("BT_TEST_PLUGIN_INITIALIZE_CALLED", "0", 1);
+       g_setenv("BT_TEST_PLUGIN_FINALIZE_CALLED", "0", 1);
+}
+
+static char *get_test_plugin_path(const char *plugin_dir,
+               const char *plugin_name)
+{
+       char *ret;
+       char *plugin_file_name;
+
+       if (asprintf(&plugin_file_name, "plugin-%s." G_MODULE_SUFFIX,
+                       plugin_name) == -1) {
+               abort();
+       }
+
+       ret = g_build_filename(plugin_dir, plugin_file_name, NULL);
+       free(plugin_file_name);
+
+       return ret;
+}
+
+static void test_minimal(const char *plugin_dir)
+{
+       const bt_plugin_set *plugin_set = NULL;
+       const bt_plugin *plugin;
+       char *minimal_path = get_test_plugin_path(plugin_dir, "minimal");
+       bt_plugin_find_all_from_file_status status;
+
+       BT_ASSERT(minimal_path);
+       diag("minimal plugin test below");
+
+       reset_test_plugin_env_vars();
+       status = bt_plugin_find_all_from_file(minimal_path, BT_FALSE,
+               &plugin_set);
+       ok(status == BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_OK,
+               "bt_plugin_find_all_from_file() succeeds with a valid file");
+       ok(plugin_set,
+               "bt_plugin_find_all_from_file() returns a plugin set");
+       ok(check_env_var("BT_TEST_PLUGIN_INITIALIZE_CALLED") == 1,
+               "plugin's initialization function is called during bt_plugin_find_all_from_file()");
+       ok(bt_plugin_set_get_plugin_count(plugin_set) == 1,
+               "bt_plugin_find_all_from_file() returns the expected number of plugins");
+       plugin = bt_plugin_set_borrow_plugin_by_index_const(plugin_set, 0);
+       ok(strcmp(bt_plugin_get_name(plugin), "test_minimal") == 0,
+               "bt_plugin_get_name() returns the expected name");
+       ok(strcmp(bt_plugin_get_description(plugin),
+               "Minimal Babeltrace plugin with no component classes") == 0,
+               "bt_plugin_get_description() returns the expected description");
+       ok(bt_plugin_get_version(plugin, NULL, NULL, NULL, NULL) ==
+               BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE,
+               "bt_plugin_get_version() fails when there's no version");
+       ok(strcmp(bt_plugin_get_author(plugin), "Janine Sutto") == 0,
+               "bt_plugin_get_author() returns the expected author");
+       ok(strcmp(bt_plugin_get_license(plugin), "Beerware") == 0,
+               "bt_plugin_get_license() returns the expected license");
+       ok(strcmp(bt_plugin_get_path(plugin), minimal_path) == 0,
+               "bt_plugin_get_path() returns the expected path");
+       ok(bt_plugin_get_source_component_class_count(plugin) == 0,
+               "bt_plugin_get_source_component_class_count() returns the expected value");
+       ok(bt_plugin_get_filter_component_class_count(plugin) == 0,
+               "bt_plugin_get_filter_component_class_count() returns the expected value");
+       ok(bt_plugin_get_sink_component_class_count(plugin) == 0,
+               "bt_plugin_get_sink_component_class_count() returns the expected value");
+       bt_plugin_set_put_ref(plugin_set);
+       ok(check_env_var("BT_TEST_PLUGIN_FINALIZE_CALLED") == 1,
+               "plugin's finalize function is called when the plugin is destroyed");
+
+       free(minimal_path);
+}
+
+static void test_sfs(const char *plugin_dir)
+{
+       const bt_plugin_set *plugin_set = NULL;
+       const bt_plugin *plugin;
+       const bt_component_class_sink *sink_comp_class;
+       const bt_component_class_source *source_comp_class;
+       const bt_component_class_filter *filter_comp_class;
+       const bt_component_sink *sink_component;
+       char *sfs_path = get_test_plugin_path(plugin_dir, "sfs");
+       unsigned int major, minor, patch;
+       const char *extra;
+       bt_value *params;
+       const bt_value *results;
+       const bt_value *object;
+       const bt_value *res_params;
+       bt_graph *graph;
+       const char *object_str;
+       bt_graph_add_component_status graph_ret;
+       bt_query_executor *query_exec;
+       int ret;
+       bt_plugin_find_all_from_file_status status;
+
+       BT_ASSERT(sfs_path);
+       diag("sfs plugin test below");
+
+       status = bt_plugin_find_all_from_file(sfs_path, BT_FALSE, &plugin_set);
+       BT_ASSERT(status == BT_PLUGIN_FIND_ALL_FROM_FILE_STATUS_OK &&
+               plugin_set && bt_plugin_set_get_plugin_count(plugin_set) == 1);
+       plugin = bt_plugin_set_borrow_plugin_by_index_const(plugin_set, 0);
+       ok(bt_plugin_get_version(plugin, &major, &minor, &patch, &extra) ==
+               BT_PROPERTY_AVAILABILITY_AVAILABLE,
+               "bt_plugin_get_version() succeeds when there's a version");
+       ok(major == 1,
+               "bt_plugin_get_version() returns the expected major version");
+       ok(minor == 2,
+               "bt_plugin_get_version() returns the expected minor version");
+       ok(patch == 3,
+               "bt_plugin_get_version() returns the expected patch version");
+       ok(strcmp(extra, "yes") == 0,
+               "bt_plugin_get_version() returns the expected extra version");
+       ok(bt_plugin_get_source_component_class_count(plugin) == 1,
+               "bt_plugin_get_source_component_class_count() returns the expected value");
+       ok(bt_plugin_get_filter_component_class_count(plugin) == 1,
+               "bt_plugin_get_filter_component_class_count() returns the expected value");
+       ok(bt_plugin_get_sink_component_class_count(plugin) == 1,
+               "bt_plugin_get_sink_component_class_count() returns the expected value");
+
+       source_comp_class = bt_plugin_borrow_source_component_class_by_name_const(
+               plugin, "source");
+       ok(source_comp_class,
+               "bt_plugin_borrow_source_component_class_by_name_const() finds a source component class");
+
+       sink_comp_class = bt_plugin_borrow_sink_component_class_by_name_const(
+               plugin, "sink");
+       ok(sink_comp_class,
+               "bt_plugin_borrow_sink_component_class_by_name_const() finds a sink component class");
+       ok(strcmp(bt_component_class_get_help(bt_component_class_sink_as_component_class_const(sink_comp_class)),
+                 "Bacon ipsum dolor amet strip steak cupim pastrami venison shoulder.\n"
+                 "Prosciutto beef ribs flank meatloaf pancetta brisket kielbasa drumstick\n"
+                 "venison tenderloin cow tail. Beef short loin shoulder meatball, sirloin\n"
+                 "ground round brisket salami cupim pork bresaola turkey bacon boudin.\n") == 0,
+               "bt_component_class_get_help() returns the expected help text");
+
+       filter_comp_class = bt_plugin_borrow_filter_component_class_by_name_const(
+               plugin, "filter");
+       ok(filter_comp_class,
+               "bt_plugin_borrow_filter_component_class_by_name_const() finds a filter component class");
+       params = bt_value_integer_signed_create_init(23);
+       BT_ASSERT(params);
+       query_exec = bt_query_executor_create(
+               bt_component_class_filter_as_component_class_const(
+                       filter_comp_class), "get-something", params);
+       BT_ASSERT(query_exec);
+       ret = bt_query_executor_query(query_exec, &results);
+       ok(ret == 0 && results, "bt_query_executor_query() succeeds");
+       BT_ASSERT(bt_value_is_array(results) && bt_value_array_get_length(results) == 2);
+       object = bt_value_array_borrow_element_by_index_const(results, 0);
+       BT_ASSERT(bt_value_is_string(object));
+       object_str = bt_value_string_get(object);
+       ok(strcmp(object_str, "get-something") == 0,
+               "bt_component_class_query() receives the expected object name");
+       res_params = bt_value_array_borrow_element_by_index_const(results, 1);
+       ok(bt_value_is_equal(res_params, params),
+               "bt_component_class_query() receives the expected parameters");
+
+       bt_component_class_sink_get_ref(sink_comp_class);
+       BT_PLUGIN_SET_PUT_REF_AND_RESET(plugin_set);
+       graph = bt_graph_create(0);
+       BT_ASSERT(graph);
+       graph_ret = bt_graph_add_sink_component(graph, sink_comp_class,
+               "the-sink", NULL, BT_LOGGING_LEVEL_NONE, &sink_component);
+       ok(graph_ret == BT_GRAPH_ADD_COMPONENT_STATUS_OK && sink_component,
+               "bt_graph_add_sink_component() still works after the plugin object is destroyed");
+       bt_graph_put_ref(graph);
+
+       free(sfs_path);
+       bt_component_class_sink_put_ref(sink_comp_class);
+       bt_value_put_ref(results);
+       bt_value_put_ref(params);
+       bt_query_executor_put_ref(query_exec);
+}
+
+static void test_create_all_from_dir(const char *plugin_dir)
+{
+       const bt_plugin_set *plugin_set;
+       bt_plugin_find_all_from_dir_status status;
+
+       diag("create from all test below");
+
+       status = bt_plugin_find_all_from_dir(NON_EXISTING_PATH, BT_FALSE,
+               BT_FALSE, &plugin_set);
+       ok(status == BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_ERROR,
+               "bt_plugin_find_all_from_dir() fails with an invalid path");
+       bt_current_thread_clear_error();
+
+       plugin_set = NULL;
+       status = bt_plugin_find_all_from_dir(plugin_dir, BT_FALSE, BT_FALSE,
+               &plugin_set);
+       ok(status == BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_OK,
+               "bt_plugin_find_all_from_dir() succeeds with a valid path");
+       ok(plugin_set,
+               "bt_plugin_find_all_from_dir() returns a plugin set with a valid path");
+
+       /* 2 or 4, if `.la` files are considered or not */
+       ok(bt_plugin_set_get_plugin_count(plugin_set) == 2 ||
+               bt_plugin_set_get_plugin_count(plugin_set) == 4,
+               "bt_plugin_find_all_from_dir() returns the expected number of plugin objects");
+
+       bt_plugin_set_put_ref(plugin_set);
+}
+
+static void test_find(const char *plugin_dir)
+{
+       int ret;
+       const bt_plugin *plugin;
+       char *plugin_path;
+       bt_plugin_find_status status;
+
+       ok(bt_plugin_find(NON_EXISTING_PATH, BT_TRUE, BT_FALSE, BT_FALSE,
+               BT_FALSE, BT_FALSE, &plugin) == BT_PLUGIN_FIND_STATUS_NOT_FOUND,
+               "bt_plugin_find() returns BT_PLUGIN_STATUS_NOT_FOUND with an unknown plugin name");
+       ret = asprintf(&plugin_path, "%s" G_SEARCHPATH_SEPARATOR_S
+                       G_DIR_SEPARATOR_S "ec1d09e5-696c-442e-b1c3-f9c6cf7f5958"
+                       G_SEARCHPATH_SEPARATOR_S G_SEARCHPATH_SEPARATOR_S
+                       G_SEARCHPATH_SEPARATOR_S "%s" G_SEARCHPATH_SEPARATOR_S
+                       "8db46494-a398-466a-9649-c765ae077629"
+                       G_SEARCHPATH_SEPARATOR_S,
+               NON_EXISTING_PATH, plugin_dir);
+       BT_ASSERT(ret > 0 && plugin_path);
+       g_setenv("BABELTRACE_PLUGIN_PATH", plugin_path, 1);
+       plugin = NULL;
+       status = bt_plugin_find("test_minimal", BT_TRUE, BT_FALSE, BT_FALSE,
+               BT_FALSE, BT_FALSE, &plugin);
+       ok(status == BT_PLUGIN_FIND_STATUS_OK,
+               "bt_plugin_find() succeeds with a plugin name it can find");
+       ok(plugin, "bt_plugin_find() returns a plugin object");
+       ok(strcmp(bt_plugin_get_author(plugin), "Janine Sutto") == 0,
+               "bt_plugin_find() finds the correct plugin for a given name");
+       BT_PLUGIN_PUT_REF_AND_RESET(plugin);
+       free(plugin_path);
+}
+
+int main(int argc, char **argv)
+{
+       int ret;
+       const char *plugin_dir;
+
+       if (argc != 2) {
+               puts("Usage: test_plugin plugin_directory");
+               ret = 1;
+               goto end;
+       }
+
+       plugin_dir = argv[1];
+       plan_tests(NR_TESTS);
+       test_minimal(plugin_dir);
+       test_sfs(plugin_dir);
+       test_create_all_from_dir(plugin_dir);
+       test_find(plugin_dir);
+       ret = exit_status();
+end:
+       return ret;
+}
diff --git a/tests/lib/test-plugins.sh b/tests/lib/test-plugins.sh
new file mode 100755 (executable)
index 0000000..f83e42b
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
+#
+
+if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
+       UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
+else
+       UTILSSH="$(dirname "$0")/../utils/utils.sh"
+fi
+
+# shellcheck source=../utils/utils.sh
+source "$UTILSSH"
+
+"${BT_TESTS_BUILDDIR}/lib/test-plugins" "${BT_TESTS_BUILDDIR}/lib/test-plugins-plugins/.libs"
This page took 0.039442 seconds and 4 git commands to generate.