mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-01 21:18:52 +00:00
validate: Enhance error reporting when scenario or configs are invalid
This commit is contained in:
parent
1a6f404c5d
commit
2036d8292f
2 changed files with 31 additions and 20 deletions
|
@ -610,7 +610,7 @@ _get_lines (const gchar * scenario_file, gchar ** file_path)
|
||||||
|
|
||||||
/* Returns: (transfer full): a #GList of #GstStructure */
|
/* Returns: (transfer full): a #GList of #GstStructure */
|
||||||
static GList *
|
static GList *
|
||||||
_lines_get_structures (gchar ** lines)
|
_lines_get_structures (gchar ** lines, gchar ** err)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
GList *structures = NULL;
|
GList *structures = NULL;
|
||||||
|
@ -626,9 +626,18 @@ _lines_get_structures (gchar ** lines)
|
||||||
|
|
||||||
structure = gst_structure_from_string (lines[i], NULL);
|
structure = gst_structure_from_string (lines[i], NULL);
|
||||||
if (structure == NULL) {
|
if (structure == NULL) {
|
||||||
GST_ERROR ("Could not parse action %s", lines[i]);
|
GST_ERROR ("Could not parse structure %s", lines[i]);
|
||||||
|
if (err) {
|
||||||
|
gchar *tmp = *err;
|
||||||
|
*err =
|
||||||
|
g_strdup_printf ("%s\n -Invalid structure: `%s`", tmp ? tmp : "",
|
||||||
|
lines[i]);
|
||||||
|
g_free (tmp);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
structures = g_list_append (structures, structure);
|
structures = g_list_append (structures, structure);
|
||||||
}
|
}
|
||||||
|
@ -653,7 +662,8 @@ GList *
|
||||||
gst_validate_utils_structs_parse_from_filename (const gchar * scenario_file,
|
gst_validate_utils_structs_parse_from_filename (const gchar * scenario_file,
|
||||||
gchar ** file_path)
|
gchar ** file_path)
|
||||||
{
|
{
|
||||||
gchar **lines;
|
GList *res;
|
||||||
|
gchar **lines, *err = NULL;
|
||||||
|
|
||||||
lines = _get_lines (scenario_file, file_path);
|
lines = _get_lines (scenario_file, file_path);
|
||||||
|
|
||||||
|
@ -662,7 +672,12 @@ gst_validate_utils_structs_parse_from_filename (const gchar * scenario_file,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _lines_get_structures (lines);
|
res = _lines_get_structures (lines, &err);
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
g_error ("Could not get structures from %s: %s", scenario_file, err);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -671,26 +686,21 @@ gst_validate_utils_structs_parse_from_filename (const gchar * scenario_file,
|
||||||
GList *
|
GList *
|
||||||
gst_validate_structs_parse_from_gfile (GFile * scenario_file)
|
gst_validate_structs_parse_from_gfile (GFile * scenario_file)
|
||||||
{
|
{
|
||||||
gchar **lines;
|
gchar **lines, *err = NULL;
|
||||||
|
GList *res;
|
||||||
|
|
||||||
lines = _file_get_lines (scenario_file);
|
lines = _file_get_lines (scenario_file);
|
||||||
|
|
||||||
if (lines == NULL)
|
if (lines == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return _lines_get_structures (lines);
|
res = _lines_get_structures (lines, &err);
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
if (err)
|
||||||
strv_contains (GStrv strv, const gchar * str)
|
g_error ("Could not get structures from %s: %s",
|
||||||
{
|
g_file_get_uri (scenario_file), err);
|
||||||
guint i;
|
|
||||||
|
|
||||||
for (i = 0; strv[i] != NULL; i++)
|
return res;
|
||||||
if (g_strcmp0 (strv[i], str) == 0)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -709,7 +719,7 @@ gst_validate_element_has_klass (GstElement * element, const gchar * klass)
|
||||||
|
|
||||||
/* All the elements in 'a' have to be in 'b' */
|
/* All the elements in 'a' have to be in 'b' */
|
||||||
for (i = 0; a[i] != NULL; i++)
|
for (i = 0; a[i] != NULL; i++)
|
||||||
if (!strv_contains (b, a[i]))
|
if (!g_strv_contains ((const char *const *) b, a[i]))
|
||||||
goto done;
|
goto done;
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
|
|
||||||
|
|
|
@ -2230,8 +2230,8 @@ class ScenarioManager(Loggable):
|
||||||
"""
|
"""
|
||||||
scenarios = []
|
scenarios = []
|
||||||
scenario_defs = os.path.join(self.config.main_dir, "scenarios.def")
|
scenario_defs = os.path.join(self.config.main_dir, "scenarios.def")
|
||||||
logs = open(os.path.join(self.config.logsdir,
|
log_path = os.path.join(self.config.logsdir, "scenarios_discovery.log")
|
||||||
"scenarios_discovery.log"), 'w')
|
logs = open(log_path, 'w')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
command = [GstValidateBaseTestManager.COMMAND,
|
command = [GstValidateBaseTestManager.COMMAND,
|
||||||
|
@ -2240,6 +2240,7 @@ class ScenarioManager(Loggable):
|
||||||
subprocess.check_call(command, stdout=logs, stderr=logs)
|
subprocess.check_call(command, stdout=logs, stderr=logs)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
self.error(e)
|
self.error(e)
|
||||||
|
self.error('See %s' % log_path)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
config = configparser.RawConfigParser()
|
config = configparser.RawConfigParser()
|
||||||
|
|
Loading…
Reference in a new issue