Test fix: use portable path code in test_plugin
authorMichael Jeanson <mjeanson@efficios.com>
Fri, 18 Aug 2017 18:28:58 +0000 (14:28 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 21 Aug 2017 19:31:13 +0000 (15:31 -0400)
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/lib/test_plugin.c

index f3f229f55f3193fd56cab595181f0e9ef20b36f5..2a6e7fd87dd49b4844ad30a4326a11e6ee8d23f5 100644 (file)
@@ -56,13 +56,17 @@ static void reset_test_plugin_env_vars(void)
 static char *get_test_plugin_path(const char *plugin_dir,
                const char *plugin_name)
 {
-       GString *path = g_string_new(plugin_dir);
        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);
 
-       assert(path);
-       g_string_append_printf(path, "/plugin-%s.so", plugin_name);
-       ret = path->str;
-       g_string_free(path, FALSE);
        return ret;
 }
 
@@ -70,6 +74,8 @@ static void test_invalid(const char *plugin_dir)
 {
        struct bt_plugin_set *plugin_set;
 
+       diag("invalid plugin test below");
+
        plugin_set = bt_plugin_create_all_from_file(NON_EXISTING_PATH);
        ok(!plugin_set, "bt_plugin_create_all_from_file() fails with a non-existing file");
 
@@ -299,7 +305,12 @@ static void test_find(const char *plugin_dir)
                "bt_plugin_find() handles NULL");
        ok(!bt_plugin_find(NON_EXISTING_PATH),
                "bt_plugin_find() returns NULL with an unknown plugin name");
-       ret = asprintf(&plugin_path, "%s:/ec1d09e5-696c-442e-b1c3-f9c6cf7f5958:::%s:8db46494-a398-466a-9649-c765ae077629:",
+       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);
        assert(ret > 0 && plugin_path);
        g_setenv("BABELTRACE_PLUGIN_PATH", plugin_path, 1);
This page took 0.025073 seconds and 5 git commands to generate.