mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
validateflow: Fail when a pad is not attached
Previously validateflow tests did not fail when the pad was not attached. This was a limitation caused by how the Validate API worked. Before, the `notify::validate-runner` signal was not emitted until a monitor was attached to the override. This made impossible to listen for the runner's `stopping` signal. This patch fixes the problem by setting `validate-runner` for all existing overrides when the runner is initialized and adding checks in validateflow to error in the case no pad was attached.
This commit is contained in:
parent
773f2e456c
commit
e536b05e5a
4 changed files with 78 additions and 0 deletions
|
@ -461,6 +461,37 @@ GList *gst_validate_override_registry_get_override_for_names
|
|||
return ret;
|
||||
}
|
||||
|
||||
GList *
|
||||
gst_validate_override_registry_get_override_list (GstValidateOverrideRegistry *
|
||||
registry)
|
||||
{
|
||||
GList *all_overrides = NULL;
|
||||
GList *i;
|
||||
|
||||
GST_VALIDATE_OVERRIDE_REGISTRY_LOCK (registry);
|
||||
for (i = registry->name_overrides.head; i; i = i->next) {
|
||||
GstValidateOverrideRegistryNameEntry *entry =
|
||||
(GstValidateOverrideRegistryNameEntry *) i->data;
|
||||
if (!g_list_find (all_overrides, entry->override))
|
||||
all_overrides = g_list_append (all_overrides, entry->override);
|
||||
}
|
||||
for (i = registry->klass_overrides.head; i; i = i->next) {
|
||||
GstValidateOverrideRegistryNameEntry *entry =
|
||||
(GstValidateOverrideRegistryNameEntry *) i->data;
|
||||
if (!g_list_find (all_overrides, entry->override))
|
||||
all_overrides = g_list_append (all_overrides, entry->override);
|
||||
}
|
||||
for (i = registry->name_overrides.head; i; i = i->next) {
|
||||
GstValidateOverrideRegistryGTypeEntry *entry =
|
||||
(GstValidateOverrideRegistryGTypeEntry *) i->data;
|
||||
if (!g_list_find (all_overrides, entry->override))
|
||||
all_overrides = g_list_append (all_overrides, entry->override);
|
||||
}
|
||||
GST_VALIDATE_OVERRIDE_REGISTRY_UNLOCK (registry);
|
||||
|
||||
return all_overrides;
|
||||
}
|
||||
|
||||
void
|
||||
_priv_validate_override_registry_deinit (void)
|
||||
{
|
||||
|
|
|
@ -45,6 +45,8 @@ GstValidateOverrideRegistry * gst_validate_override_registry_get (void);
|
|||
GST_VALIDATE_API GList *
|
||||
gst_validate_override_registry_get_override_for_names (GstValidateOverrideRegistry *reg,
|
||||
const gchar *name, ...);
|
||||
GST_VALIDATE_API GList *
|
||||
gst_validate_override_registry_get_override_list (GstValidateOverrideRegistry *reg);
|
||||
GST_VALIDATE_API
|
||||
void gst_validate_override_register_by_name (const gchar * name, GstValidateOverride * override);
|
||||
GST_VALIDATE_API
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "gst-validate-monitor-factory.h"
|
||||
#include "gst-validate-override-registry.h"
|
||||
#include "gst-validate-runner.h"
|
||||
#include "gst-validate-reporter.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gst_validate_runner_debug);
|
||||
#undef GST_CAT_DEFAULT
|
||||
|
@ -473,6 +474,20 @@ gst_validate_runner_new (void)
|
|||
runner->priv->user_created = TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
GstValidateOverrideRegistry *registry =
|
||||
gst_validate_override_registry_get ();
|
||||
GList *all_overrides =
|
||||
gst_validate_override_registry_get_override_list (registry);
|
||||
GList *i;
|
||||
for (i = all_overrides; i; i = i->next) {
|
||||
GstValidateOverride *override = (GstValidateOverride *) i->data;
|
||||
gst_validate_reporter_set_runner (GST_VALIDATE_REPORTER (override),
|
||||
runner);
|
||||
}
|
||||
g_list_free (all_overrides);
|
||||
}
|
||||
|
||||
return runner;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#define VALIDATE_FLOW_MISMATCH g_quark_from_static_string ("validateflow::mismatch")
|
||||
#define VALIDATE_FLOW_NOT_ATTACHED g_quark_from_static_string ("validateflow::not-attached")
|
||||
|
||||
typedef enum _ValidateFlowMode
|
||||
{
|
||||
|
@ -60,6 +61,7 @@ typedef struct _ValidateFlowOverride
|
|||
gchar *expectations_file_path;
|
||||
gchar *actual_results_file_path;
|
||||
ValidateFlowMode mode;
|
||||
gboolean was_attached;
|
||||
|
||||
/* output_file will refer to the expectations file if it did not exist,
|
||||
* or to the actual results file otherwise. */
|
||||
|
@ -72,6 +74,7 @@ typedef struct _ValidateFlowOverride
|
|||
GList *all_overrides = NULL;
|
||||
|
||||
static void validate_flow_override_finalize (GObject * object);
|
||||
static void validate_flow_override_attached (GstValidateOverride * override);
|
||||
static void _runner_set (GObject * object, GParamSpec * pspec,
|
||||
gpointer user_data);
|
||||
static void runner_stopping (GstValidateRunner * runner,
|
||||
|
@ -92,7 +95,11 @@ void
|
|||
validate_flow_override_class_init (ValidateFlowOverrideClass * klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GstValidateOverrideClass *override_class =
|
||||
GST_VALIDATE_OVERRIDE_CLASS (klass);
|
||||
|
||||
object_class->finalize = validate_flow_override_finalize;
|
||||
override_class->attached = validate_flow_override_attached;
|
||||
|
||||
g_assert (gst_validate_is_initialized ());
|
||||
|
||||
|
@ -101,6 +108,12 @@ validate_flow_override_class_init (ValidateFlowOverrideClass * klass)
|
|||
"The recorded log does not match the expectation file.",
|
||||
"The recorded log does not match the expectation file.",
|
||||
GST_VALIDATE_REPORT_LEVEL_CRITICAL));
|
||||
|
||||
gst_validate_issue_register (gst_validate_issue_new
|
||||
(VALIDATE_FLOW_NOT_ATTACHED,
|
||||
"The pad to monitor was never attached.",
|
||||
"The pad to monitor was never attached.",
|
||||
GST_VALIDATE_REPORT_LEVEL_CRITICAL));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -284,6 +297,8 @@ validate_flow_override_new (GstStructure * config)
|
|||
if (!flow->output_file)
|
||||
g_error ("Could not open for writing: %s", flow->output_file_path);
|
||||
|
||||
flow->was_attached = FALSE;
|
||||
|
||||
gst_validate_override_register_by_name (flow->pad_name, override);
|
||||
|
||||
override->buffer_handler = validate_flow_override_buffer_handler;
|
||||
|
@ -306,6 +321,13 @@ _runner_set (GObject * object, GParamSpec * pspec, gpointer user_data)
|
|||
gst_object_unref (runner);
|
||||
}
|
||||
|
||||
static void
|
||||
validate_flow_override_attached (GstValidateOverride * override)
|
||||
{
|
||||
ValidateFlowOverride *flow = VALIDATE_FLOW_OVERRIDE (override);
|
||||
flow->was_attached = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
run_diff (const gchar * expected_file, const gchar * actual_file)
|
||||
{
|
||||
|
@ -369,6 +391,14 @@ runner_stopping (GstValidateRunner * runner, ValidateFlowOverride * flow)
|
|||
|
||||
fclose (flow->output_file);
|
||||
flow->output_file = NULL;
|
||||
|
||||
if (!flow->was_attached) {
|
||||
GST_VALIDATE_REPORT (flow, VALIDATE_FLOW_NOT_ATTACHED,
|
||||
"The test ended without the pad ever being attached: %s",
|
||||
flow->pad_name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (flow->mode == VALIDATE_FLOW_MODE_WRITING_EXPECTATIONS)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in a new issue