From 5b271bcd88d652eede44d69a7d8355d2af8213a4 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Thu, 27 Jul 2006 13:26:27 +0000 Subject: [PATCH] Fix some of the leaks exposed by extending the parse-launch testsuite, and move the 3 I can't figure out into a separ... Original commit message from CVS: * gst/parse/grammar.y: * gst/parse/parse.l: * tests/check/pipelines/parse-launch.c: (expected_fail_pipe), (GST_START_TEST), (parse_suite): Fix some of the leaks exposed by extending the parse-launch testsuite, and move the 3 I can't figure out into a separate test that won't run the pipelines unless the appropriate line is uncommented. --- ChangeLog | 10 ++++++++++ gst/parse/grammar.y | 20 +++++++++++++------ gst/parse/parse.l | 2 +- tests/check/pipelines/parse-launch.c | 38 ++++++++++++++++++++++++++++-------- 4 files changed, 55 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index caf1775..4cd71f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-07-27 Jan Schmidt,,, + + * gst/parse/grammar.y: + * gst/parse/parse.l: + * tests/check/pipelines/parse-launch.c: (expected_fail_pipe), + (GST_START_TEST), (parse_suite): + Fix some of the leaks exposed by extending the parse-launch testsuite, + and move the 3 I can't figure out into a separate test that won't run + the pipelines unless the appropriate line is uncommented. + 2006-07-27 Tim-Philipp Müller * plugins/elements/gstfilesrc.c: (gst_file_src_create_read): diff --git a/gst/parse/grammar.y b/gst/parse/grammar.y index 006842f..654dc7b 100644 --- a/gst/parse/grammar.y +++ b/gst/parse/grammar.y @@ -571,11 +571,12 @@ static int yyerror (const char *s); %% element: IDENTIFIER { $$ = gst_element_factory_make ($1, NULL); - if (!$$) + if ($$ == NULL) { SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, _("no element \"%s\""), $1); - gst_parse_strfree ($1); - if (!$$) + gst_parse_strfree ($1); YYERROR; + } + gst_parse_strfree ($1); } | element ASSIGNMENT { gst_parse_element_set ($2, $1, graph); $$ = $1; @@ -617,7 +618,7 @@ linkpart: reference { $$ = $1; } link: linkpart LINK linkpart { $$ = $1; if ($2) { $$->caps = gst_caps_from_string ($2); - if (!$$->caps) + if ($$->caps == NULL) SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("could not parse caps \"%s\""), $2); gst_parse_strfree ($2); } @@ -741,10 +742,15 @@ chain: element { $$ = gst_parse_chain_new (); if (!element) { SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_NO_SUCH_ELEMENT, _("no sink element for URI \"%s\""), $2); + gst_parse_link_free ($1); + g_free ($2); YYERROR; } else if ($1->sink_name || $1->sink_pads) { + gst_object_unref (element); SET_ERROR (((graph_t *) graph)->error, GST_PARSE_ERROR_LINK, _("could not link sink element for URI \"%s\""), $2); + gst_parse_link_free ($1); + g_free ($2); YYERROR; } else { $$ = gst_parse_chain_new (); @@ -856,8 +862,10 @@ _gst_parse_launch (const gchar *str, GError **error) bin = GST_BIN (gst_element_factory_make ("pipeline", NULL)); g_assert (bin); - for (walk = g.chain->elements; walk; walk = walk->next) - gst_bin_add (bin, GST_ELEMENT (walk->data)); + for (walk = g.chain->elements; walk; walk = walk->next) { + if (walk->data != NULL) + gst_bin_add (bin, GST_ELEMENT (walk->data)); + } g_slist_free (g.chain->elements); ret = GST_ELEMENT (bin); diff --git a/gst/parse/parse.l b/gst/parse/parse.l index c37b877..9d5c07a 100644 --- a/gst/parse/parse.l +++ b/gst/parse/parse.l @@ -138,7 +138,7 @@ _link ("!"[[:space:]]*{_caps}([[:space:]]*(";"[[:space:]]*{_caps})*[[:space:]]*) [[:space:]]+ { PRINT ("SPACE: [%s]", yytext); } . { - printf ("???: %s\n", yytext); + PRINT ("Invalid Lexer element: %s\n", yytext); return *yytext; } diff --git a/tests/check/pipelines/parse-launch.c b/tests/check/pipelines/parse-launch.c index 4d4f207..7ed7db4 100644 --- a/tests/check/pipelines/parse-launch.c +++ b/tests/check/pipelines/parse-launch.c @@ -23,6 +23,9 @@ # include "config.h" #endif +#include +#include + #include static GstElement * @@ -48,7 +51,7 @@ expected_fail_pipe (const gchar * pipe_descr) GError *error = NULL; #ifndef GST_DISABLE_GST_DEBUG - gst_debug_set_default_threshold (GST_LEVEL_NONE); + // gst_debug_set_default_threshold (GST_LEVEL_NONE); #endif pipeline = gst_parse_launch (pipe_descr, &error); @@ -270,8 +273,6 @@ static const gchar *expected_failures[] = { "fakesrc num-buffers=4 name=\"a=b\" a=b. ! fakesink", /* checks: Error branch for a non-deserialisable property value */ "filesrc blocksize=absdff", - /* checks: That requesting an element which doesn't exist doesn't work */ - "error-does-not-exist-src", /* checks: That broken caps which don't parse can't create a pipeline */ "fakesrc ! video/raw,format=(antwerp)monkeys ! fakesink", /* checks: Empty pipeline is invalid */ @@ -288,13 +289,8 @@ static const gchar *expected_failures[] = { "fakesrc name=src fakesink name=sink noexiste. ! sink.", /* checks: Referencing non-existent sink element by name can't link */ "fakesrc name=src fakesink name=sink src. ! noexiste.", - /* checks: Invalid pipeline syntax fails */ - "fakesrc ! identity ! sgsdfagfd @ gfdgfdsgfsgSF", /* checks: Can't link 2 elements that only have sink pads */ "fakesink ! fakesink", - /* checks: Attempting to link to a non-existent pad on an element - * created via URI handler should fail */ - "fakesrc ! .foo file:///dev/null", /* checks multi-chain link without src element fails. */ "! identity ! identity ! fakesink", /* END: */ @@ -312,6 +308,31 @@ GST_START_TEST (expected_to_fail_pipes) GST_END_TEST; +static const gchar *leaking_failures[] = { + /* checks: Invalid pipeline syntax fails */ + "fakesrc ! identity ! sgsdfagfd @ gfdgfdsgfsgSF", + /* checks: Attempting to link to a non-existent pad on an element + * created via URI handler should fail */ + "fakesrc ! .foo file:///dev/null", + /* checks: That requesting an element which doesn't exist doesn't work */ + "error-does-not-exist-src", + NULL +}; + +GST_START_TEST (leaking_fail_pipes) +{ + const gchar **s; + + for (s = leaking_failures; *s != NULL; s++) { + g_print ("Trying pipe: %s\n", *s); + /* Uncomment if you want to try fixing the leaks */ + /* expected_fail_pipe (*s); */ + VALGRIND_DO_LEAK_CHECK; + } +} + +GST_END_TEST; + /* Helper function to test delayed linking support in parse_launch by creating * a test element based on bin, which contains a fakesrc and a sometimes * pad-template, and trying to link to a fakesink. When the bin transitions @@ -526,6 +547,7 @@ parse_suite (void) tcase_add_test (tc_chain, test_launch_lines); tcase_add_test (tc_chain, test_launch_lines2); tcase_add_test (tc_chain, expected_to_fail_pipes); + tcase_add_test (tc_chain, leaking_fail_pipes); tcase_add_test (tc_chain, delayed_link); return s; } -- 2.7.4