validateflow: Add buffers-checksum option to log buffers data checksum

This commit is contained in:
Thibault Saunier 2019-06-23 11:58:11 -04:00
parent ade8ba3fcb
commit 25a7173b22
4 changed files with 27 additions and 4 deletions

View file

@ -84,6 +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.
* `buffers-checksum`: Default: false. Whether a checkum of the buffer data is logged. Implies `record-buffers`.
* `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

@ -191,11 +191,25 @@ buffer_get_meta_string (GstBuffer * buffer)
}
gchar *
validate_flow_format_buffer (GstBuffer * buffer)
validate_flow_format_buffer (GstBuffer * buffer, gboolean add_checksum)
{
gchar *flags_str, *meta_str, *buffer_str;
gchar *buffer_parts[6];
gchar *buffer_parts[7];
int buffer_parts_index = 0;
gchar *sum;
GstMapInfo map;
if (add_checksum) {
if (!gst_buffer_map (buffer, &map, GST_MAP_READ)) {
GST_ERROR ("Buffer could not be mapped.");
} else {
sum = g_compute_checksum_for_data (G_CHECKSUM_SHA1, map.data, map.size);
gst_buffer_unmap (buffer, &map);
buffer_parts[buffer_parts_index++] = g_strdup_printf ("checksum=%s", sum);
g_free (sum);
}
}
if (GST_CLOCK_TIME_IS_VALID (buffer->dts)) {
gchar time_str[32];

View file

@ -31,7 +31,7 @@ gchar* validate_flow_format_segment (const GstSegment *segment);
gchar* validate_flow_format_caps (const GstCaps* caps, const gchar * const *keys_to_print);
gchar* validate_flow_format_buffer (GstBuffer *buffer);
gchar* validate_flow_format_buffer (GstBuffer *buffer, gboolean add_checksum);
gchar* validate_flow_format_event (GstEvent *event, const gchar * const *caps_properties, GstStructure *ignored_event_fields);

View file

@ -52,6 +52,7 @@ typedef struct _ValidateFlowOverride
const gchar *pad_name;
gboolean record_buffers;
gboolean buffers_checksum;
gchar *expectations_dir;
gchar *actual_results_dir;
gboolean error_writing_file;
@ -166,7 +167,7 @@ validate_flow_override_buffer_handler (GstValidateOverride * override,
if (flow->error_writing_file || !flow->record_buffers)
return;
buffer_str = validate_flow_format_buffer (buffer);
buffer_str = validate_flow_format_buffer (buffer, flow->buffers_checksum);
validate_flow_override_printf (flow, "buffer: %s\n", buffer_str);
g_free (buffer_str);
}
@ -218,6 +219,13 @@ validate_flow_override_new (GstStructure * config)
flow->record_buffers = FALSE;
gst_structure_get_boolean (config, "record-buffers", &flow->record_buffers);
flow->buffers_checksum = FALSE;
gst_structure_get_boolean (config, "buffers-checksum",
&flow->buffers_checksum);
if (flow->buffers_checksum)
flow->record_buffers = TRUE;
/* caps-properties: Caps events can include many dfferent properties, but
* many of these may be irrelevant for some tests. If this option is set,
* only the listed properties will be written to the expectation log. */