diff --git a/validate/gst/validate/gst-validate-media-info.c b/validate/gst/validate/gst-validate-media-info.c index ded0a952be..ed1113f4f5 100644 --- a/validate/gst/validate/gst-validate-media-info.c +++ b/validate/gst/validate/gst-validate-media-info.c @@ -27,6 +27,7 @@ #endif #include "gst-validate-media-info.h" +#include "validate.h" #include #include @@ -1070,41 +1071,45 @@ gst_validate_media_info_compare (GstValidateMediaInfo * expected, { gboolean ret = TRUE; if (expected->duration != extracted->duration) { - g_print ("Duration changed: %" GST_TIME_FORMAT " -> %" GST_TIME_FORMAT "\n", + gst_validate_printf (NULL, + "Duration changed: %" GST_TIME_FORMAT " -> %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (expected->duration), GST_TIME_ARGS (extracted->duration)); ret = FALSE; } if (expected->file_size != extracted->file_size) { - g_print ("File size changed: %" G_GUINT64_FORMAT " -> %" G_GUINT64_FORMAT - "\n", expected->file_size, extracted->file_size); + gst_validate_printf (NULL, + "File size changed: %" G_GUINT64_FORMAT " -> %" G_GUINT64_FORMAT "\n", + expected->file_size, extracted->file_size); ret = FALSE; } if (expected->seekable && !extracted->seekable) { - g_print ("File isn't seekable anymore\n"); + gst_validate_printf (NULL, "File isn't seekable anymore\n"); ret = FALSE; } if (extracted->discover_only == FALSE) { if (expected->playback_error == NULL && extracted->playback_error) { - g_print ("Playback is now failing with: %s\n", extracted->playback_error); + gst_validate_printf (NULL, "Playback is now failing with: %s\n", + extracted->playback_error); ret = FALSE; } if (expected->reverse_playback_error == NULL && extracted->reverse_playback_error) { - g_print ("Reverse playback is now failing with: %s\n", + gst_validate_printf (NULL, "Reverse playback is now failing with: %s\n", extracted->reverse_playback_error); ret = FALSE; } if (expected->track_switch_error == NULL && extracted->track_switch_error) { - g_print ("Track switching is now failing with: %s\n", + gst_validate_printf (NULL, "Track switching is now failing with: %s\n", extracted->track_switch_error); ret = FALSE; } } if (extracted->stream_info == NULL || expected->stream_info == NULL) { - g_print ("Stream infos could not be retrieved, an error occured\n"); + gst_validate_printf (NULL, + "Stream infos could not be retrieved, an error occured\n"); ret = FALSE; } else if (expected->stream_info && !gst_caps_is_equal_fixed (expected->stream_info->caps, @@ -1112,7 +1117,8 @@ gst_validate_media_info_compare (GstValidateMediaInfo * expected, gchar *caps1 = gst_caps_to_string (expected->stream_info->caps); gchar *caps2 = gst_caps_to_string (extracted->stream_info->caps); - g_print ("Media caps changed: '%s' -> '%s'\n", caps1, caps2); + gst_validate_printf (NULL, "Media caps changed: '%s' -> '%s'\n", caps1, + caps2); g_free (caps1); g_free (caps2); ret = FALSE; diff --git a/validate/gst/validate/gst-validate-override-registry.c b/validate/gst/validate/gst-validate-override-registry.c index 1506366d49..32073e39ff 100644 --- a/validate/gst/validate/gst-validate-override-registry.c +++ b/validate/gst/validate/gst-validate-override-registry.c @@ -265,35 +265,38 @@ _add_override_from_struct (GstStructure * soverride) if (!gst_structure_has_name (soverride, "change-severity") && !gst_structure_has_name (soverride, "change-issue-severity")) { - g_error ("Currently only 'change-severity' overrides are supported"); + gst_validate_abort + ("Currently only 'change-severity' overrides are supported"); return FALSE; } str_issue_id = gst_structure_get_string (soverride, "issue-id"); if (!str_issue_id) { - g_error ("No issue id provided in override: %" GST_PTR_FORMAT, soverride); + gst_validate_abort ("No issue id provided in override: %" GST_PTR_FORMAT, + soverride); return FALSE; } issue_id = g_quark_from_string (str_issue_id); if (gst_validate_issue_from_id (issue_id) == NULL) { - g_error ("No GstValidateIssue registered for %s", str_issue_id); + gst_validate_abort ("No GstValidateIssue registered for %s", str_issue_id); return FALSE; } str_new_severity = gst_structure_get_string (soverride, "new-severity"); if (str_new_severity == NULL) { - g_error ("No 'new-severity' field found in %" GST_PTR_FORMAT, soverride); + gst_validate_abort ("No 'new-severity' field found in %" GST_PTR_FORMAT, + soverride); return FALSE; } level = gst_validate_report_level_from_name (str_new_severity); if (level == GST_VALIDATE_REPORT_LEVEL_UNKNOWN) { - g_error ("Unknown level name %s", str_new_severity); + gst_validate_abort ("Unknown level name %s", str_new_severity); return FALSE; } diff --git a/validate/gst/validate/gst-validate-report.c b/validate/gst/validate/gst-validate-report.c index 7b1224ead7..558c640078 100644 --- a/validate/gst/validate/gst-validate-report.c +++ b/validate/gst/validate/gst-validate-report.c @@ -1300,3 +1300,72 @@ gst_validate_print_issues (void) g_hash_table_foreach (_gst_validate_issues, (GHFunc) print_issue, NULL); } + +void +gst_validate_error_structure (gpointer structure, const gchar * format, ...) +{ + gchar *filename = NULL; + gint lineno = -1; + gchar *tmp, *debug = NULL; + GString *f = g_string_new (NULL); + va_list var_args; + gchar *color = NULL; + + const gchar *endcolor = ""; + +#if GLIB_CHECK_VERSION(2,50,0) + if (g_log_writer_supports_color (fileno (stderr))) { + color = gst_debug_construct_term_color (GST_DEBUG_FG_RED); + endcolor = "\033[0m"; + } +#endif + + if (structure) { + if (GST_IS_STRUCTURE (structure)) { + filename = + g_strdup (gst_structure_get_string (structure, "__filename__")); + debug = g_strdup (gst_structure_get_string (structure, "__debug__")); + gst_structure_get_int (structure, "__lineno__", &lineno); + /* We are going to assert... we can boutcher the struct! */ + gst_structure_remove_fields (structure, "__filename__", "__lineno__", + "__debug__", NULL); + } else { + filename = g_strdup (GST_VALIDATE_ACTION_FILENAME (structure)); + debug = g_strdup (GST_VALIDATE_ACTION_DEBUG (structure)); + lineno = GST_VALIDATE_ACTION_LINENO (structure); + } + } + + va_start (var_args, format); + tmp = gst_info_strdup_vprintf (format, var_args); + va_end (var_args); + + g_string_append_printf (f, "%s:%d: %s\n", + filename ? filename : "Unknown", lineno, tmp); + + if (debug) + g_string_append (f, debug); + + g_print ("Bail out! %sERROR%s: %s\n\n", color ? color : "", endcolor, f->str); + g_string_free (f, TRUE); + g_free (debug); + g_free (color); + g_free (filename); + g_free (tmp); + + exit (-18); +} + +void +gst_validate_abort (const gchar * format, ...) +{ + va_list var_args; + gchar *tmp; + + va_start (var_args, format); + tmp = gst_info_strdup_vprintf (format, var_args); + va_end (var_args); + + g_print ("Bail out! %s\n", tmp); + exit (-18); +} diff --git a/validate/gst/validate/gst-validate-report.h b/validate/gst/validate/gst-validate-report.h index bc47ffd792..6029f1a8c2 100644 --- a/validate/gst/validate/gst-validate-report.h +++ b/validate/gst/validate/gst-validate-report.h @@ -314,6 +314,10 @@ GST_VALIDATE_API void gst_validate_print_position(GstClockTime position, GstClockTime duration, gdouble rate, gchar* extra_info); GST_VALIDATE_API void gst_validate_print_issues (void); +GST_VALIDATE_API +void gst_validate_error_structure (gpointer action, const gchar* format, ...) G_GNUC_PRINTF (2, 3); +GST_VALIDATE_API +void gst_validate_abort (const gchar * format, ...) G_GNUC_PRINTF (1, 2); G_END_DECLS #endif /* __GST_VALIDATE_REPORT_H__ */ diff --git a/validate/gst/validate/gst-validate-reporter.c b/validate/gst/validate/gst-validate-reporter.c index 3110d4bd77..0c5fcf38ad 100644 --- a/validate/gst/validate/gst-validate-reporter.c +++ b/validate/gst/validate/gst-validate-reporter.c @@ -250,7 +250,8 @@ gst_validate_report_valist (GstValidateReporter * reporter, if (runner) gst_validate_runner_printf (runner); - g_error ("Fatal report received: %" GST_VALIDATE_ERROR_REPORT_PRINT_FORMAT, + gst_validate_abort ("Fatal report received: %" + GST_VALIDATE_ERROR_REPORT_PRINT_FORMAT, GST_VALIDATE_REPORT_PRINT_ARGS (report)); } @@ -268,7 +269,7 @@ gst_validate_default_log_hanlder (const gchar * log_domain, gchar *trace = gst_debug_get_stack_trace (GST_STACK_TRACE_SHOW_FULL); if (trace) { - g_print ("\nStack trace:\n%s\n", trace); + gst_validate_printf (NULL, "\nStack trace:\n%s\n", trace); g_free (trace); } diff --git a/validate/gst/validate/gst-validate-runner.c b/validate/gst/validate/gst-validate-runner.c index d116c630a9..386fee80f1 100644 --- a/validate/gst/validate/gst-validate-runner.c +++ b/validate/gst/validate/gst-validate-runner.c @@ -471,7 +471,8 @@ gst_validate_runner_new (void) runner = first_runner; first_runner = NULL; } else if (element_created) { - g_error ("Should never create a GstValidateRunner after a GstElement " + gst_validate_abort + ("Should never create a GstValidateRunner after a GstElement " "has been created in the same process."); return NULL; diff --git a/validate/gst/validate/gst-validate-scenario.c b/validate/gst/validate/gst-validate-scenario.c index 6d62450b43..6bcab936e8 100644 --- a/validate/gst/validate/gst-validate-scenario.c +++ b/validate/gst/validate/gst-validate-scenario.c @@ -282,38 +282,6 @@ gst_validate_g_enum_to_string (GType g_enum_type, gint value) } #endif -static void -g_error_action (gpointer action, const gchar * format, ...) -{ - const gchar *filename = NULL; - gint lineno = -1; - gchar *f, *tmp; - va_list var_args; - - if (action) { - if (GST_IS_STRUCTURE (action)) { - filename = gst_structure_get_string (action, "__filename__"); - gst_structure_get_int (action, "__lineno__", &lineno); - } else { - filename = GST_VALIDATE_ACTION_FILENAME (action); - lineno = GST_VALIDATE_ACTION_LINENO (action); - } - } - - f = filename ? g_strdup_printf ("\n> %s:%d\n> %d | %s\n> %*c|\n", - filename, lineno, lineno, format, - (gint) floor (log10 (abs ((lineno)))) + 1, ' ') - : g_strdup (format); - - va_start (var_args, format); - tmp = gst_info_strdup_vprintf (f, var_args); - va_end (var_args); - g_free (f); - - g_error ("%s", tmp); - g_free (tmp); -} - static void gst_validate_seek_information_free (GstValidateSeekInformation * info) { @@ -456,6 +424,7 @@ _action_copy (GstValidateAction * act) GST_VALIDATE_ACTION_LINENO (copy) = GST_VALIDATE_ACTION_LINENO (act); GST_VALIDATE_ACTION_FILENAME (copy) = g_strdup (GST_VALIDATE_ACTION_FILENAME (act)); + GST_VALIDATE_ACTION_DEBUG (copy) = g_strdup (GST_VALIDATE_ACTION_DEBUG (act)); return copy; } @@ -471,6 +440,7 @@ _action_free (GstValidateAction * action) g_weak_ref_clear (&action->priv->scenario); g_free (GST_VALIDATE_ACTION_FILENAME (action)); + g_free (GST_VALIDATE_ACTION_DEBUG (action)); g_slice_free (GstValidateActionPrivate, action->priv); g_slice_free (GstValidateAction, action); @@ -515,8 +485,9 @@ gst_validate_action_new (GstValidateScenario * scenario, gst_structure_get (structure, "__lineno__", G_TYPE_INT, &GST_VALIDATE_ACTION_LINENO (action), "__filename__", G_TYPE_STRING, &GST_VALIDATE_ACTION_FILENAME (action), - NULL); - gst_structure_remove_fields (structure, "__lineno__", "__filename__", NULL); + "__debug__", G_TYPE_STRING, &GST_VALIDATE_ACTION_DEBUG (action), NULL); + gst_structure_remove_fields (structure, "__lineno__", "__filename__", + "__debug__", NULL); g_weak_ref_set (&action->priv->scenario, scenario); if (structure) @@ -2045,8 +2016,8 @@ _set_action_playback_time (GstValidateScenario * scenario, { if (!gst_validate_action_get_clocktime (scenario, action, "playback-time", &action->playback_time)) { - g_error_action (action, "Could not parse playback-time in %" GST_PTR_FORMAT, - action->structure); + gst_validate_error_structure (action, + "Could not parse playback-time in %" GST_PTR_FORMAT, action->structure); return FALSE; } @@ -2350,7 +2321,8 @@ execute_next_action_full (GstValidateScenario * scenario, GstMessage * message) priv->actions = g_list_remove_link (priv->actions, tmp); if (!gst_validate_parse_next_action_playback_time (scenario)) { - g_error_action (priv->actions ? priv->actions->data : NULL, + gst_validate_error_structure (priv->actions ? priv-> + actions->data : NULL, "Could not determine next action playback time!"); return G_SOURCE_REMOVE; @@ -2441,7 +2413,7 @@ execute_next_action_full (GstValidateScenario * scenario, GstMessage * message) priv->actions = g_list_remove_link (priv->actions, tmp); if (!gst_validate_parse_next_action_playback_time (scenario)) { - g_error_action (priv->actions ? priv->actions->data : NULL, + gst_validate_error_structure (priv->actions ? priv->actions->data : NULL, "Could not determine next action playback time!"); return G_SOURCE_REMOVE; @@ -3313,7 +3285,7 @@ gst_validate_action_default_prepare_func (GstValidateAction * action) repeat_expr = g_strdup (gst_structure_get_string (action->structure, "repeat")); if (!repeat_expr) { - g_error_action (action, "Invalid value for 'repeat'"); + gst_validate_error_structure (action, "Invalid value for 'repeat'"); goto err; } @@ -3321,7 +3293,7 @@ gst_validate_action_default_prepare_func (GstValidateAction * action) gst_validate_utils_parse_expression (repeat_expr, _set_variable_func, scenario, &error); if (error) { - g_error_action (action, "Invalid value for 'repeat'"); + gst_validate_error_structure (action, "Invalid value for 'repeat'"); goto err; } g_free (repeat_expr); @@ -3813,7 +3785,8 @@ gst_validate_scenario_load_structures (GstValidateScenario * scenario, continue; } - g_error_action (structure, "We do not handle action types %s", type); + gst_validate_error_structure (structure, + "We do not handle action types %s", type); goto failed; } @@ -3827,7 +3800,7 @@ gst_validate_scenario_load_structures (GstValidateScenario * scenario, if (action_type->parameters[i].mandatory && gst_structure_has_field (structure, action_type->parameters[i].name) == FALSE) { - g_error_action (structure, + gst_validate_error_structure (structure, "Mandatory field '%s' not present in structure: %" GST_PTR_FORMAT, action_type->parameters[i].name, structure); goto failed; @@ -4010,7 +3983,7 @@ done: g_strfreev (scenarios); if (ret == FALSE) - g_error ("Could not set scenario %s => EXIT\n", scenario_name); + gst_validate_abort ("Could not set scenario %s => EXIT\n", scenario_name); return ret; @@ -4521,7 +4494,7 @@ _parse_scenario (GFile * f, GKeyFile * kf) gst_validate_scenario_check_and_set_needs_clock_sync (structures, &meta); for (tmp = structures; tmp; tmp = tmp->next) gst_structure_remove_fields (tmp->data, "__lineno__", "__filename__", - NULL); + "__debug__", NULL); if (meta) { KeyFileGroupName kfg; @@ -4529,6 +4502,8 @@ _parse_scenario (GFile * f, GKeyFile * kf) kfg.group_name = g_file_get_path (f); kfg.kf = kf; + gst_structure_remove_fields (meta, "__lineno__", "__filename__", + "__debug__", NULL); gst_structure_foreach (meta, (GstStructureForeachFunc) _add_description, &kfg); gst_structure_free (meta); @@ -4634,7 +4609,7 @@ gst_validate_list_scenarios (gchar ** scenarios, gint num_scenarios, done: result = g_key_file_to_data (kf, &datalength, &err); - g_print ("All scenarios available:\n%s", result); + gst_validate_printf (NULL, "All scenarios available:\n%s", result); if (output_file && !err) { if (!g_file_set_contents (output_file, result, datalength, &err)) { @@ -5573,8 +5548,8 @@ init_scenarios (void) GstValidateActionType *atype = _find_action_type (action_typename); if (!atype) { - g_error_action (plug_conf, "[CONFIG ERROR] Action type %s not found", - action_typename); + gst_validate_error_structure (plug_conf, + "[CONFIG ERROR] Action type %s not found", action_typename); continue; } @@ -5588,7 +5563,7 @@ init_scenarios (void) if (!(atype->flags & GST_VALIDATE_ACTION_TYPE_CONFIG) && !(_action_type_has_parameter (atype, "as-config"))) { - g_error_action (plug_conf, + gst_validate_error_structure (plug_conf, "[CONFIG ERROR] Action '%s' is not a config action", action_typename); diff --git a/validate/gst/validate/gst-validate-scenario.h b/validate/gst/validate/gst-validate-scenario.h index ac4ca37583..b1c6623b3b 100644 --- a/validate/gst/validate/gst-validate-scenario.h +++ b/validate/gst/validate/gst-validate-scenario.h @@ -91,6 +91,7 @@ typedef struct _GstValidateActionPrivate GstValidateActionPrivate; #define GST_VALIDATE_ACTION_LINENO(action) (((GstValidateAction*) action)->ABI.abi.lineno) #define GST_VALIDATE_ACTION_FILENAME(action) (((GstValidateAction*) action)->ABI.abi.filename) +#define GST_VALIDATE_ACTION_DEBUG(action) (((GstValidateAction*) action)->ABI.abi.debug) /** * GstValidateAction: @@ -129,6 +130,7 @@ struct _GstValidateAction struct { gint lineno; gchar *filename; + gchar *debug; } abi; } ABI; }; diff --git a/validate/gst/validate/gst-validate-utils.c b/validate/gst/validate/gst-validate-utils.c index 179ef5b301..0700f555c4 100644 --- a/validate/gst/validate/gst-validate-utils.c +++ b/validate/gst/validate/gst-validate-utils.c @@ -509,7 +509,7 @@ gst_validate_utils_flags_from_str (GType type, const gchar * str_flags) g_value_init (&value, type); if (!gst_value_deserialize (&value, str_flags)) { - g_error ("Invalid flags: %s", str_flags); + gst_validate_abort ("Invalid flags: %s", str_flags); return 0; } @@ -536,7 +536,7 @@ gst_validate_utils_enum_from_str (GType type, const gchar * str_enum, g_value_init (&value, type); if (!gst_value_deserialize (&value, str_enum)) { - g_error ("Invalid enum: %s", str_enum); + gst_validate_abort ("Invalid enum: %s", str_enum); return FALSE; } @@ -613,6 +613,7 @@ _file_get_structures (GFile * file, gchar ** err) l = g_string_new (NULL); debug_line = g_string_new (NULL); current_lineno = lineno; + g_string_append_printf (debug_line, " %4d | ", lineno); while (*tmp != '\n' && *tmp) { gchar next; @@ -659,8 +660,8 @@ _file_get_structures (GFile * file, gchar ** err) if (errstr) { g_string_append_printf (errstr, - "\n%s:%d-%d: Invalid structure\n %4d | %s", - filename, current_lineno, lineno, current_lineno, debug_line->str); + "\n%s:%d-%d: Invalid structure\n%s", + filename, current_lineno, lineno, debug_line->str); if (strchr (debug_line->str, '\n')) g_string_append_printf (errstr, "\n > %s\n", l->str); @@ -674,7 +675,8 @@ _file_get_structures (GFile * file, gchar ** err) } else { gst_structure_set (structure, "__lineno__", G_TYPE_INT, current_lineno, - "__filename__", G_TYPE_STRING, filename, NULL); + "__filename__", G_TYPE_STRING, filename, + "__debug__", G_TYPE_STRING, debug_line->str, NULL); structures = g_list_append (structures, structure); } @@ -737,7 +739,8 @@ gst_validate_utils_structs_parse_from_filename (const gchar * scenario_file, res = _get_structures (scenario_file, file_path, &err); if (err) - g_error ("Could not get structures from %s:\n%s\n", scenario_file, err); + gst_validate_abort ("Could not get structures from %s:\n%s\n", + scenario_file, err); return res; } @@ -753,7 +756,7 @@ gst_validate_structs_parse_from_gfile (GFile * scenario_file) res = _file_get_structures (scenario_file, &err); if (err) - g_error ("Could not get structures from %s:\n%s\n", + gst_validate_abort ("Could not get structures from %s:\n%s\n", g_file_get_uri (scenario_file), err); return res; @@ -990,7 +993,7 @@ fault_handler_sighandler (int signum) g_printerr ("\n"); break; case SIGQUIT: - g_print ("\n"); + gst_validate_printf (NULL, "\n"); break; default: g_printerr ("\n", signum); diff --git a/validate/gst/validate/media-descriptor-writer.c b/validate/gst/validate/media-descriptor-writer.c index c20155069a..1a7c242be6 100644 --- a/validate/gst/validate/media-descriptor-writer.c +++ b/validate/gst/validate/media-descriptor-writer.c @@ -604,7 +604,7 @@ _run_frame_analysis (GstValidateMediaDescriptorWriter * writer, switch (sret) { case GST_STATE_CHANGE_FAILURE: /* ignore, we should get an error message posted on the bus */ - g_print ("Pipeline failed to go to PLAYING state\n"); + gst_validate_printf (NULL, "Pipeline failed to go to PLAYING state\n"); return FALSE; default: break; diff --git a/validate/gst/validate/validate.c b/validate/gst/validate/validate.c index dfeebfdd08..0405712aac 100644 --- a/validate/gst/validate/validate.c +++ b/validate/gst/validate/validate.c @@ -237,7 +237,7 @@ static GList * gst_validate_get_testfile_configs (const gchar * suffix) { GList *res = NULL; - gchar **config_strs = NULL, *filename = NULL; + gchar **config_strs = NULL, *filename = NULL, *debug = NULL; gint current_lineno = -1; GstStructure *meta = get_test_file_meta (); @@ -246,6 +246,7 @@ gst_validate_get_testfile_configs (const gchar * suffix) gst_structure_get (meta, "__lineno__", G_TYPE_INT, ¤t_lineno, + "__debug__", G_TYPE_STRING, &debug, "__filename__", G_TYPE_STRING, &filename, NULL); config_strs = gst_validate_utils_get_strv (meta, "configs"); @@ -257,14 +258,14 @@ gst_validate_get_testfile_configs (const gchar * suffix) gst_structure_from_string (config_strs[i], NULL); if (tmpstruct == NULL) { - g_error ("%s:%d: Invalid structure\n %d | %s\n %*c|", - filename, current_lineno, current_lineno, config_strs[i], - (gint) floor (log10 (abs ((current_lineno)))) + 1, ' '); + gst_validate_abort ("%s:%d: Invalid structure\n %4d | %s\n%s", + filename, current_lineno, current_lineno, config_strs[i], debug); } gst_structure_set (tmpstruct, "__lineno__", G_TYPE_INT, current_lineno, - "__filename__", G_TYPE_STRING, filename, NULL); + "__filename__", G_TYPE_STRING, filename, + "__debug__", G_TYPE_STRING, debug, NULL); res = g_list_append (res, tmpstruct); } } @@ -519,7 +520,7 @@ gst_validate_setup_test_file (const gchar * testfile, gboolean use_fakesinks) GstStructure *res = NULL; if (global_testfile) - g_error ("A testfile was already loaded: %s", global_testfile); + gst_validate_abort ("A testfile was already loaded: %s", global_testfile); gst_validate_set_globals (NULL); gst_validate_structure_set_variables_from_struct_file (NULL, testfile); @@ -527,7 +528,7 @@ gst_validate_setup_test_file (const gchar * testfile, gboolean use_fakesinks) gst_validate_utils_structs_parse_from_filename (testfile, NULL); if (!testfile_structs) - g_error ("Could not load test file: %s", testfile); + gst_validate_abort ("Could not load test file: %s", testfile); res = testfile_structs->data; if (gst_structure_has_name (testfile_structs->data, "set-globals")) { @@ -537,7 +538,8 @@ gst_validate_setup_test_file (const gchar * testfile, gboolean use_fakesinks) } if (!gst_structure_has_name (res, "meta")) - g_error ("First structure of a .validatetest file should be a `meta` or " + gst_validate_abort + ("First structure of a .validatetest file should be a `meta` or " "`set-gobals` then `meta`, got: %s", gst_structure_to_string (res)); register_action_types (); @@ -552,7 +554,8 @@ gst_validate_setup_test_file (const gchar * testfile, gboolean use_fakesinks) tool = "gst-validate-" GST_API_VERSION; if (g_strcmp0 (tool, g_get_prgname ())) - g_error ("Validate test file: '%s' was made to be run with '%s' not '%s'", + gst_validate_abort + ("Validate test file: '%s' was made to be run with '%s' not '%s'", testfile, tool, g_get_prgname ()); global_testfile = g_strdup (testfile); diff --git a/validate/plugins/extra_checks/gstvalidateextrachecks.c b/validate/plugins/extra_checks/gstvalidateextrachecks.c index 6f1890e712..c719859c72 100644 --- a/validate/plugins/extra_checks/gstvalidateextrachecks.c +++ b/validate/plugins/extra_checks/gstvalidateextrachecks.c @@ -23,21 +23,24 @@ gst_validate_check_num_instances_data_new (GstStructure * check) if (!gst_structure_get_int (check, "num-instances", &data->expected_n_instances)) { - g_error ("[CONFIG ERROR] Mandatory field `num-instances` not found in " + gst_validate_abort + ("[CONFIG ERROR] Mandatory field `num-instances` not found in " "extra-check `num-instances`"); goto failed; } data->pname = g_strdup (gst_structure_get_string (check, "pipeline-name")); if (!data->pname) { - g_error ("[CONFIG ERROR] Mandatory field `pipeline` not found in " + gst_validate_abort + ("[CONFIG ERROR] Mandatory field `pipeline` not found in " "extra-check `num-instances`"); goto failed; } data->klass = g_strdup (gst_structure_get_string (check, "element-klass")); if (!data->klass) { - g_error ("[CONFIG ERROR] Mandatory field `element-klass` not found in " + gst_validate_abort + ("[CONFIG ERROR] Mandatory field `element-klass` not found in " "extra-check `num-instances`"); goto failed; } diff --git a/validate/plugins/flow/gstvalidateflow.c b/validate/plugins/flow/gstvalidateflow.c index 776048680f..f0b812cd3d 100644 --- a/validate/plugins/flow/gstvalidateflow.c +++ b/validate/plugins/flow/gstvalidateflow.c @@ -219,7 +219,8 @@ validate_flow_override_new (GstStructure * config) { ValidateFlowOverride *flow; GstValidateOverride *override; - gchar *ignored_fields, *logged_fields; + gchar *ignored_fields = NULL, *logged_fields; + const GValue *tmpval; flow = g_object_new (VALIDATE_TYPE_FLOW_OVERRIDE, NULL); GST_OBJECT_FLAG_SET (flow, GST_OBJECT_FLAG_MAY_BE_LEAKED); @@ -228,8 +229,8 @@ validate_flow_override_new (GstStructure * config) /* pad: Name of the pad where flowing buffers and events will be monitorized. */ flow->pad_name = gst_structure_get_string (config, "pad"); if (!flow->pad_name) { - g_error ("pad property is mandatory, not found in %s", - gst_structure_to_string (config)); + gst_validate_error_structure (config, + "pad property is mandatory, not found in %" GST_PTR_FORMAT, config); } /* record-buffers: Whether buffers will be written to the expectation log. */ @@ -254,14 +255,23 @@ validate_flow_override_new (GstStructure * config) flow->ignored_event_types = gst_validate_utils_get_strv (config, "ignored-event-types"); - ignored_fields = - (gchar *) gst_structure_get_string (config, "ignored-fields"); + tmpval = gst_structure_get_value (config, "ignored-fields"); + if (tmpval) { + if (!G_VALUE_HOLDS_STRING (tmpval)) { + gst_validate_error_structure (config, + "Invalid value type for `ignored-fields`: '%s' instead of 'string'", + G_VALUE_TYPE_NAME (tmpval)); + } + ignored_fields = (gchar *) g_value_get_string (tmpval); + } + if (ignored_fields) { ignored_fields = g_strdup_printf ("ignored,%s", ignored_fields); flow->ignored_fields = gst_structure_new_from_string (ignored_fields); if (!flow->ignored_fields) - g_error ("Could not parse 'ignored-event-fields' %s in %s", - ignored_fields, gst_structure_to_string (config)); + gst_validate_error_structure (config, + "Could not parse 'ignored-event-fields' structure: `%s`", + ignored_fields); g_free (ignored_fields); } else { flow->ignored_fields = @@ -277,8 +287,8 @@ validate_flow_override_new (GstStructure * config) logged_fields = g_strdup_printf ("logged,%s", logged_fields); flow->logged_fields = gst_structure_new_from_string (logged_fields); if (!flow->logged_fields) - g_error ("Could not parse 'logged-fields' %s in %s", - logged_fields, gst_structure_to_string (config)); + gst_validate_error_structure (config, + "Could not parse 'logged-fields' %s", logged_fields); g_free (logged_fields); } else { flow->logged_fields = NULL; @@ -331,7 +341,7 @@ validate_flow_override_new (GstStructure * config) { gchar *directory_path = g_path_get_dirname (flow->output_file_path); if (g_mkdir_with_parents (directory_path, 0755) < 0) { - g_error ("Could not create directory tree: %s Reason: %s", + gst_validate_abort ("Could not create directory tree: %s Reason: %s", directory_path, g_strerror (errno)); } g_free (directory_path); @@ -339,7 +349,8 @@ validate_flow_override_new (GstStructure * config) flow->output_file = fopen (flow->output_file_path, "w"); if (!flow->output_file) - g_error ("Could not open for writing: %s", flow->output_file_path); + gst_validate_abort ("Could not open for writing: %s", + flow->output_file_path); flow->was_attached = FALSE; @@ -452,7 +463,7 @@ runner_stopping (GstValidateRunner * runner, ValidateFlowOverride * flow) GError *error = NULL; g_file_get_contents (flow->expectations_file_path, &contents, NULL, &error); if (error) { - g_error ("Failed to open expectations file: %s Reason: %s", + gst_validate_abort ("Failed to open expectations file: %s Reason: %s", flow->expectations_file_path, error->message); } lines_expected = g_strsplit (contents, "\n", 0); @@ -465,7 +476,7 @@ runner_stopping (GstValidateRunner * runner, ValidateFlowOverride * flow) g_file_get_contents (flow->actual_results_file_path, &contents, NULL, &error); if (error) { - g_error ("Failed to open actual results file: %s Reason: %s", + gst_validate_abort ("Failed to open actual results file: %s Reason: %s", flow->actual_results_file_path, error->message); } lines_actual = g_strsplit (contents, "\n", 0); diff --git a/validate/tools/gst-validate-images-check.c b/validate/tools/gst-validate-images-check.c index 518de1e7ff..3e1625ccd0 100644 --- a/validate/tools/gst-validate-images-check.c +++ b/validate/tools/gst-validate-images-check.c @@ -108,14 +108,14 @@ main (int argc, char **argv) if (ret == 0) { ret = rep_err; if (rep_err != 0) - g_print ("Returning %d as error where found", rep_err); + gst_validate_printf (NULL, "Returning %d as error where found", rep_err); } g_object_unref (ssim); g_object_unref (runner); gst_validate_deinit (); - g_print ("\n=======> Test %s (Return value: %i)\n\n", + gst_validate_printf (NULL, "\n=======> Test %s (Return value: %i)\n\n", ret == 0 ? "PASSED" : "FAILED", ret); return ret; diff --git a/validate/tools/gst-validate-media-check.c b/validate/tools/gst-validate-media-check.c index b388443257..f357ac4eb1 100644 --- a/validate/tools/gst-validate-media-check.c +++ b/validate/tools/gst-validate-media-check.c @@ -112,7 +112,7 @@ main (int argc, gchar ** argv) gst_validate_media_descriptor_parser_new (runner, expected_file, NULL); if (reference == NULL) { - g_print ("Could not parse file: %s\n", expected_file); + gst_validate_printf (NULL, "Could not parse file: %s\n", expected_file); ret = 1; goto out; } @@ -136,7 +136,7 @@ main (int argc, gchar ** argv) gst_validate_media_descriptor_writer_new_discover (runner, argv[1], writer_flags, NULL); if (writer == NULL) { - g_print ("Could not discover file: %s\n", argv[1]); + gst_validate_printf (NULL, "Could not discover file: %s\n", argv[1]); ret = 1; goto out; } @@ -156,7 +156,7 @@ main (int argc, gchar ** argv) } } else { output = gst_validate_media_descriptor_writer_serialize (writer); - g_print ("Media info:\n%s\n", output); + gst_validate_printf (NULL, "Media info:\n%s\n", output); g_free (output); } @@ -180,7 +180,7 @@ out: gst_validate_deinit (); gst_deinit (); - g_print ("\n=======> Test %s (Return value: %i)\n\n", + gst_validate_printf (NULL, "\n=======> Test %s (Return value: %i)\n\n", ret == 0 ? "PASSED" : "FAILED", ret); return ret; diff --git a/validate/tools/gst-validate-rtsp-server.c b/validate/tools/gst-validate-rtsp-server.c index 93602db95f..00abbd5d55 100644 --- a/validate/tools/gst-validate-rtsp-server.c +++ b/validate/tools/gst-validate-rtsp-server.c @@ -52,7 +52,7 @@ remove_map (GstRTSPServer * server) { GstRTSPMountPoints *mounts; - g_print ("removing /test mount point\n"); + gst_validate_printf (NULL, "removing /test mount point\n"); mounts = gst_rtsp_server_get_mount_points (server); gst_rtsp_mount_points_remove_factory (mounts, "/test"); g_object_unref (mounts); diff --git a/validate/tools/gst-validate-transcoding.c b/validate/tools/gst-validate-transcoding.c index 5f6be5b30f..fcf07daa74 100644 --- a/validate/tools/gst-validate-transcoding.c +++ b/validate/tools/gst-validate-transcoding.c @@ -57,10 +57,10 @@ static gboolean is_live = FALSE; static gboolean intr_handler (gpointer user_data) { - g_print ("interrupt received.\n"); + gst_validate_printf (NULL, "interrupt received.\n"); if (eos_on_shutdown) { - g_print ("Sending EOS to the pipeline\n"); + gst_validate_printf (NULL, "Sending EOS to the pipeline\n"); eos_on_shutdown = FALSE; gst_element_send_event (GST_ELEMENT_CAST (user_data), gst_event_new_eos ()); return TRUE; @@ -90,11 +90,11 @@ _execute_set_restriction (GstValidateScenario * scenario, profile_type = g_type_from_name (profile_type_name); if (profile_type == G_TYPE_NONE) { - g_error ("Profile name %s not known", profile_name); + gst_validate_abort ("Profile name %s not known", profile_name); return FALSE; } else if (profile_type == GST_TYPE_ENCODING_CONTAINER_PROFILE) { - g_error ("Can not set restrictions on container profiles"); + gst_validate_abort ("Can not set restrictions on container profiles"); return FALSE; } @@ -115,7 +115,7 @@ _execute_set_restriction (GstValidateScenario * scenario, caps = gst_caps_from_string (restriction_caps); if (caps == NULL) { - g_error ("Could not parse caps: %s", restriction_caps); + gst_validate_abort ("Could not parse caps: %s", restriction_caps); return FALSE; } @@ -143,7 +143,7 @@ _execute_set_restriction (GstValidateScenario * scenario, } if (!found) { - g_error ("Could not find profile for %s%s", + gst_validate_abort ("Could not find profile for %s%s", profile_type_name ? profile_type_name : "", profile_name ? profile_name : ""); @@ -239,7 +239,7 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data) } if (!buffering) { - g_print ("\n"); + gst_validate_printf (NULL, "\n"); } gst_message_parse_buffering (message, &percent); @@ -560,20 +560,20 @@ main (int argc, gchar ** argv) g_signal_connect (bus, "message", (GCallback) bus_callback, &bus_callback_data); - g_print ("Starting pipeline\n"); + gst_validate_printf (NULL, "Starting pipeline\n"); sret = gst_element_set_state (pipeline, GST_STATE_PLAYING); switch (sret) { case GST_STATE_CHANGE_FAILURE: /* ignore, we should get an error message posted on the bus */ - g_print ("Pipeline failed to go to PLAYING state\n"); + gst_validate_printf (NULL, "Pipeline failed to go to PLAYING state\n"); ret = -1; goto exit; case GST_STATE_CHANGE_NO_PREROLL: - g_print ("Pipeline is live.\n"); + gst_validate_printf (NULL, "Pipeline is live.\n"); is_live = TRUE; break; case GST_STATE_CHANGE_ASYNC: - g_print ("Prerolling...\r"); + gst_validate_printf (NULL, "Prerolling...\r"); break; default: break; @@ -603,7 +603,7 @@ exit: gst_validate_deinit (); gst_deinit (); - g_print ("\n=======> Test %s (Return value: %i)\n\n", + gst_validate_printf (NULL, "\n=======> Test %s (Return value: %i)\n\n", ret == 0 ? "PASSED" : "FAILED", ret); return ret; } diff --git a/validate/tools/gst-validate.c b/validate/tools/gst-validate.c index 0825748a3a..77682d75ff 100644 --- a/validate/tools/gst-validate.c +++ b/validate/tools/gst-validate.c @@ -54,7 +54,7 @@ static gboolean is_live = FALSE; static gboolean intr_handler (gpointer user_data) { - g_print ("interrupt received.\n"); + gst_validate_printf (NULL, "interrupt received.\n"); GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "gst-validate.interrupted"); @@ -137,9 +137,10 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data) GST_DEBUG_GRAPH_SHOW_ALL, "gst-validate.warning"); gst_message_parse_warning (message, &gerror, &debug); - g_print ("WARNING: from element %s: %s\n", name, gerror->message); + gst_validate_printf (NULL, "WARNING: from element %s: %s\n", name, + gerror->message); if (debug) - g_print ("Additional debug info:\n%s\n", debug); + gst_validate_printf (NULL, "Additional debug info:\n%s\n", debug); g_clear_error (&gerror); g_free (debug); @@ -160,7 +161,7 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data) } if (!buffering) { - g_print ("\n"); + gst_validate_printf (NULL, "\n"); } gst_message_parse_buffering (message, &percent); @@ -313,7 +314,7 @@ run_test_from_file (const gchar * testfile, gboolean use_fakesinks) args = gst_validate_utils_get_strv (meta, "args"); if (!args) - g_error ("No 'args' in .validatetest meta structure: %s", + gst_validate_abort ("No 'args' in .validatetest meta structure: %s", gst_structure_to_string (meta)); for (argc = 0; args[argc]; argc++); @@ -407,7 +408,8 @@ main (int argc, gchar ** argv) "as gstreamer debugging"); if (argc == 1) { - g_print ("%s", g_option_context_get_help (ctx, FALSE, NULL)); + gst_validate_printf (NULL, "%s", g_option_context_get_help (ctx, FALSE, + NULL)); exit (1); } @@ -423,7 +425,8 @@ main (int argc, gchar ** argv) if (testfile) { is_testfile = TRUE; if (scenario) - g_error ("Can not specify scenario and testfile at the same time"); + gst_validate_abort + ("Can not specify scenario and testfile at the same time"); return run_test_from_file (testfile, use_fakesinks); } @@ -467,7 +470,8 @@ main (int argc, gchar ** argv) } if (argc == 1) { - g_print ("%s", g_option_context_get_help (ctx, FALSE, NULL)); + gst_validate_printf (NULL, "%s", g_option_context_get_help (ctx, FALSE, + NULL)); g_option_context_free (ctx); exit (1); } @@ -491,7 +495,7 @@ main (int argc, gchar ** argv) } if (!pipeline) { - g_print ("Failed to create pipeline: %s\n", + gst_validate_printf (NULL, "Failed to create pipeline: %s\n", err ? err->message : "unknown reason"); g_clear_error (&err); g_object_unref (runner); @@ -560,9 +564,9 @@ main (int argc, gchar ** argv) &bus_callback_data); if (argc == 2) - g_print ("**-> Starting pipeline**\n"); + gst_validate_printf (NULL, "**-> Starting pipeline**\n"); else - g_print ("**-> Starting pipeline**\n"); + gst_validate_printf (NULL, "**-> Starting pipeline**\n"); g_free (argvn); g_object_get (monitor, "handles-states", &monitor_handles_state, NULL); @@ -571,23 +575,23 @@ main (int argc, gchar ** argv) switch (sret) { case GST_STATE_CHANGE_FAILURE: /* ignore, we should get an error message posted on the bus */ - g_print ("Pipeline failed to go to PLAYING state\n"); + gst_validate_printf (NULL, "Pipeline failed to go to PLAYING state\n"); gst_element_set_state (pipeline, GST_STATE_NULL); ret = -1; goto exit; case GST_STATE_CHANGE_NO_PREROLL: - g_print ("Pipeline is live.\n"); + gst_validate_printf (NULL, "Pipeline is live.\n"); is_live = TRUE; break; case GST_STATE_CHANGE_ASYNC: - g_print ("Prerolling...\r"); + gst_validate_printf (NULL, "Prerolling...\r"); break; default: break; } - g_print ("**-> Pipeline started**\n"); + gst_validate_printf (NULL, "**-> Pipeline started**\n"); } else { - g_print ("**-> Letting scenario handle set state**\n"); + gst_validate_printf (NULL, "**-> Letting scenario handle set state**\n"); } g_main_loop_run (mainloop); @@ -603,7 +607,8 @@ main (int argc, gchar ** argv) if (ret == 0) { ret = rep_err; if (rep_err != 0) - g_print ("Returning %d as errors were found\n", rep_err); + gst_validate_printf (NULL, "Returning %d as errors were found\n", + rep_err); } exit: @@ -617,7 +622,7 @@ exit: g_source_remove (signal_watch_id); #endif - g_print ("\n=======> Test %s (Return value: %i)\n\n", + gst_validate_printf (NULL, "\n=======> Test %s (Return value: %i)\n\n", ret == 0 ? "PASSED" : "FAILED", ret); gst_validate_deinit ();