validate-flow: Add an ignored-event-fields configuration

It replaces `record-stream-id` as it is a more generic way of doing
the same thing.
This commit is contained in:
Thibault Saunier 2019-03-10 17:03:09 -03:00
parent 8f75606bf7
commit b61cb56e20
4 changed files with 42 additions and 16 deletions

View file

@ -84,7 +84,7 @@ In order to use the plugin a validate configuration file must be provided, conta
* `pad`: Required. Name of the pad that will be monitored.
* `record-buffers`: Default: false. Whether buffers will be logged. By default only events are logged.
* `record-stream-id`: Default: false. `stream-id`'s are often non reproducible (this is the case for basesrc, for instance). For this reason, they are omitted by default when recording a `stream-start` event. This setting allows to override that behavior.
* `ignored-event-fields`: Default: `stream-start=stream-id` (as they are often non reproducible). Key with a list of coma (`,`) separated list of fields to not record.
* `expectations-dir`: Path to the directory where the expectations will be written if they don't exist, relative to the current working directory. By default the current working directory is used, but this setting is usually set automatically as part of the `%(validateflow)s` expansion to a correct path like `~/gst-validate/gst-integration-testsuites/flow-expectations/<test name>`.
* `actual-results-dir`: Path to the directory where the events will be recorded. The expectation file will be compared to this. By default the current working directory is used, but this setting is usually set automatically as part of the `%(validateflow)s` expansion to the test log directory, i.e. `~/gst-validate/logs/validate/launch_pipeline/<test name>`.

View file

@ -239,12 +239,13 @@ validate_flow_format_buffer (GstBuffer * buffer)
}
gchar *
validate_flow_format_event (GstEvent * event, gboolean allow_stream_id,
const gchar * const *caps_properties)
validate_flow_format_event (GstEvent * event,
const gchar * const *caps_properties, GstStructure * ignored_event_fields)
{
const gchar *event_type;
gchar *structure_string;
gchar *event_string;
const gchar *ignored_fields;
event_type = gst_event_type_get_name (GST_EVENT_TYPE (event));
@ -262,8 +263,16 @@ validate_flow_format_event (GstEvent * event, gboolean allow_stream_id,
GstStructure *printable =
gst_structure_copy (gst_event_get_structure (event));
if (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_START && !allow_stream_id)
gst_structure_remove_fields (printable, "stream-id", NULL);
ignored_fields =
gst_structure_get_string (ignored_event_fields, event_type);
if (ignored_fields) {
gint i = 0;
gchar *field, **fields = g_strsplit (ignored_fields, ",", -1);
for (field = fields[i]; field; field = fields[++i])
gst_structure_remove_field (printable, field);
g_strfreev (fields);
}
structure_string = gst_structure_to_string (printable);
gst_structure_free (printable);

View file

@ -33,6 +33,6 @@ gchar* validate_flow_format_caps (const GstCaps* caps, const gchar * const *keys
gchar* validate_flow_format_buffer (GstBuffer *buffer);
gchar* validate_flow_format_event (GstEvent *event, gboolean allow_stream_id, const gchar * const *caps_properties);
gchar* validate_flow_format_event (GstEvent *event, const gchar * const *caps_properties, GstStructure *ignored_event_fields);
#endif // __GST_VALIDATE_FLOW_FORMATTING_H__

View file

@ -55,7 +55,7 @@ typedef struct _ValidateFlowOverride
gchar *actual_results_dir;
gboolean error_writing_file;
gchar **caps_properties;
gboolean record_stream_id;
GstStructure *ignored_event_fields;
gchar *expectations_file_path;
gchar *actual_results_file_path;
@ -136,8 +136,9 @@ validate_flow_override_event_handler (GstValidateOverride * override,
if (flow->error_writing_file)
return;
event_string = validate_flow_format_event (event, flow->record_stream_id,
(const gchar * const *) flow->caps_properties);
event_string = validate_flow_format_event (event,
(const gchar * const *) flow->caps_properties,
flow->ignored_event_fields);
validate_flow_override_printf (flow, "event %s\n", event_string);
g_free (event_string);
}
@ -188,6 +189,7 @@ validate_flow_override_new (GstStructure * config)
{
ValidateFlowOverride *flow;
GstValidateOverride *override;
gchar *ignored_event_fields;
flow = g_object_new (VALIDATE_TYPE_FLOW_OVERRIDE, NULL);
override = GST_VALIDATE_OVERRIDE (flow);
@ -208,13 +210,26 @@ validate_flow_override_new (GstStructure * config)
* only the listed properties will be written to the expectation log. */
flow->caps_properties = parse_caps_properties_setting (flow, config);
/* record-stream-id: stream-id's are often non reproducible (this is the case
* for basesrc, for instance). For this reason, they are omitted by default
* when recording a stream-start event. This setting allows to override that
* behavior. */
flow->record_stream_id = FALSE;
gst_structure_get_boolean (config, "record-stream-id",
&flow->record_stream_id);
ignored_event_fields =
(gchar *) gst_structure_get_string (config, "ignored-event-fields");
if (ignored_event_fields) {
ignored_event_fields = g_strdup_printf ("ignored,%s", ignored_event_fields);
flow->ignored_event_fields =
gst_structure_new_from_string (ignored_event_fields);
if (!flow->ignored_event_fields)
g_error ("Could not parse 'ignored-event-fields' %s in %s",
ignored_event_fields, gst_structure_to_string (config));
g_free (ignored_event_fields);
} else {
flow->ignored_event_fields =
gst_structure_new_from_string ("ignored,stream-start=stream-id");
}
if (!gst_structure_has_field (flow->ignored_event_fields, "stream-start"))
gst_structure_set (flow->ignored_event_fields, "stream-start",
G_TYPE_STRING, "stream-id", NULL);
/* expectations-dir: Path to the directory where the expectations will be
* written if they don't exist, relative to the current working directory.
@ -421,6 +436,8 @@ validate_flow_override_finalize (GObject * object)
g_free (*str_pointer);
g_free (flow->caps_properties);
}
if (flow->ignored_event_fields)
gst_structure_free (flow->ignored_event_fields);
G_OBJECT_CLASS (validate_flow_override_parent_class)->finalize (object);
}