From: Tim-Philipp Müller Date: Sat, 24 May 2008 16:38:15 +0000 (+0000) Subject: tests/check/: Add some unit tests for the new gst_parse_launch*_full() API. (Exposes... X-Git-Tag: RELEASE-0_10_20~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7230d272a499ae029aed2ba2700823a08b38a80;p=platform%2Fupstream%2Fgstreamer.git 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). --- diff --git a/ChangeLog b/ChangeLog index a641f64..ab9d173 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2008-05-24 Tim-Philipp Müller + * 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 + * docs/gst/gstreamer-sections.txt: * gst/gst.c: (init_post): * gst/gst_private.h: (_GstParseContext): diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index 2a08bf7..878ceb3 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -167,7 +167,8 @@ libs_typefindhelper_LDADD = \ # these just need valgrind fixing, period VALGRIND_TO_FIX = \ gst/gstinfo \ - libs/collectpads + libs/collectpads \ + pipelines/parse-launch VALGRIND_IGNORE = \ pipelines/stress diff --git a/tests/check/pipelines/parse-launch.c b/tests/check/pipelines/parse-launch.c index ecad58d..15c49c8 100644 --- a/tests/check/pipelines/parse-launch.c +++ b/tests/check/pipelines/parse-launch.c @@ -1,7 +1,6 @@ -/* GStreamer +/* GStreamer gst_parse_launch unit tests * Copyright (C) <2005> Thomas Vander Stichele - * - * cleanup.c: Unit test for cleanup of pipelines + * Copyright (C) <2008> Tim-Philipp Müller * * This library is free software; you can redistribute it and/or * 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); } +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 * parse_suite (void) { @@ -551,6 +609,8 @@ parse_suite (void) tcase_add_test (tc_chain, expected_to_fail_pipes); tcase_add_test (tc_chain, leaking_fail_pipes); tcase_add_test (tc_chain, delayed_link); + tcase_add_test (tc_chain, test_flags); + tcase_add_test (tc_chain, test_missing_elements); return s; }