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 = falSe 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 /* aggregator is borked
85 #define PIPELINE8 "fakesrc num-buffers=4 ! tee name=tee1 .src0,src1 ! .sink0, sink1 aggregator ! fakesink"
87 #define PIPELINE8 "fakesrc num-buffers=4 ! fakesink"
88 #define PIPELINE9 "fakesrc num-buffers=4 ! test. fakesink name=test"
89 #define PIPELINE10 "( fakesrc num-buffers=\"4\" ! ) identity ! fakesink"
90 #define PIPELINE11 "fakesink name = sink identity name=id ( fakesrc num-buffers=\"4\" ! id. ) id. ! sink."
94 main (gint argc, gchar * argv[])
96 gst_init (&argc, &argv);
100 * - specifying an element works :)
101 * - if only 1 element is requested, no bin is returned, but the element
103 TEST_START (PIPELINE1);
104 TEST_CHECK_FAIL (G_OBJECT_TYPE (cur) == g_type_from_name ("GstFakeSrc"));
110 * - string, int, boolean and enums can be properly set (note: eos should be false)
111 * - first test of escaping strings
113 TEST_START (PIPELINE2);
114 g_object_get (G_OBJECT (cur), "name", &s, "num-buffers", &i, "silent", &b,
116 TEST_CHECK_FAIL (strcmp (s, "donald") == 0);
117 TEST_CHECK_FAIL (i == 27);
118 TEST_CHECK_FAIL (b == TRUE);
119 g_object_get (G_OBJECT (cur), "eos", &b, "sizetype", &i, NULL);
120 TEST_CHECK_FAIL (i == 3);
121 TEST_CHECK_FAIL (b == FALSE);
122 g_object_get (G_OBJECT (cur), "data", &i, NULL);
123 TEST_CHECK_FAIL (i == 2);
128 * - specifying multiple elements without links works
129 * - if multiple toplevel elements exist, a pipeline is returned
131 TEST_START (PIPELINE3);
132 TEST_CHECK_FAIL (GST_BIN (cur)->numchildren == 3); /* a bit hacky here */
133 TEST_CHECK_FAIL (GST_IS_PIPELINE (cur));
138 * - test default link "!"
139 * - test if specifying pads on links works
141 TEST_START (PIPELINE4);
147 * - test if appending the links works, too
148 * - check if the pipeline constructed works the same as the one before (how?)
150 TEST_START (PIPELINE5);
156 * - test various types of bins
157 * - test if linking across bins works
158 * - test if escaping strings works
160 TEST_START (PIPELINE6);
161 TEST_CHECK_FAIL (GST_IS_PIPELINE (cur));
162 g_object_get (G_OBJECT (cur), "name", &s, NULL);
163 TEST_CHECK_FAIL (strcmp (s, "john") == 0);
169 * - test request pads
171 TEST_START (PIPELINE7);
177 * - multiple pads on 1 link
179 TEST_START (PIPELINE8);
185 * - failed in grammar.y cvs version 1.17
187 TEST_START (PIPELINE9);
193 * - failed in grammar.y cvs version 1.17
195 TEST_START (PIPELINE10);
201 * - failed in grammar.y cvs version 1.18
203 TEST_START (PIPELINE11);