2 * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
4 * parse1.c: Test various parsing stuff
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 /* variables used by the TEST_* macros */
28 static guint iterations;
29 static GstElement *cur = NULL;
30 static GError *error = NULL;
32 /* variables needed for checking */
37 #define TEST_CHECK_FAIL(condition) G_STMT_START{ \
39 g_print ("TEST %2d line %3d OK\n", test, __LINE__); \
41 g_print ("TEST %2d line %3d FAILED : %s\n", test, __LINE__, \
47 #define TEST_START(pipeline) G_STMT_START{ \
48 g_print ("TEST %2d line %3d START : %s\n", ++test, __LINE__, \
50 cur = gst_parse_launch (pipeline, &error); \
51 if (error == NULL) { \
52 g_print ("TEST %2d line %3d CREATED\n", test, __LINE__); \
54 g_print ("TEST %2d line %3d FAILED : %s\n", test, __LINE__, \
56 g_error_free (error); \
61 #define TEST_OK G_STMT_START{ \
62 gst_object_unref (GST_OBJECT (cur)); \
64 g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \
67 #define TEST_RUN G_STMT_START{ \
69 g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \
70 if (gst_element_set_state (cur, GST_STATE_PLAYING) \
71 == GST_STATE_FAILURE) { \
72 g_print ("TEST %2d line %3d FAILED : " \
73 "pipeline could not be set to PLAYING\n", test, __LINE__); \
77 while (gst_bin_iterate (GST_BIN (cur))) iterations++; \
78 if (gst_element_set_state (cur, GST_STATE_NULL) \
79 == GST_STATE_FAILURE) { \
80 g_print ("TEST %2d line %3d FAILED : " \
81 "pipeline could not be reset to state NULL\n", test, __LINE__); \
84 g_print ("TEST %2d line %3d STOPPED : %u iterations\n", \
85 test, __LINE__, iterations); \
89 #define PIPELINE1 "fakesrc"
90 #define PIPELINE2 "fakesrc name=donald num-buffers= 27 silent =TruE sizetype = 3 eos = falSe data= Subbuffer\\ data"
91 #define PIPELINE3 "fakesrc identity fakesink"
92 #define PIPELINE4 "fakesrc num-buffers=4 .src ! identity !.sink identity .src ! .sink fakesink"
93 #define PIPELINE5 "fakesrc num-buffers=4 name=src identity name=id1 identity name = id2 fakesink name =sink src. ! id1. id1.! id2.sink id2.src!sink.sink"
94 #define PIPELINE6 "pipeline.(name=\"john\" fakesrc num-buffers=4 ( thread. ( ! queue ! identity !{ queue ! fakesink }) ))"
95 #define PIPELINE7 "fakesrc num-buffers=4 ! tee name=tee .src%d! fakesink tee.src%d ! fakesink fakesink name =\"foo\" tee.src%d ! foo."
96 /* aggregator is borked
97 #define PIPELINE8 "fakesrc num-buffers=4 ! tee name=tee1 .src0,src1 ! .sink0, sink1 aggregator ! fakesink"
99 #define PIPELINE8 "fakesrc num-buffers=4 ! fakesink"
100 #define PIPELINE9 "fakesrc num-buffers=4 ! test. fakesink name=test"
101 #define PIPELINE10 "( fakesrc num-buffers=\"4\" ! ) identity ! fakesink"
102 #define PIPELINE11 "fakesink name = sink identity name=id ( fakesrc num-buffers=\"4\" ! id. ) id. ! sink."
103 #define PIPELINE12 "fakesrc num-buffers=4 name=a:b a:b. ! fakesink"
106 main (gint argc, gchar * argv[])
108 gst_init (&argc, &argv);
112 * - specifying an element works :)
113 * - if only 1 element is requested, no bin is returned, but the element
115 TEST_START (PIPELINE1);
116 TEST_CHECK_FAIL (G_OBJECT_TYPE (cur) == g_type_from_name ("GstFakeSrc"));
122 * - string, int, boolean and enums can be properly set
123 * (note: eos should be false)
124 * - first test of escaping strings
126 TEST_START (PIPELINE2);
127 g_object_get (G_OBJECT (cur), "name", &s, "num-buffers", &i, "silent", &b,
129 TEST_CHECK_FAIL (strcmp (s, "donald") == 0);
130 TEST_CHECK_FAIL (i == 27);
131 TEST_CHECK_FAIL (b == TRUE);
132 g_object_get (G_OBJECT (cur), "eos", &b, "sizetype", &i, NULL);
133 TEST_CHECK_FAIL (i == 3);
134 TEST_CHECK_FAIL (b == FALSE);
135 g_object_get (G_OBJECT (cur), "data", &i, NULL);
136 TEST_CHECK_FAIL (i == 2);
141 * - specifying multiple elements without links works
142 * - if multiple toplevel elements exist, a pipeline is returned
144 TEST_START (PIPELINE3);
145 TEST_CHECK_FAIL (GST_BIN (cur)->numchildren == 3); /* a bit hacky here */
146 TEST_CHECK_FAIL (GST_IS_PIPELINE (cur));
151 * - test default link "!"
152 * - test if specifying pads on links works
154 TEST_START (PIPELINE4);
160 * - test if appending the links works, too
161 * - check if the pipeline constructed works the same as the one before (how?)
163 TEST_START (PIPELINE5);
169 * - test various types of bins
170 * - test if linking across bins works
171 * - test if escaping strings works
173 TEST_START (PIPELINE6);
174 TEST_CHECK_FAIL (GST_IS_PIPELINE (cur));
175 g_object_get (G_OBJECT (cur), "name", &s, NULL);
176 TEST_CHECK_FAIL (strcmp (s, "john") == 0);
182 * - test request pads
184 TEST_START (PIPELINE7);
190 * - multiple pads on 1 link
192 TEST_START (PIPELINE8);
198 * - failed in grammar.y cvs version 1.17
200 TEST_START (PIPELINE9);
206 * - failed in grammar.y cvs version 1.17
208 TEST_START (PIPELINE10);
214 * - failed in grammar.y cvs version 1.18
216 TEST_START (PIPELINE11);
222 * - fails because a:b. is not a valid element reference in parse.l cvs rev 1.29
224 TEST_START (PIPELINE12);