*/
#include <babeltrace/plugin/plugin-dev.h>
-#include <babeltrace/component/component.h>
+#include <babeltrace/component/component-class.h>
+#include <babeltrace/values.h>
+#include <babeltrace/ref.h>
+#include <assert.h>
static enum bt_component_status sink_consume(struct bt_component *component)
{
return BT_NOTIFICATION_ITERATOR_STATUS_OK;
}
+static struct bt_value *query_info_method(
+ struct bt_component_class *component_class,
+ const char *action, struct bt_value *params)
+{
+ int ret;
+ struct bt_value *results = bt_value_array_create();
+
+ assert(results);
+ ret = bt_value_array_append_string(results, action);
+ assert(ret == 0);
+ ret = bt_value_array_append(results, params);
+ assert(ret == 0);
+ return results;
+}
+
BT_PLUGIN(test_sfs);
BT_PLUGIN_DESCRIPTION("Babeltrace plugin with source, sink, and filter component classes");
BT_PLUGIN_AUTHOR("Janine Sutto");
dummy_iterator_destroy_method);
BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_SEEK_TIME_METHOD(filter,
dummy_iterator_seek_time_method);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_INFO_METHOD(filter, query_info_method);
#include "tap/tap.h"
#include "common.h"
-#define NR_TESTS 45
+#define NR_TESTS 51
#define NON_EXISTING_PATH "/this/hopefully/does/not/exist/5bc75f8d-0dba-4043-a509-d7984b97e42b.so"
/* Those symbols are written to by some test plugins */
char *sfs_path = get_test_plugin_path(plugin_dir, "sfs");
unsigned int major, minor, patch;
const char *extra;
+ struct bt_value *params;
+ struct bt_value *results;
+ struct bt_value *action;
+ struct bt_value *res_params;
+ const char *action_str;
+ int ret;
assert(sfs_path);
diag("sfs plugin test below");
ok(!bt_plugin_get_component_class_by_name_and_type(plugin, "filter",
BT_COMPONENT_CLASS_TYPE_SOURCE),
"bt_plugin_get_component_class_by_name_and_type() does not find a component class given the wrong type");
+ params = bt_value_integer_create_init(23);
+ assert(params);
+ ok (!bt_component_class_query_info(NULL, "get-something", params),
+ "bt_component_class_query_info() handles NULL (component class)");
+ ok (!bt_component_class_query_info(filter_comp_class, NULL, params),
+ "bt_component_class_query_info() handles NULL (action)");
+ ok (!bt_component_class_query_info(filter_comp_class, "get-something", NULL),
+ "bt_component_class_query_info() handles NULL (parameters)");
+ results = bt_component_class_query_info(filter_comp_class,
+ "get-something", params);
+ ok(results, "bt_component_class_query_info() succeeds");
+ assert(bt_value_is_array(results) && bt_value_array_size(results) == 2);
+ action = bt_value_array_get(results, 0);
+ assert(action && bt_value_is_string(action));
+ ret = bt_value_string_get(action, &action_str);
+ assert(ret == 0);
+ ok(strcmp(action_str, "get-something") == 0,
+ "bt_component_class_query_info() receives the expected action name");
+ res_params = bt_value_array_get(results, 1);
+ ok(res_params == params,
+ "bt_component_class_query_info() receives the expected parameters");
diag("> putting the plugin object here");
BT_PUT(plugin);
free(sfs_path);
free(plugins);
+ bt_put(action);
+ bt_put(res_params);
+ bt_put(results);
+ bt_put(params);
}
static void test_create_all_from_dir(const char *plugin_dir)