From: Philippe Proulx Date: Sat, 8 Dec 2018 17:44:10 +0000 (-0500) Subject: lib: rename bt_plugin_create_all_*() -> bt_plugin_find_all_*() X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=c8db321922f3730c70628a5e452baf8a046e70fd lib: rename bt_plugin_create_all_*() -> bt_plugin_find_all_*() Those functions return a const plugin set anyway, so we're not really creating private objects as other *_create() functions do. Signed-off-by: Philippe Proulx --- diff --git a/cli/babeltrace.c b/cli/babeltrace.c index 0f3b05ca..ae1a9263 100644 --- a/cli/babeltrace.c +++ b/cli/babeltrace.c @@ -814,7 +814,7 @@ int load_dynamic_plugins(const bt_value *plugin_paths) /* * Skip this if the directory does not exist because - * bt_plugin_create_all_from_dir() expects an existing + * bt_plugin_find_all_from_dir() expects an existing * directory. */ if (!g_file_test(plugin_path, G_FILE_TEST_IS_DIR)) { @@ -823,7 +823,7 @@ int load_dynamic_plugins(const bt_value *plugin_paths) continue; } - plugin_set = bt_plugin_create_all_from_dir(plugin_path, false); + plugin_set = bt_plugin_find_all_from_dir(plugin_path, false); if (!plugin_set) { BT_LOGD("Unable to load dynamic plugins: path=\"%s\"", plugin_path); @@ -844,7 +844,7 @@ int load_static_plugins(void) const bt_plugin_set *plugin_set; BT_LOGI("Loading static plugins."); - plugin_set = bt_plugin_create_all_from_static(); + plugin_set = bt_plugin_find_all_from_static(); if (!plugin_set) { BT_LOGE("Unable to load static plugins."); ret = -1; diff --git a/include/babeltrace/plugin/plugin-const.h b/include/babeltrace/plugin/plugin-const.h index fe581f4e..fe51a856 100644 --- a/include/babeltrace/plugin/plugin-const.h +++ b/include/babeltrace/plugin/plugin-const.h @@ -63,13 +63,13 @@ enum bt_plugin_status { extern const bt_plugin *bt_plugin_find(const char *plugin_name); -extern const bt_plugin_set *bt_plugin_create_all_from_file( +extern const bt_plugin_set *bt_plugin_find_all_from_file( const char *path); -extern const bt_plugin_set *bt_plugin_create_all_from_dir( +extern const bt_plugin_set *bt_plugin_find_all_from_dir( const char *path, bt_bool recurse); -extern const bt_plugin_set *bt_plugin_create_all_from_static(void); +extern const bt_plugin_set *bt_plugin_find_all_from_static(void); extern const char *bt_plugin_get_name(const bt_plugin *plugin); diff --git a/lib/plugin/plugin-so.c b/lib/plugin/plugin-so.c index b06a1b6b..cf0b66f1 100644 --- a/lib/plugin/plugin-so.c +++ b/lib/plugin/plugin-so.c @@ -71,7 +71,7 @@ BT_PLUGIN_MODULE(); * * It allows this use-case: * - * my_plugins = bt_plugin_create_all_from_file("/path/to/my-plugin.so"); + * my_plugins = bt_plugin_find_all_from_file("/path/to/my-plugin.so"); * // instantiate components from a plugin's component classes * // put plugins and free my_plugins here * // user code of instantiated components still exists @@ -198,7 +198,7 @@ struct bt_plugin_so_shared_lib_handle *bt_plugin_so_shared_lib_handle_create( * DEBUG-level logging because we're only _trying_ to * open this file as a Babeltrace plugin: if it's not, * it's not an error. And because this can be tried - * during bt_plugin_create_all_from_dir(), it's not even + * during bt_plugin_find_all_from_dir(), it's not even * a warning. */ BT_LOGD("Cannot open GModule: %s: path=\"%s\"", @@ -1223,7 +1223,7 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_sections( * _trying_ to open this file as a compatible * Babeltrace plugin: if it's not, it's not an * error. And because this can be tried during - * bt_plugin_create_all_from_dir(), it's not + * bt_plugin_find_all_from_dir(), it's not * even a warning. */ BT_LOGD("Unknown ABI major version: abi-major=%d", @@ -1250,7 +1250,7 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_sections( * _trying_ to open this file as a compatible * Babeltrace plugin: if it's not, it's not an * error. And because this can be tried during - * bt_plugin_create_all_from_dir(), it's not + * bt_plugin_find_all_from_dir(), it's not * even a warning. */ BT_LOGD_STR("Cannot initialize SO plugin object from sections."); diff --git a/lib/plugin/plugin.c b/lib/plugin/plugin.c index 1d7661de..ce13d01b 100644 --- a/lib/plugin/plugin.c +++ b/lib/plugin/plugin.c @@ -124,13 +124,13 @@ const struct bt_plugin *bt_plugin_set_borrow_plugin_by_index_const( return g_ptr_array_index(plugin_set->plugins, index); } -const struct bt_plugin_set *bt_plugin_create_all_from_static(void) +const struct bt_plugin_set *bt_plugin_find_all_from_static(void) { /* bt_plugin_so_create_all_from_static() logs errors */ return bt_plugin_so_create_all_from_static(); } -const struct bt_plugin_set *bt_plugin_create_all_from_file(const char *path) +const struct bt_plugin_set *bt_plugin_find_all_from_file(const char *path) { struct bt_plugin_set *plugin_set = NULL; @@ -246,7 +246,7 @@ const struct bt_plugin *bt_plugin_find(const char *plugin_name) /* * Skip this if the directory does not exist because - * bt_plugin_create_all_from_dir() would log a warning. + * bt_plugin_find_all_from_dir() would log a warning. */ if (!g_file_test(dir->str, G_FILE_TEST_IS_DIR)) { BT_LOGV("Skipping nonexistent directory path: " @@ -254,8 +254,8 @@ const struct bt_plugin *bt_plugin_find(const char *plugin_name) continue; } - /* bt_plugin_create_all_from_dir() logs details/errors */ - plugin_set = bt_plugin_create_all_from_dir(dir->str, BT_FALSE); + /* bt_plugin_find_all_from_dir() logs details/errors */ + plugin_set = bt_plugin_find_all_from_dir(dir->str, BT_FALSE); if (!plugin_set) { BT_LOGD("No plugins found in directory: path=\"%s\"", dir->str); @@ -281,7 +281,7 @@ const struct bt_plugin *bt_plugin_find(const char *plugin_name) } bt_object_put_ref(plugin_set); - plugin_set = bt_plugin_create_all_from_static(); + plugin_set = bt_plugin_find_all_from_static(); if (plugin_set) { for (j = 0; j < plugin_set->plugins->len; j++) { const struct bt_plugin *candidate_plugin = @@ -348,7 +348,7 @@ int nftw_append_all_from_dir(const char *file, const struct stat *sb, int flag, goto end; } - plugins_from_file = bt_plugin_create_all_from_file(file); + plugins_from_file = bt_plugin_find_all_from_file(file); if (plugins_from_file) { size_t j; @@ -408,7 +408,7 @@ enum bt_plugin_status bt_plugin_create_append_all_from_dir( return ret; } -const struct bt_plugin_set *bt_plugin_create_all_from_dir(const char *path, +const struct bt_plugin_set *bt_plugin_find_all_from_dir(const char *path, bt_bool recurse) { struct bt_plugin_set *plugin_set; diff --git a/tests/lib/test_plugin.c b/tests/lib/test_plugin.c index e9739f3e..6d9c4263 100644 --- a/tests/lib/test_plugin.c +++ b/tests/lib/test_plugin.c @@ -72,13 +72,13 @@ static void test_minimal(const char *plugin_dir) diag("minimal plugin test below"); reset_test_plugin_env_vars(); - plugin_set = bt_plugin_create_all_from_file(minimal_path); + plugin_set = bt_plugin_find_all_from_file(minimal_path); ok(plugin_set && bt_plugin_set_get_plugin_count(plugin_set) == 1, - "bt_plugin_create_all_from_file() succeeds with a valid file"); + "bt_plugin_find_all_from_file() succeeds with a valid file"); ok(check_env_var("BT_TEST_PLUGIN_INIT_CALLED") == 1, - "plugin's initialization function is called during bt_plugin_create_all_from_file()"); + "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_create_all_from_file() returns the expected number of plugins"); + "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"); @@ -132,7 +132,7 @@ static void test_sfs(const char *plugin_dir) BT_ASSERT(sfs_path); diag("sfs plugin test below"); - plugin_set = bt_plugin_create_all_from_file(sfs_path); + plugin_set = bt_plugin_find_all_from_file(sfs_path); BT_ASSERT(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) == @@ -214,17 +214,17 @@ static void test_create_all_from_dir(const char *plugin_dir) diag("create from all test below"); - plugin_set = bt_plugin_create_all_from_dir(NON_EXISTING_PATH, BT_FALSE); + plugin_set = bt_plugin_find_all_from_dir(NON_EXISTING_PATH, BT_FALSE); ok(!plugin_set, - "bt_plugin_create_all_from_dir() fails with an invalid path"); + "bt_plugin_find_all_from_dir() fails with an invalid path"); - plugin_set = bt_plugin_create_all_from_dir(plugin_dir, BT_FALSE); - ok(plugin_set, "bt_plugin_create_all_from_dir() succeeds with a valid path"); + plugin_set = bt_plugin_find_all_from_dir(plugin_dir, BT_FALSE); + ok(plugin_set, "bt_plugin_find_all_from_dir() succeeds 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_create_all_from_dir() returns the expected number of plugin objects"); + "bt_plugin_find_all_from_dir() returns the expected number of plugin objects"); bt_plugin_set_put_ref(plugin_set); }