Commit a157c9fa authored by Seungha Yang's avatar Seungha Yang 🐑 Committed by Thibault Saunier
Browse files

tests: nle: Fix GList leak

parent a799e1be
......@@ -404,3 +404,14 @@ nle_composition_add (GstBin * comp, GstElement * object)
{
return gst_bin_add (comp, object);
}
void
collect_free (CollectStructure * collect)
{
if (collect->seen_segments)
g_list_free (collect->seen_segments);
if (collect->expected_segments)
g_list_free_full (collect->expected_segments, (GDestroyNotify) g_free);
g_free (collect);
}
......@@ -76,3 +76,5 @@ segment_new (gdouble rate, GstFormat format, gint64 start, gint64 stop, gint64 p
void commit_and_wait (GstElement *comp, gboolean *ret);
gboolean nle_composition_remove (GstBin * comp, GstElement * object);
gboolean nle_composition_add (GstBin * comp, GstElement * object);
void collect_free (CollectStructure *collect);
......@@ -88,6 +88,10 @@ fill_pipeline_and_check (GstElement * comp, GList * segments,
GST_DEBUG ("Resetted pipeline to READY");
if (collect->seen_segments)
g_list_free (collect->seen_segments);
collect->seen_segments = NULL;
collect->expected_segments = listcopy;
collect->gotsegment = FALSE;
collect->expected_base = 0;
......@@ -141,7 +145,7 @@ done:
ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
gst_object_unref (bus);
g_free (collect);
collect_free (collect);
}
GST_START_TEST (test_one_space_another)
......@@ -614,6 +618,10 @@ GST_START_TEST (test_renegotiation)
GST_DEBUG ("Resetted pipeline to READY");
if (collect->seen_segments)
g_list_free (collect->seen_segments);
collect->seen_segments = NULL;
/* Expected segments */
collect->expected_segments = g_list_append (collect->expected_segments,
segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
......@@ -672,7 +680,7 @@ GST_START_TEST (test_renegotiation)
ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
gst_object_unref (bus);
g_free (collect);
collect_free (collect);
}
GST_END_TEST;
......
......@@ -72,6 +72,10 @@ fill_pipeline_and_check (GstElement * comp, GList * segments)
GST_DEBUG ("Resetted pipeline to READY");
if (collect->seen_segments)
g_list_free (collect->seen_segments);
collect->seen_segments = NULL;
collect->expected_base = 0;
collect->expected_segments = listcopy;
collect->gotsegment = FALSE;
......@@ -121,7 +125,7 @@ fill_pipeline_and_check (GstElement * comp, GList * segments)
ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
gst_object_unref (bus);
g_free (collect);
collect_free (collect);
}
GST_START_TEST (test_simple_operation)
......
......@@ -79,6 +79,11 @@ test_simplest_full (void)
GST_ERROR ("Resetted pipeline to READY");
if (collect->seen_segments)
g_list_free (collect->seen_segments);
collect->seen_segments = NULL;
/* Expected segments */
collect->expected_segments = g_list_append (collect->expected_segments,
segment_new (1.0, GST_FORMAT_TIME, 5 * GST_SECOND, 6 * GST_SECOND, 0));
......@@ -105,7 +110,7 @@ test_simplest_full (void)
gst_check_objects_destroyed_on_unref (pipeline, comp, source1, NULL);
ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
g_free (collect);
collect_free (collect);
}
static void
......@@ -317,6 +322,11 @@ test_one_after_other_full (void)
GST_DEBUG ("Resetted pipeline to READY");
if (collect->seen_segments)
g_list_free (collect->seen_segments);
collect->seen_segments = NULL;
/* Expected segments */
collect->expected_segments = g_list_append (collect->expected_segments,
segment_new (1.0, GST_FORMAT_TIME, 5 * GST_SECOND, 6 * GST_SECOND, 0));
......@@ -373,7 +383,7 @@ test_one_after_other_full (void)
ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
gst_object_unref (bus);
g_free (collect);
collect_free (collect);
}
static void
......@@ -516,7 +526,7 @@ test_one_under_another_full (void)
ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
gst_object_unref (bus);
g_free (collect);
collect_free (collect);
}
static void
......@@ -669,6 +679,11 @@ test_one_bin_after_other_full (void)
GST_DEBUG ("Resetted pipeline to READY");
if (collect->seen_segments)
g_list_free (collect->seen_segments);
collect->seen_segments = NULL;
/* Expected segments */
collect->expected_segments = g_list_append (collect->expected_segments,
segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
......@@ -719,7 +734,7 @@ test_one_bin_after_other_full (void)
ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
gst_object_unref (bus);
g_free (collect);
collect_free (collect);
}
GST_START_TEST (test_simplest)
......
......@@ -152,7 +152,7 @@ GST_START_TEST (test_tempochange)
ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
gst_object_unref (bus);
g_free (collect);
collect_free (collect);
}
GST_END_TEST;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment