validate:tests: Fix race in validate_padmonitor.buffer_before_segment

We were using a fakesrc which data flow was potentially breaking the
test. Stop using it and remove dead code.

Fixes #34
This commit is contained in:
Thibault Saunier 2019-01-03 12:09:09 +01:00 committed by Thibault Saunier
parent b1f22e7130
commit 26ddc02cef
2 changed files with 9 additions and 14 deletions

View file

@ -241,17 +241,13 @@ gst_validate_monitor_do_setup (GstValidateMonitor * monitor)
static GstValidateReportingDetails static GstValidateReportingDetails
_get_report_level_for_pad (GstValidateRunner * runner, GstObject * pad) _get_report_level_for_pad (GstValidateRunner * runner, GstObject * pad)
{ {
GstObject *parent;
gchar *name; gchar *name;
GstValidateReportingDetails level = GST_VALIDATE_SHOW_UNKNOWN; GstValidateReportingDetails level = GST_VALIDATE_SHOW_UNKNOWN;
parent = gst_object_get_parent (pad);
name = g_strdup_printf ("%s__%s", GST_DEBUG_PAD_NAME (pad)); name = g_strdup_printf ("%s__%s", GST_DEBUG_PAD_NAME (pad));
level = gst_validate_runner_get_reporting_level_for_name (runner, name); level = gst_validate_runner_get_reporting_level_for_name (runner, name);
g_free (name); g_free (name);
gst_object_unref (parent);
return level; return level;
} }

View file

@ -94,26 +94,27 @@ gst_discount_buffer_new (void)
GST_START_TEST (buffer_before_segment) GST_START_TEST (buffer_before_segment)
{ {
GstPad *srcpad; GstPad *srcpad, *sinkpad;
GstElement *src, *sink; GstElement *sink;
GstValidateRunner *runner; GstValidateRunner *runner;
GstValidateReport *report; GstValidateReport *report;
GstValidateMonitor *monitor; GstValidateMonitor *monitor;
GList *reports; GList *reports;
/* getting an existing element class is cheating, but easier */ /* getting an existing element class is cheating, but easier */
src = gst_element_factory_make ("fakesrc", "fakesrc");
sink = gst_element_factory_make ("fakesink", "fakesink"); sink = gst_element_factory_make ("fakesink", "fakesink");
fail_unless (gst_element_link (src, sink)); srcpad = gst_pad_new ("src", GST_PAD_SRC);
sinkpad = gst_element_get_static_pad (sink, "sink");
fail_unless (gst_pad_link (srcpad, sinkpad) == GST_PAD_LINK_OK);
gst_clear_object (&sinkpad);
fail_unless (g_setenv ("GST_VALIDATE_REPORTING_DETAILS", "all", TRUE)); fail_unless (g_setenv ("GST_VALIDATE_REPORTING_DETAILS", "all", TRUE));
runner = gst_validate_runner_new (); runner = gst_validate_runner_new ();
monitor = monitor =
gst_validate_monitor_factory_create (GST_OBJECT (src), runner, NULL); gst_validate_monitor_factory_create (GST_OBJECT (srcpad), runner, NULL);
fail_unless (GST_IS_VALIDATE_ELEMENT_MONITOR (monitor)); fail_unless (GST_IS_VALIDATE_PAD_MONITOR (monitor));
srcpad = gst_element_get_static_pad (src, "src");
/* We want to handle the src behaviour ourself */ /* We want to handle the src behaviour ourself */
fail_unless (gst_pad_activate_mode (srcpad, GST_PAD_MODE_PUSH, TRUE)); fail_unless (gst_pad_activate_mode (srcpad, GST_PAD_MODE_PUSH, TRUE));
@ -137,7 +138,7 @@ GST_START_TEST (buffer_before_segment)
/* Setup all needed event and push a new buffer (WORKS) */ /* Setup all needed event and push a new buffer (WORKS) */
{ {
_gst_check_expecting_log = FALSE; _gst_check_expecting_log = FALSE;
gst_check_setup_events (srcpad, src, NULL, GST_FORMAT_TIME); gst_check_setup_events (srcpad, sink, NULL, GST_FORMAT_TIME);
fail_unless_equals_int (gst_pad_push (srcpad, gst_discount_buffer_new ()), fail_unless_equals_int (gst_pad_push (srcpad, gst_discount_buffer_new ()),
GST_FLOW_OK); GST_FLOW_OK);
reports = gst_validate_runner_get_reports (runner); reports = gst_validate_runner_get_reports (runner);
@ -152,10 +153,8 @@ GST_START_TEST (buffer_before_segment)
_check_reports_refcount (srcpad, 2); _check_reports_refcount (srcpad, 2);
gst_object_unref (srcpad); gst_object_unref (srcpad);
gst_check_objects_destroyed_on_unref (src, srcpad, NULL);
gst_check_object_destroyed_on_unref (sink); gst_check_object_destroyed_on_unref (sink);
ASSERT_OBJECT_REFCOUNT (runner, "runner", 2); ASSERT_OBJECT_REFCOUNT (runner, "runner", 2);
gst_object_unref (monitor);
gst_object_unref (runner); gst_object_unref (runner);
} }