From: Thibault Saunier Date: Thu, 16 Jan 2020 20:36:54 +0000 (-0300) Subject: validate: Enhance error reporting when scenario or configs are invalid X-Git-Tag: 1.19.3~491^2~210 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2036d8292fba2b9dc808ff26a94fabf844a70092;p=platform%2Fupstream%2Fgstreamer.git validate: Enhance error reporting when scenario or configs are invalid --- diff --git a/validate/gst/validate/gst-validate-utils.c b/validate/gst/validate/gst-validate-utils.c index 4bf95b1..f784e66 100644 --- a/validate/gst/validate/gst-validate-utils.c +++ b/validate/gst/validate/gst-validate-utils.c @@ -610,7 +610,7 @@ _get_lines (const gchar * scenario_file, gchar ** file_path) /* Returns: (transfer full): a #GList of #GstStructure */ static GList * -_lines_get_structures (gchar ** lines) +_lines_get_structures (gchar ** lines, gchar ** err) { gint i; GList *structures = NULL; @@ -626,8 +626,17 @@ _lines_get_structures (gchar ** lines) structure = gst_structure_from_string (lines[i], NULL); if (structure == NULL) { - GST_ERROR ("Could not parse action %s", lines[i]); - goto failed; + 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; + } } structures = g_list_append (structures, structure); @@ -653,7 +662,8 @@ GList * gst_validate_utils_structs_parse_from_filename (const gchar * scenario_file, gchar ** file_path) { - gchar **lines; + GList *res; + gchar **lines, *err = NULL; 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 _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 * gst_validate_structs_parse_from_gfile (GFile * scenario_file) { - gchar **lines; + gchar **lines, *err = NULL; + GList *res; lines = _file_get_lines (scenario_file); if (lines == NULL) return NULL; - return _lines_get_structures (lines); -} + res = _lines_get_structures (lines, &err); -static gboolean -strv_contains (GStrv strv, const gchar * str) -{ - guint i; - - for (i = 0; strv[i] != NULL; i++) - if (g_strcmp0 (strv[i], str) == 0) - return TRUE; + if (err) + g_error ("Could not get structures from %s: %s", + g_file_get_uri (scenario_file), err); - return FALSE; + return res; } 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' */ 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; result = TRUE; diff --git a/validate/launcher/baseclasses.py b/validate/launcher/baseclasses.py index a4c848b..3cda4d2 100644 --- a/validate/launcher/baseclasses.py +++ b/validate/launcher/baseclasses.py @@ -2230,8 +2230,8 @@ class ScenarioManager(Loggable): """ scenarios = [] scenario_defs = os.path.join(self.config.main_dir, "scenarios.def") - logs = open(os.path.join(self.config.logsdir, - "scenarios_discovery.log"), 'w') + log_path = os.path.join(self.config.logsdir, "scenarios_discovery.log") + logs = open(log_path, 'w') try: command = [GstValidateBaseTestManager.COMMAND, @@ -2240,6 +2240,7 @@ class ScenarioManager(Loggable): subprocess.check_call(command, stdout=logs, stderr=logs) except subprocess.CalledProcessError as e: self.error(e) + self.error('See %s' % log_path) pass config = configparser.RawConfigParser()