tests/check/: Add some unit tests for the new gst_parse_launch*_full() API. (Exposes a previously-existing memory lea...

Original commit message from CVS:
* tests/check/Makefile.am:
* tests/check/pipelines/parse-launch.c:
Add some unit tests for the new gst_parse_launch*_full() API.
(Exposes a previously-existing memory leak in the error code
path, so adding to VALGRIND_TO_FIX for now).
This commit is contained in:
Tim-Philipp Müller 2008-05-24 16:38:15 +00:00
parent ebc08ddfb9
commit c7230d272a
3 changed files with 73 additions and 4 deletions

View file

@ -1,3 +1,11 @@
2008-05-24 Tim-Philipp Müller <tim.muller at collabora co uk>
* tests/check/Makefile.am:
* tests/check/pipelines/parse-launch.c:
Add some unit tests for the new gst_parse_launch*_full() API.
(Exposes a previously-existing memory leak in the error code
path, so adding to VALGRIND_TO_FIX for now).
2008-05-24 Tim-Philipp Müller <tim.muller at collabora co uk> 2008-05-24 Tim-Philipp Müller <tim.muller at collabora co uk>
* docs/gst/gstreamer-sections.txt: * docs/gst/gstreamer-sections.txt:

View file

@ -167,7 +167,8 @@ libs_typefindhelper_LDADD = \
# these just need valgrind fixing, period # these just need valgrind fixing, period
VALGRIND_TO_FIX = \ VALGRIND_TO_FIX = \
gst/gstinfo \ gst/gstinfo \
libs/collectpads libs/collectpads \
pipelines/parse-launch
VALGRIND_IGNORE = \ VALGRIND_IGNORE = \
pipelines/stress pipelines/stress

View file

@ -1,7 +1,6 @@
/* GStreamer /* GStreamer gst_parse_launch unit tests
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org> * Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
* * Copyright (C) <2008> Tim-Philipp Müller <tim centricular net>
* cleanup.c: Unit test for cleanup of pipelines
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
@ -536,6 +535,65 @@ gst_parse_test_element_change_state (GstElement * element,
return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
} }
GST_START_TEST (test_missing_elements)
{
GstParseContext *ctx;
GstElement *element;
GError *err = NULL;
gchar **arr;
/* avoid misleading 'no such element' error debug messages when using cvs */
if (!g_getenv ("GST_DEBUG"))
gst_debug_set_default_threshold (GST_LEVEL_NONE);
ctx = gst_parse_context_new ();
element = gst_parse_launch_full ("fakesrc ! coffeesink", ctx,
GST_PARSE_FLAG_FATAL_ERRORS, &err);
fail_unless (err != NULL, "expected error");
fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT);
fail_unless (element == NULL, "expected NULL return with FATAL_ERRORS");
arr = gst_parse_context_get_missing_elements (ctx);
fail_unless (arr != NULL, "expected missing elements");
fail_unless_equals_string (arr[0], "coffeesink");
fail_unless (arr[1] == NULL);
g_strfreev (arr);
gst_parse_context_free (ctx);
g_error_free (err);
err = NULL;
}
GST_END_TEST;
GST_START_TEST (test_flags)
{
GstElement *element;
GError *err = NULL;
/* avoid misleading 'no such element' error debug messages when using cvs */
if (!g_getenv ("GST_DEBUG"))
gst_debug_set_default_threshold (GST_LEVEL_NONE);
/* default behaviour is to return any already constructed bins/elements */
element = gst_parse_launch_full ("fakesrc ! coffeesink", NULL, 0, &err);
fail_unless (err != NULL, "expected error");
fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT);
fail_unless (element != NULL, "expected partial pipeline/element");
g_error_free (err);
err = NULL;
gst_object_unref (element);
/* test GST_PARSE_FLAG_FATAL_ERRORS */
element = gst_parse_launch_full ("fakesrc ! coffeesink", NULL,
GST_PARSE_FLAG_FATAL_ERRORS, &err);
fail_unless (err != NULL, "expected error");
fail_unless_equals_int (err->code, GST_PARSE_ERROR_NO_SUCH_ELEMENT);
fail_unless (element == NULL, "expected NULL return with FATAL_ERRORS");
g_error_free (err);
err = NULL;
}
GST_END_TEST;
static Suite * static Suite *
parse_suite (void) parse_suite (void)
{ {
@ -551,6 +609,8 @@ parse_suite (void)
tcase_add_test (tc_chain, expected_to_fail_pipes); tcase_add_test (tc_chain, expected_to_fail_pipes);
tcase_add_test (tc_chain, leaking_fail_pipes); tcase_add_test (tc_chain, leaking_fail_pipes);
tcase_add_test (tc_chain, delayed_link); tcase_add_test (tc_chain, delayed_link);
tcase_add_test (tc_chain, test_flags);
tcase_add_test (tc_chain, test_missing_elements);
return s; return s;
} }