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__, #condition); \
45 #define TEST_START(pipeline) G_STMT_START{ \
46 g_print ("TEST %2d line %3d START : %s\n", ++test, __LINE__, pipeline); \
47 cur = gst_parse_launch (pipeline, &error); \
48 if (error == NULL) { \
49 g_print ("TEST %2d line %3d CREATED\n", test, __LINE__); \
51 g_print ("TEST %2d line %3d FAILED : %s\n", test, __LINE__, error->message); \
52 g_error_free (error); \
56 #define TEST_OK G_STMT_START{ \
57 gst_object_unref (GST_OBJECT (cur)); \
59 g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \
61 #define TEST_RUN G_STMT_START{ \
63 g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \
64 if (gst_element_set_state (cur, GST_STATE_PLAYING) == GST_STATE_FAILURE) { \
65 g_print ("TEST %2d line %3d FAILED : pipeline could not be set to state PLAYING\n", test, __LINE__); \
69 while (gst_bin_iterate (GST_BIN (cur))) iterations++; \
70 if (gst_element_set_state (cur, GST_STATE_NULL) == GST_STATE_FAILURE) { \
71 g_print ("TEST %2d line %3d FAILED : pipeline could not be reset to state NULL\n", test, __LINE__); \
74 g_print ("TEST %2d line %3d STOPPED : %u iterations\n", test, __LINE__, iterations); \
77 #define PIPELINE1 "fakesrc"
78 #define PIPELINE2 "fakesrc name=donald num-buffers= 27 silent =TruE sizetype = 3 eos = yesyo data= Subbuffer\\ data"
79 #define PIPELINE3 "fakesrc identity fakesink"
80 #define PIPELINE4 "fakesrc num-buffers=4 .src ! identity !.sink identity .src ! .sink fakesink"
81 #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"
82 #define PIPELINE6 "pipeline.(name=\"john\" fakesrc num-buffers=4 ( thread. ( ! queue ! identity !{ queue ! fakesink }) ))"
83 #define PIPELINE7 "fakesrc num-buffers=4 ! tee name=tee .src%d! fakesink tee.src%d ! fakesink fakesink name =\"foo\" tee.src%d ! foo."
84 #define PIPELINE8 "fakesrc num-buffers=4 ! tee name=tee1 .src0,src1 ! .sink0, sink1 aggregator ! fakesink"
85 #define PIPELINE9 "fakesrc num-buffers=4 ! test. fakesink name=test"
86 #define PIPELINE10 "( fakesrc num-buffers=\"4\" ! ) identity ! fakesink"
87 #define PIPELINE11 "fakesink name = sink identity name=id ( fakesrc num-buffers=\"4\" ! id. ) id. ! sink."
91 main (gint argc, gchar * argv[])
93 gst_init (&argc, &argv);
97 * - specifying an element works :)
98 * - if only 1 element is requested, no bin is returned, but the element
100 TEST_START (PIPELINE1);
101 TEST_CHECK_FAIL (G_OBJECT_TYPE (cur) == g_type_from_name ("GstFakeSrc"));
107 * - string, int, boolean and enums can be properly set (note: eos should be false)
108 * - first test of escaping strings
110 TEST_START (PIPELINE2);
111 g_object_get (G_OBJECT (cur), "name", &s, "num-buffers", &i, "silent", &b,
113 TEST_CHECK_FAIL (strcmp (s, "donald") == 0);
114 TEST_CHECK_FAIL (i == 27);
115 TEST_CHECK_FAIL (b == TRUE);
116 g_object_get (G_OBJECT (cur), "eos", &b, "sizetype", &i, NULL);
117 TEST_CHECK_FAIL (i == 3);
118 TEST_CHECK_FAIL (b == FALSE);
119 g_object_get (G_OBJECT (cur), "data", &i, NULL);
120 TEST_CHECK_FAIL (i == 2);
125 * - specifying multiple elements without links works
126 * - if multiple toplevel elements exist, a pipeline is returned
128 TEST_START (PIPELINE3);
129 TEST_CHECK_FAIL (GST_BIN (cur)->numchildren == 3); /* a bit hacky here */
130 TEST_CHECK_FAIL (GST_IS_PIPELINE (cur));
135 * - test default link "!"
136 * - test if specifying pads on links works
138 TEST_START (PIPELINE4);
144 * - test if appending the links works, too
145 * - check if the pipeline constructed works the same as the one before
148 TEST_START (PIPELINE5);
150 TEST_CHECK_FAIL (i == iterations);
155 * - test various types of bins
156 * - test if linking across bins works
157 * - test if escaping strings works
159 TEST_START (PIPELINE6);
160 TEST_CHECK_FAIL (GST_IS_PIPELINE (cur));
161 g_object_get (G_OBJECT (cur), "name", &s, NULL);
162 TEST_CHECK_FAIL (strcmp (s, "john") == 0);
168 * - test request pads
170 TEST_START (PIPELINE7);
176 * - multiple pads on 1 link
178 TEST_START (PIPELINE8);
184 * - failed in grammar.y cvs version 1.17
186 TEST_START (PIPELINE9);
192 * - failed in grammar.y cvs version 1.17
194 TEST_START (PIPELINE10);
200 * - failed in grammar.y cvs version 1.18
202 TEST_START (PIPELINE11);