validate: Handle various paths in GST_VALIDATE_SCENARIOS_PATH

This commit is contained in:
Thibault Saunier 2014-02-18 18:49:00 +01:00
parent 63f8034bec
commit 68cbc15f35

View file

@ -970,7 +970,9 @@ gst_validate_scenario_load (GstValidateScenario * scenario,
guint i; guint i;
gchar *lfilename = NULL, *tldir = NULL; gchar *lfilename = NULL, *tldir = NULL;
gboolean found_actions = FALSE, is_config, ret = TRUE; gboolean found_actions = FALSE, is_config, ret = TRUE;
const gchar *env_scenariodir = g_getenv ("GST_VALIDATE_SCENARIOS_PATH");
gchar ** env_scenariodir = g_strsplit (g_getenv ("GST_VALIDATE_SCENARIOS_PATH"), ":",
0);
if (!scenario_name) if (!scenario_name)
goto invalid_name; goto invalid_name;
@ -989,11 +991,15 @@ gst_validate_scenario_load (GstValidateScenario * scenario,
g_free (tldir); g_free (tldir);
if (env_scenariodir) { if (env_scenariodir) {
tldir = g_build_filename (env_scenariodir, lfilename, NULL); guint i;
for (i = 0; env_scenariodir[i]; i++) {
tldir = g_build_filename (env_scenariodir[i], lfilename, NULL);
if ((ret = _load_scenario_file (scenario, tldir, &is_config))) if ((ret = _load_scenario_file (scenario, tldir, &is_config)))
goto check_scenario; goto check_scenario;
g_free (tldir); g_free (tldir);
} }
}
/* Try from local profiles */ /* Try from local profiles */
tldir = tldir =
@ -1028,6 +1034,9 @@ gst_validate_scenario_load (GstValidateScenario * scenario,
done: done:
if (env_scenariodir)
g_strfreev (env_scenariodir);
if (ret == FALSE) if (ret == FALSE)
g_error ("Could not set scenario %s => EXIT\n", scenario_name); g_error ("Could not set scenario %s => EXIT\n", scenario_name);
@ -1237,7 +1246,8 @@ gst_validate_list_scenarios (gchar * output_file)
gsize datalength; gsize datalength;
GError *err = NULL; GError *err = NULL;
GKeyFile *kf = NULL; GKeyFile *kf = NULL;
const gchar *env_scenariodir = g_getenv ("GST_VALIDATE_SCENARIOS_PATH"); gchar ** env_scenariodir = g_strsplit (g_getenv ("GST_VALIDATE_SCENARIOS_PATH"), ":",
0);
gchar *tldir = g_build_filename (g_get_user_data_dir (), gchar *tldir = g_build_filename (g_get_user_data_dir (),
"gstreamer-" GST_API_VERSION, GST_VALIDATE_SCENARIO_DIRECTORY, "gstreamer-" GST_API_VERSION, GST_VALIDATE_SCENARIO_DIRECTORY,
NULL); NULL);
@ -1256,10 +1266,14 @@ gst_validate_list_scenarios (gchar * output_file)
g_free (tldir); g_free (tldir);
if (env_scenariodir) { if (env_scenariodir) {
dir = g_file_new_for_path (env_scenariodir); guint i;
for (i = 0; env_scenariodir[i]; i++) {
dir = g_file_new_for_path (env_scenariodir[i]);
_list_scenarios_in_dir (dir, kf); _list_scenarios_in_dir (dir, kf);
g_object_unref (dir); g_object_unref (dir);
} }
}
/* Hack to make it work uninstalled */ /* Hack to make it work uninstalled */
dir = g_file_new_for_path ("data/"); dir = g_file_new_for_path ("data/");
@ -1269,10 +1283,12 @@ gst_validate_list_scenarios (gchar * output_file)
result = g_key_file_to_data (kf, &datalength, &err); result = g_key_file_to_data (kf, &datalength, &err);
g_print ("All scenarios avalaible:\n%s", result); g_print ("All scenarios avalaible:\n%s", result);
if (output_file && !err) if (output_file && !err)
g_file_set_contents (output_file, result, datalength, &err); g_file_set_contents (output_file, result, datalength, &err);
if (env_scenariodir)
g_strfreev (env_scenariodir);
if (err) { if (err) {
GST_WARNING ("Got error '%s' listing scenarios", err->message); GST_WARNING ("Got error '%s' listing scenarios", err->message);
g_clear_error (&err); g_clear_error (&err);