mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
validate:scenario: Enhance failures messages
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-devtools/-/merge_requests/182>
This commit is contained in:
parent
9840417a87
commit
47f59ad731
2 changed files with 49 additions and 18 deletions
|
@ -46,6 +46,7 @@
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include <gst/check/gsttestclock.h>
|
#include <gst/check/gsttestclock.h>
|
||||||
#include "gst-validate-internal.h"
|
#include "gst-validate-internal.h"
|
||||||
|
@ -220,6 +221,38 @@ gst_validate_g_enum_to_string (GType g_enum_type, gint value)
|
||||||
}
|
}
|
||||||
#endif
|
#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 GstValidateInterceptionReturn
|
static GstValidateInterceptionReturn
|
||||||
gst_validate_scenario_intercept_report (GstValidateReporter * reporter,
|
gst_validate_scenario_intercept_report (GstValidateReporter * reporter,
|
||||||
GstValidateReport * report)
|
GstValidateReport * report)
|
||||||
|
@ -1793,10 +1826,8 @@ _set_action_playback_time (GstValidateScenario * scenario,
|
||||||
{
|
{
|
||||||
if (!gst_validate_action_get_clocktime (scenario, action,
|
if (!gst_validate_action_get_clocktime (scenario, action,
|
||||||
"playback-time", &action->playback_time)) {
|
"playback-time", &action->playback_time)) {
|
||||||
gchar *str = gst_structure_to_string (action->structure);
|
g_error_action (action, "Could not parse playback-time in %" GST_PTR_FORMAT,
|
||||||
|
action->structure);
|
||||||
g_error ("Could not parse playback-time on structure: %s", str);
|
|
||||||
g_free (str);
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2100,7 +2131,8 @@ execute_next_action_full (GstValidateScenario * scenario, GstMessage * message)
|
||||||
priv->actions = g_list_remove_link (priv->actions, tmp);
|
priv->actions = g_list_remove_link (priv->actions, tmp);
|
||||||
|
|
||||||
if (!gst_validate_parse_next_action_playback_time (scenario)) {
|
if (!gst_validate_parse_next_action_playback_time (scenario)) {
|
||||||
g_error ("Could not determine next action playback time!");
|
g_error_action (priv->actions ? priv->actions->data : NULL,
|
||||||
|
"Could not determine next action playback time!");
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
@ -2190,7 +2222,8 @@ execute_next_action_full (GstValidateScenario * scenario, GstMessage * message)
|
||||||
priv->actions = g_list_remove_link (priv->actions, tmp);
|
priv->actions = g_list_remove_link (priv->actions, tmp);
|
||||||
|
|
||||||
if (!gst_validate_parse_next_action_playback_time (scenario)) {
|
if (!gst_validate_parse_next_action_playback_time (scenario)) {
|
||||||
g_error ("Could not determine next action playback time!");
|
g_error_action (priv->actions ? priv->actions->data : NULL,
|
||||||
|
"Could not determine next action playback time!");
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
@ -3048,9 +3081,7 @@ gst_validate_action_default_prepare_func (GstValidateAction * action)
|
||||||
repeat_expr =
|
repeat_expr =
|
||||||
g_strdup (gst_structure_get_string (action->structure, "repeat"));
|
g_strdup (gst_structure_get_string (action->structure, "repeat"));
|
||||||
if (!repeat_expr) {
|
if (!repeat_expr) {
|
||||||
g_error ("Invalid value for 'repeat' in %s",
|
g_error_action (action, "Invalid value for 'repeat'");
|
||||||
gst_structure_to_string (action->structure));
|
|
||||||
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3058,9 +3089,7 @@ gst_validate_action_default_prepare_func (GstValidateAction * action)
|
||||||
gst_validate_utils_parse_expression (repeat_expr, _set_variable_func,
|
gst_validate_utils_parse_expression (repeat_expr, _set_variable_func,
|
||||||
scenario, &error);
|
scenario, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
g_error ("Invalid value for 'repeat' in %s: %s",
|
g_error_action (action, "Invalid value for 'repeat'");
|
||||||
gst_structure_to_string (action->structure), error);
|
|
||||||
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
g_free (repeat_expr);
|
g_free (repeat_expr);
|
||||||
|
@ -3515,7 +3544,7 @@ gst_validate_scenario_load_structures (GstValidateScenario * scenario,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_ERROR_OBJECT (scenario, "We do not handle action types %s", type);
|
g_error_action (structure, "We do not handle action types %s", type);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3529,7 +3558,7 @@ gst_validate_scenario_load_structures (GstValidateScenario * scenario,
|
||||||
if (action_type->parameters[i].mandatory &&
|
if (action_type->parameters[i].mandatory &&
|
||||||
gst_structure_has_field (structure,
|
gst_structure_has_field (structure,
|
||||||
action_type->parameters[i].name) == FALSE) {
|
action_type->parameters[i].name) == FALSE) {
|
||||||
GST_ERROR_OBJECT (scenario,
|
g_error_action (structure,
|
||||||
"Mandatory field '%s' not present in structure: %" GST_PTR_FORMAT,
|
"Mandatory field '%s' not present in structure: %" GST_PTR_FORMAT,
|
||||||
action_type->parameters[i].name, structure);
|
action_type->parameters[i].name, structure);
|
||||||
goto failed;
|
goto failed;
|
||||||
|
@ -5222,7 +5251,8 @@ init_scenarios (void)
|
||||||
GstValidateActionType *atype = _find_action_type (action_typename);
|
GstValidateActionType *atype = _find_action_type (action_typename);
|
||||||
|
|
||||||
if (!atype) {
|
if (!atype) {
|
||||||
g_error ("[CONFIG ERROR] Action type %s not found", action_typename);
|
g_error_action (plug_conf, "[CONFIG ERROR] Action type %s not found",
|
||||||
|
action_typename);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -5236,7 +5266,8 @@ init_scenarios (void)
|
||||||
|
|
||||||
if (!(atype->flags & GST_VALIDATE_ACTION_TYPE_CONFIG) &&
|
if (!(atype->flags & GST_VALIDATE_ACTION_TYPE_CONFIG) &&
|
||||||
!(_action_type_has_parameter (atype, "as-config"))) {
|
!(_action_type_has_parameter (atype, "as-config"))) {
|
||||||
g_error ("[CONFIG ERROR] Action '%s' is not a config action",
|
g_error_action (plug_conf,
|
||||||
|
"[CONFIG ERROR] Action '%s' is not a config action",
|
||||||
action_typename);
|
action_typename);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -89,8 +89,8 @@ typedef GstValidateExecuteActionReturn (*GstValidatePrepareAction) (GstValidateA
|
||||||
|
|
||||||
typedef struct _GstValidateActionPrivate GstValidateActionPrivate;
|
typedef struct _GstValidateActionPrivate GstValidateActionPrivate;
|
||||||
|
|
||||||
#define GST_VALIDATE_ACTION_LINENO(action) (action->ABI.abi.lineno)
|
#define GST_VALIDATE_ACTION_LINENO(action) (((GstValidateAction*) action)->ABI.abi.lineno)
|
||||||
#define GST_VALIDATE_ACTION_FILENAME(action) (action->ABI.abi.filename)
|
#define GST_VALIDATE_ACTION_FILENAME(action) (((GstValidateAction*) action)->ABI.abi.filename)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstValidateAction:
|
* GstValidateAction:
|
||||||
|
|
Loading…
Reference in a new issue