added tests for parsing stuff
authorBenjamin Otte <otte@gnome.org>
Thu, 10 Apr 2003 01:51:42 +0000 (01:51 +0000)
committerBenjamin Otte <otte@gnome.org>
Thu, 10 Apr 2003 01:51:42 +0000 (01:51 +0000)
Original commit message from CVS:
added tests for parsing stuff

configure.ac
tests/old/testsuite/Makefile.am
tests/old/testsuite/parse/.gitignore [new file with mode: 0644]
tests/old/testsuite/parse/Makefile.am [new file with mode: 0644]
tests/old/testsuite/parse/parse1.c [new file with mode: 0644]
tests/old/testsuite/parse/parse2.c [new file with mode: 0644]
testsuite/Makefile.am
testsuite/parse/.gitignore [new file with mode: 0644]
testsuite/parse/Makefile.am [new file with mode: 0644]
testsuite/parse/parse1.c [new file with mode: 0644]
testsuite/parse/parse2.c [new file with mode: 0644]

index 785f920..4cfeb51 100644 (file)
@@ -522,6 +522,7 @@ testsuite/clock/Makefile
 testsuite/dynparams/Makefile
 testsuite/elements/Makefile
 testsuite/indexers/Makefile
+testsuite/parse/Makefile
 testsuite/plugin/Makefile
 testsuite/refcounting/Makefile
 testsuite/threads/Makefile
index 3b75335..3748b1d 100644 (file)
@@ -1,5 +1,11 @@
+if GST_DISABLE_PARSE
+GST_PARSE_DIRS = 
+else
+GST_PARSE_DIRS = parse
+endif
+
 # FIXME : threads bytestream
-SUBDIRS = caps plugin elements clock refcounting threads indexers ## cleanup dynparams
+SUBDIRS = caps plugin elements clock refcounting threads indexers $(GST_PARSE_DIRS) ## cleanup dynparams
 
 GST_PLUGIN_PATH = $(shell cd $(top_builddir) && pwd)
 TESTS_ENVIRONMENT = GST_PLUGIN_PATH=$(GST_PLUGIN_PATH) GST_REGISTRY=`pwd`/test-registry.xml
@@ -24,6 +30,6 @@ AM_CFLAGS = $(GST_CFLAGS)
 CLEANFILES = test-registry.xml elementstest-registry.xml
 
 DIST_SUBDIRS = bytestream caps cleanup clock dynparams elements indexers \
-               plugin refcounting threads
+               plugin refcounting threads parse
 
 EXTRA_DIST = gst-inspect-check
diff --git a/tests/old/testsuite/parse/.gitignore b/tests/old/testsuite/parse/.gitignore
new file mode 100644 (file)
index 0000000..5dbe8a3
--- /dev/null
@@ -0,0 +1,9 @@
+Makefile
+Makefile.in
+*.o
+*.lo
+*.la
+.deps
+.libs
+parse1
+parse2
diff --git a/tests/old/testsuite/parse/Makefile.am b/tests/old/testsuite/parse/Makefile.am
new file mode 100644 (file)
index 0000000..0d15c50
--- /dev/null
@@ -0,0 +1,12 @@
+testprogs = parse1 parse2
+
+TESTS = $(testprogs)
+
+check_PROGRAMS = $(testprogs)
+
+parse1_SOURCES = parse1.c
+parse2_SOURCES = parse2.c
+
+# we have nothing but apps here, we can do this safely
+LIBS = $(GST_LIBS)
+AM_CFLAGS = $(GST_CFLAGS)
diff --git a/tests/old/testsuite/parse/parse1.c b/tests/old/testsuite/parse/parse1.c
new file mode 100644 (file)
index 0000000..d7f3469
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
+ *
+ * parse1.c: Test various parsing stuff
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <gst/gst.h>
+
+#include <string.h>
+
+/* variables used by the TEST_* macros */
+static gint test = 0;
+static guint iterations;
+static GstElement *cur = NULL;
+static GError *error = NULL;
+
+/* variables needed for checking */
+static gint i;
+static gboolean b;
+static gchar *s;
+
+#define TEST_CHECK_FAIL(condition) G_STMT_START{ \
+  if (condition) { \
+    g_print ("TEST %2d line %3d    OK\n", test, __LINE__); \
+  } else { \
+    g_print ("TEST %2d line %3d  FAILED : %s\n", test, __LINE__, #condition); \
+    return -test; \
+  } \
+}G_STMT_END
+#define TEST_START(pipeline) G_STMT_START{ \
+  g_print ("TEST %2d line %3d  START   : %s\n", ++test, __LINE__, pipeline); \
+  cur = gst_parse_launch (pipeline, &error); \
+  if (error == NULL) { \
+    g_print ("TEST %2d line %3d CREATED\n", test, __LINE__); \
+  } else { \
+    g_print ("TEST %2d line %3d  FAILED  : %s\n", test, __LINE__, error->message); \
+    g_error_free (error); \
+    return -test; \
+  } \
+}G_STMT_END
+#define TEST_OK G_STMT_START{ \
+  gst_object_unref (GST_OBJECT (cur)); \
+  cur = NULL; \
+  g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \
+}G_STMT_END 
+#define TEST_RUN G_STMT_START{ \
+  g_print ("TEST %2d line %3d   RUN\n", test, __LINE__); \
+  if (gst_element_set_state (cur, GST_STATE_PLAYING) == GST_STATE_FAILURE) { \
+    g_print ("TEST %2d line %3d  FAILED  : pipeline could not be set to state PLAYING\n", test, __LINE__); \
+    return -test; \
+  } \
+  iterations = 0; \
+  while (gst_bin_iterate (GST_BIN (cur))) iterations++; \
+  if (gst_element_set_state (cur, GST_STATE_NULL) == GST_STATE_FAILURE) { \
+    g_print ("TEST %2d line %3d  FAILED  : pipeline could not be reset to state NULL\n", test, __LINE__); \
+    return -test; \
+  } \
+  g_print ("TEST %2d line %3d STOPPED  : %u iterations\n", test, __LINE__, iterations); \
+}G_STMT_END 
+#define PIPELINE1 "fakesrc"
+#define PIPELINE2 "fakesrc name=donald num-buffers= 27 silent =TruE sizetype = 3 eos  =    yesyo data=   Subbuffer\\ data"
+#define PIPELINE3 "fakesrc identity fakesink"
+#define PIPELINE4 "fakesrc num-buffers=4 .src ! identity !.sink identity .src ! .sink fakesink"
+#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"
+#define PIPELINE6 "pipeline.(name=\"john\" fakesrc num-buffers=4 ( thread. ( ! queue ! identity !{ queue ! fakesink }) ))"
+#define PIPELINE7 "fakesrc num-buffers=4 ! tee name=tee .src%d! fakesink tee.src%d ! fakesink fakesink name =\"foo\" tee.src%d ! foo."
+#define PIPELINE8 "fakesrc num-buffers=4 ! tee name=tee1 .src0,src1 ! .sink0, sink1 aggregator ! fakesink"
+
+gint 
+main (gint argc, gchar *argv[]) 
+{
+  gst_init (&argc, &argv);
+
+goto here;
+here:
+
+  /**
+   * checks:
+   * - specifying an element works :)
+   * - if only 1 element is requested, no bin is returned, but the element
+   */
+  TEST_START (PIPELINE1);
+  TEST_CHECK_FAIL (G_OBJECT_TYPE (cur) == g_type_from_name ("GstFakeSrc"));
+  TEST_OK;
+
+  /**
+   * checks:
+   * - properties works
+   * - string, int, boolean and enums can be properly set (note: eos should be false)
+   * - first test of escaping strings
+   */
+  TEST_START (PIPELINE2);
+  g_object_get (G_OBJECT (cur), "name", &s, "num-buffers", &i, "silent", &b, NULL);
+  TEST_CHECK_FAIL (strcmp (s, "donald") == 0);
+  TEST_CHECK_FAIL (i == 27);
+  TEST_CHECK_FAIL (b == TRUE);
+  g_object_get (G_OBJECT (cur), "eos", &b, "sizetype", &i, NULL);
+  TEST_CHECK_FAIL (i == 3);
+  TEST_CHECK_FAIL (b == FALSE);
+  g_object_get (G_OBJECT (cur), "data", &i, NULL);
+  TEST_CHECK_FAIL (i == 2);
+  TEST_OK;
+
+  /**
+   * checks:
+   * - specifying multiple elements without links works
+   * - if multiple toplevel elements exist, a pipeline is returned
+   */
+  TEST_START (PIPELINE3);
+  TEST_CHECK_FAIL (GST_BIN (cur)->numchildren == 3); /* a bit hacky here */
+  TEST_CHECK_FAIL (GST_IS_PIPELINE (cur));
+  TEST_OK;
+
+  /**
+   * checks:
+   * - test default link "!"
+   * - test if specifying pads on links works
+   */
+  TEST_START (PIPELINE4);
+  TEST_RUN;
+  TEST_OK;
+
+  /**
+   * checks:
+   * - test if appending the links works, too
+   * - check if the pipeline constructed works the same as the one before
+   */
+  i = iterations;
+  TEST_START (PIPELINE5);
+  TEST_RUN;
+  TEST_CHECK_FAIL (i == iterations);
+  TEST_OK;
+
+  /**
+   * checks:
+   * - test various types of bins
+   * - test if linking across bins works
+   * - test if escaping strings works
+   */
+  TEST_START (PIPELINE6);
+  TEST_CHECK_FAIL (GST_IS_PIPELINE (cur));
+  g_object_get (G_OBJECT (cur), "name", &s, NULL);
+  TEST_CHECK_FAIL (strcmp (s, "john") == 0);
+  TEST_RUN;
+  TEST_OK;
+  
+  /**
+   * checks:
+   * - test request pads
+   */
+  TEST_START (PIPELINE7);
+  TEST_RUN;
+  TEST_OK;
+  
+  /**
+   * checks:
+   * - multiple pads on 1 link
+   */
+  TEST_START (PIPELINE8);
+  TEST_RUN;
+  TEST_OK;
+  
+  return 0;
+}
+
diff --git a/tests/old/testsuite/parse/parse2.c b/tests/old/testsuite/parse/parse2.c
new file mode 100644 (file)
index 0000000..647b3bc
--- /dev/null
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
+ *
+ * parse1.c: Test common pipelines (need various plugins)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <gst/gst.h>
+
+#include <string.h>
+
+/* variables used by the TEST_* macros */
+static gint test = 0;
+static guint iterations;
+static GstElement *cur = NULL;
+static GError *error = NULL;
+static char *audio_file = NULL;
+static char *video_file = NULL;
+
+/* variables needed for checking */
+
+#define TEST_CHECK_FAIL(condition) G_STMT_START{ \
+  if (condition) { \
+    g_print ("TEST %2d line %3d    OK\n", test, __LINE__); \
+  } else { \
+    g_print ("TEST %2d line %3d  FAILED : %s\n", test, __LINE__, #condition); \
+    return -test; \
+  } \
+}G_STMT_END
+#ifdef G_HAVE_ISO_VARARGS
+#define TEST_START(...) G_STMT_START{ \
+  gchar *pipeline = g_strdup_printf (__VA_ARGS__); \
+  g_print ("TEST %2d line %3d  START   : %s\n", ++test, __LINE__, pipeline); \
+  cur = gst_parse_launch (pipeline, &error); \
+  if (error == NULL) { \
+    g_print ("TEST %2d line %3d CREATED\n", test, __LINE__); \
+  } else { \
+    g_print ("TEST %2d line %3d  FAILED  : %s\n", test, __LINE__, error->message); \
+    g_error_free (error); \
+    return -test; \
+  } \
+  g_free (pipeline); \
+}G_STMT_END
+#elif defined(G_HAVE_GNUC_VARARGS)
+#define TEST_START(pipe...) G_STMT_START{ \
+  gchar *pipeline = g_strdup_printf ( ## pipe ); \
+  g_print ("TEST %2d line %3d  START   : %s\n", ++test, __LINE__, pipeline); \
+  cur = gst_parse_launch (pipeline, &error); \
+  if (error == NULL) { \
+    g_print ("TEST %2d line %3d CREATED\n", test, __LINE__); \
+  } else { \
+    g_print ("TEST %2d line %3d  FAILED  : %s\n", test, __LINE__, error->message); \
+    g_error_free (error); \
+    return -test; \
+  } \
+  g_free (pipeline); \
+}G_STMT_END
+#else
+#error Please fix this macro here
+#define TEST_START(pipe...) G_STMT_START{ \
+  gchar *pipeline = g_strdup_printf (__VA_ARGS__); \
+  g_print ("TEST %2d line %3d  START   : %s\n", ++test, __LINE__, pipeline); \
+  cur = gst_parse_launch (pipeline, &error); \
+  if (error == NULL) { \
+    g_print ("TEST %2d line %3d CREATED\n", test, __LINE__); \
+  } else { \
+    g_print ("TEST %2d line %3d  FAILED  : %s\n", test, __LINE__, error->message); \
+    g_error_free (error); \
+    return -test; \
+  } \
+  g_free (pipeline); \
+}G_STMT_END
+#endif
+#define TEST_OK G_STMT_START{ \
+  gst_object_unref (GST_OBJECT (cur)); \
+  cur = NULL; \
+  g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \
+}G_STMT_END 
+#define TEST_RUN(iters) G_STMT_START{ \
+  gint it = iters; \
+  g_print ("TEST %2d line %3d   RUN\n", test, __LINE__); \
+  if (gst_element_set_state (cur, GST_STATE_PLAYING) == GST_STATE_FAILURE) { \
+    g_print ("TEST %2d line %3d  FAILED  : pipeline could not be set to state PLAYING\n", test, __LINE__); \
+    return -test; \
+  } \
+  iterations = 0; \
+  while (gst_bin_iterate (GST_BIN (cur)) && it != 0) { \
+    iterations++; \
+    it--; \
+  } \
+  if (gst_element_set_state (cur, GST_STATE_NULL) == GST_STATE_FAILURE) { \
+    g_print ("TEST %2d line %3d  FAILED  : pipeline could not be reset to state NULL\n", test, __LINE__); \
+    return -test; \
+  } \
+  g_print ("TEST %2d line %3d STOPPED  : %u iterations\n", test, __LINE__, iterations); \
+}G_STMT_END 
+#define TEST_FINISH G_STMT_START{ \
+  g_print("\n"); \
+  g_print("To run this test there are things required that you do not have. (see above)\n"); \
+  g_print("Please correct the above mentioned problem if you want to run this test.\n"); \
+  g_print("Currently the following tests will be ignored.\n"); \
+  g_print("\n"); \
+  exit (0); \
+}G_STMT_END 
+#define TEST_REQUIRE(condition, error) G_STMT_START{ \
+  if (condition) { \
+    g_print ("REQUIRE line %3d    OK\n", __LINE__); \
+  } else { \
+    g_print ("REQUIRE line %3d   EXIT   : %s\n", __LINE__, (error)); \
+    TEST_FINISH; \
+  } \
+}G_STMT_END 
+#define TEST_REQUIRE_ELEMENT(element_name) G_STMT_START{ \
+  GstElement *element = gst_element_factory_make ((element_name), NULL); \
+  if (element) { \
+    g_print ("REQUIRE line %3d    OK\n", __LINE__); \
+    gst_object_unref (GST_OBJECT (element)); \
+  } else { \
+    g_print ("REQUIRE line %3d   EXIT   : No element of type \"%s\" available. Exiting.\n", __LINE__, (element_name)); \
+    TEST_FINISH; \
+  } \
+}G_STMT_END 
+
+#define PIPELINE1 "filesrc blocksize =8192  location=%s ! mad ! osssink"
+#define PIPELINE2 "filesrc location=%s ! mpegdemux ! mpeg2dec ! xvideosink"
+#define PIPELINE3 "filesrc location=%s ! mpegdemux name = demux ! mpeg2dec ! { queue ! xvideosink } demux.audio_00 ! mad ! osssink"
+#define PIPELINE4 "pipeline. ( { filesrc location=%s ! spider name=spider ! { queue ! volume ! ( tee name=tee ! { queue ! ( goom ) ! colorspace ! ( xvideosink ) } tee. ! { queue ! ( osssink ) } ) } spider. ! { queue ! colorspace ( xvideosink ) } } )"
+#define PIPELINE5 "pipeline. ( { filesrc location=%s ! spider name=spider ! ( tee name=tee ! { queue ! spider ! ( goom ) ! colorspace ! ( xvideosink ) } tee. ! { queue ! volume ! ( osssink ) } ) spider. ! { queue! colorspace ( xvideosink ) } } )"
+
+/* FIXME: Should this run, too?
+#define PIPELINE3 "filesrc location=%s ! mpegdemux name = demux ! mpeg2dec ! { queue ! xvideosink } demux.audio_%%02d ! mad ! osssink"
+*/
+
+gint 
+main (gint argc, gchar *argv[]) 
+{
+  gst_init (&argc, &argv);
+
+goto here;
+here:
+
+  /**
+   * checks:
+   * - default playback pipeline
+   * - unsigned parameters
+   */
+  audio_file = g_build_filename (g_get_home_dir (), "music.mp3", NULL);
+  TEST_REQUIRE (g_file_test (audio_file, G_FILE_TEST_EXISTS), "The following tests requires a valid mp3 file music.mp3 in your home directory.");
+  TEST_REQUIRE_ELEMENT ("mad");
+  TEST_REQUIRE_ELEMENT ("osssink");
+  TEST_START (PIPELINE1, audio_file);
+  TEST_RUN (10);
+  TEST_OK;
+
+  /**
+   * checks:
+   * - default video playback pipeline (without audio)
+   * - SOMETIMES pads
+   */
+  video_file = g_build_filename (g_get_home_dir (), "video.mpeg", NULL);
+  TEST_REQUIRE (g_file_test (video_file, G_FILE_TEST_EXISTS), "The following tests requires a valid mpeg file video.mpeg in your home directory.");
+  TEST_REQUIRE_ELEMENT ("mpegdemux");
+  TEST_REQUIRE_ELEMENT ("mpeg2dec");
+  TEST_REQUIRE_ELEMENT ("xvideosink");
+  TEST_START (PIPELINE2, video_file);
+  TEST_RUN (50);
+  TEST_OK;
+
+  /**
+   * checks:
+   * - default video playback pipeline (with audio)
+   * - more SOMETIMES pads
+   */
+  TEST_START (PIPELINE3, video_file);
+  TEST_RUN (200);
+  TEST_OK;
+
+  /**
+   * checks:
+   * - default new gst-player pipeline
+   */
+  TEST_START (PIPELINE4, video_file);
+  TEST_RUN (500);
+  TEST_OK;
+
+  /**
+   * checks:
+   * - default old gst-player pipeline
+   */
+  TEST_START (PIPELINE5, video_file);
+  TEST_RUN (500);
+  TEST_OK;
+
+  g_free (audio_file);
+  g_free (video_file);
+  return 0;
+}
index 3b75335..3748b1d 100644 (file)
@@ -1,5 +1,11 @@
+if GST_DISABLE_PARSE
+GST_PARSE_DIRS = 
+else
+GST_PARSE_DIRS = parse
+endif
+
 # FIXME : threads bytestream
-SUBDIRS = caps plugin elements clock refcounting threads indexers ## cleanup dynparams
+SUBDIRS = caps plugin elements clock refcounting threads indexers $(GST_PARSE_DIRS) ## cleanup dynparams
 
 GST_PLUGIN_PATH = $(shell cd $(top_builddir) && pwd)
 TESTS_ENVIRONMENT = GST_PLUGIN_PATH=$(GST_PLUGIN_PATH) GST_REGISTRY=`pwd`/test-registry.xml
@@ -24,6 +30,6 @@ AM_CFLAGS = $(GST_CFLAGS)
 CLEANFILES = test-registry.xml elementstest-registry.xml
 
 DIST_SUBDIRS = bytestream caps cleanup clock dynparams elements indexers \
-               plugin refcounting threads
+               plugin refcounting threads parse
 
 EXTRA_DIST = gst-inspect-check
diff --git a/testsuite/parse/.gitignore b/testsuite/parse/.gitignore
new file mode 100644 (file)
index 0000000..5dbe8a3
--- /dev/null
@@ -0,0 +1,9 @@
+Makefile
+Makefile.in
+*.o
+*.lo
+*.la
+.deps
+.libs
+parse1
+parse2
diff --git a/testsuite/parse/Makefile.am b/testsuite/parse/Makefile.am
new file mode 100644 (file)
index 0000000..0d15c50
--- /dev/null
@@ -0,0 +1,12 @@
+testprogs = parse1 parse2
+
+TESTS = $(testprogs)
+
+check_PROGRAMS = $(testprogs)
+
+parse1_SOURCES = parse1.c
+parse2_SOURCES = parse2.c
+
+# we have nothing but apps here, we can do this safely
+LIBS = $(GST_LIBS)
+AM_CFLAGS = $(GST_CFLAGS)
diff --git a/testsuite/parse/parse1.c b/testsuite/parse/parse1.c
new file mode 100644 (file)
index 0000000..d7f3469
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
+ *
+ * parse1.c: Test various parsing stuff
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <gst/gst.h>
+
+#include <string.h>
+
+/* variables used by the TEST_* macros */
+static gint test = 0;
+static guint iterations;
+static GstElement *cur = NULL;
+static GError *error = NULL;
+
+/* variables needed for checking */
+static gint i;
+static gboolean b;
+static gchar *s;
+
+#define TEST_CHECK_FAIL(condition) G_STMT_START{ \
+  if (condition) { \
+    g_print ("TEST %2d line %3d    OK\n", test, __LINE__); \
+  } else { \
+    g_print ("TEST %2d line %3d  FAILED : %s\n", test, __LINE__, #condition); \
+    return -test; \
+  } \
+}G_STMT_END
+#define TEST_START(pipeline) G_STMT_START{ \
+  g_print ("TEST %2d line %3d  START   : %s\n", ++test, __LINE__, pipeline); \
+  cur = gst_parse_launch (pipeline, &error); \
+  if (error == NULL) { \
+    g_print ("TEST %2d line %3d CREATED\n", test, __LINE__); \
+  } else { \
+    g_print ("TEST %2d line %3d  FAILED  : %s\n", test, __LINE__, error->message); \
+    g_error_free (error); \
+    return -test; \
+  } \
+}G_STMT_END
+#define TEST_OK G_STMT_START{ \
+  gst_object_unref (GST_OBJECT (cur)); \
+  cur = NULL; \
+  g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \
+}G_STMT_END 
+#define TEST_RUN G_STMT_START{ \
+  g_print ("TEST %2d line %3d   RUN\n", test, __LINE__); \
+  if (gst_element_set_state (cur, GST_STATE_PLAYING) == GST_STATE_FAILURE) { \
+    g_print ("TEST %2d line %3d  FAILED  : pipeline could not be set to state PLAYING\n", test, __LINE__); \
+    return -test; \
+  } \
+  iterations = 0; \
+  while (gst_bin_iterate (GST_BIN (cur))) iterations++; \
+  if (gst_element_set_state (cur, GST_STATE_NULL) == GST_STATE_FAILURE) { \
+    g_print ("TEST %2d line %3d  FAILED  : pipeline could not be reset to state NULL\n", test, __LINE__); \
+    return -test; \
+  } \
+  g_print ("TEST %2d line %3d STOPPED  : %u iterations\n", test, __LINE__, iterations); \
+}G_STMT_END 
+#define PIPELINE1 "fakesrc"
+#define PIPELINE2 "fakesrc name=donald num-buffers= 27 silent =TruE sizetype = 3 eos  =    yesyo data=   Subbuffer\\ data"
+#define PIPELINE3 "fakesrc identity fakesink"
+#define PIPELINE4 "fakesrc num-buffers=4 .src ! identity !.sink identity .src ! .sink fakesink"
+#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"
+#define PIPELINE6 "pipeline.(name=\"john\" fakesrc num-buffers=4 ( thread. ( ! queue ! identity !{ queue ! fakesink }) ))"
+#define PIPELINE7 "fakesrc num-buffers=4 ! tee name=tee .src%d! fakesink tee.src%d ! fakesink fakesink name =\"foo\" tee.src%d ! foo."
+#define PIPELINE8 "fakesrc num-buffers=4 ! tee name=tee1 .src0,src1 ! .sink0, sink1 aggregator ! fakesink"
+
+gint 
+main (gint argc, gchar *argv[]) 
+{
+  gst_init (&argc, &argv);
+
+goto here;
+here:
+
+  /**
+   * checks:
+   * - specifying an element works :)
+   * - if only 1 element is requested, no bin is returned, but the element
+   */
+  TEST_START (PIPELINE1);
+  TEST_CHECK_FAIL (G_OBJECT_TYPE (cur) == g_type_from_name ("GstFakeSrc"));
+  TEST_OK;
+
+  /**
+   * checks:
+   * - properties works
+   * - string, int, boolean and enums can be properly set (note: eos should be false)
+   * - first test of escaping strings
+   */
+  TEST_START (PIPELINE2);
+  g_object_get (G_OBJECT (cur), "name", &s, "num-buffers", &i, "silent", &b, NULL);
+  TEST_CHECK_FAIL (strcmp (s, "donald") == 0);
+  TEST_CHECK_FAIL (i == 27);
+  TEST_CHECK_FAIL (b == TRUE);
+  g_object_get (G_OBJECT (cur), "eos", &b, "sizetype", &i, NULL);
+  TEST_CHECK_FAIL (i == 3);
+  TEST_CHECK_FAIL (b == FALSE);
+  g_object_get (G_OBJECT (cur), "data", &i, NULL);
+  TEST_CHECK_FAIL (i == 2);
+  TEST_OK;
+
+  /**
+   * checks:
+   * - specifying multiple elements without links works
+   * - if multiple toplevel elements exist, a pipeline is returned
+   */
+  TEST_START (PIPELINE3);
+  TEST_CHECK_FAIL (GST_BIN (cur)->numchildren == 3); /* a bit hacky here */
+  TEST_CHECK_FAIL (GST_IS_PIPELINE (cur));
+  TEST_OK;
+
+  /**
+   * checks:
+   * - test default link "!"
+   * - test if specifying pads on links works
+   */
+  TEST_START (PIPELINE4);
+  TEST_RUN;
+  TEST_OK;
+
+  /**
+   * checks:
+   * - test if appending the links works, too
+   * - check if the pipeline constructed works the same as the one before
+   */
+  i = iterations;
+  TEST_START (PIPELINE5);
+  TEST_RUN;
+  TEST_CHECK_FAIL (i == iterations);
+  TEST_OK;
+
+  /**
+   * checks:
+   * - test various types of bins
+   * - test if linking across bins works
+   * - test if escaping strings works
+   */
+  TEST_START (PIPELINE6);
+  TEST_CHECK_FAIL (GST_IS_PIPELINE (cur));
+  g_object_get (G_OBJECT (cur), "name", &s, NULL);
+  TEST_CHECK_FAIL (strcmp (s, "john") == 0);
+  TEST_RUN;
+  TEST_OK;
+  
+  /**
+   * checks:
+   * - test request pads
+   */
+  TEST_START (PIPELINE7);
+  TEST_RUN;
+  TEST_OK;
+  
+  /**
+   * checks:
+   * - multiple pads on 1 link
+   */
+  TEST_START (PIPELINE8);
+  TEST_RUN;
+  TEST_OK;
+  
+  return 0;
+}
+
diff --git a/testsuite/parse/parse2.c b/testsuite/parse/parse2.c
new file mode 100644 (file)
index 0000000..647b3bc
--- /dev/null
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
+ *
+ * parse1.c: Test common pipelines (need various plugins)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include <gst/gst.h>
+
+#include <string.h>
+
+/* variables used by the TEST_* macros */
+static gint test = 0;
+static guint iterations;
+static GstElement *cur = NULL;
+static GError *error = NULL;
+static char *audio_file = NULL;
+static char *video_file = NULL;
+
+/* variables needed for checking */
+
+#define TEST_CHECK_FAIL(condition) G_STMT_START{ \
+  if (condition) { \
+    g_print ("TEST %2d line %3d    OK\n", test, __LINE__); \
+  } else { \
+    g_print ("TEST %2d line %3d  FAILED : %s\n", test, __LINE__, #condition); \
+    return -test; \
+  } \
+}G_STMT_END
+#ifdef G_HAVE_ISO_VARARGS
+#define TEST_START(...) G_STMT_START{ \
+  gchar *pipeline = g_strdup_printf (__VA_ARGS__); \
+  g_print ("TEST %2d line %3d  START   : %s\n", ++test, __LINE__, pipeline); \
+  cur = gst_parse_launch (pipeline, &error); \
+  if (error == NULL) { \
+    g_print ("TEST %2d line %3d CREATED\n", test, __LINE__); \
+  } else { \
+    g_print ("TEST %2d line %3d  FAILED  : %s\n", test, __LINE__, error->message); \
+    g_error_free (error); \
+    return -test; \
+  } \
+  g_free (pipeline); \
+}G_STMT_END
+#elif defined(G_HAVE_GNUC_VARARGS)
+#define TEST_START(pipe...) G_STMT_START{ \
+  gchar *pipeline = g_strdup_printf ( ## pipe ); \
+  g_print ("TEST %2d line %3d  START   : %s\n", ++test, __LINE__, pipeline); \
+  cur = gst_parse_launch (pipeline, &error); \
+  if (error == NULL) { \
+    g_print ("TEST %2d line %3d CREATED\n", test, __LINE__); \
+  } else { \
+    g_print ("TEST %2d line %3d  FAILED  : %s\n", test, __LINE__, error->message); \
+    g_error_free (error); \
+    return -test; \
+  } \
+  g_free (pipeline); \
+}G_STMT_END
+#else
+#error Please fix this macro here
+#define TEST_START(pipe...) G_STMT_START{ \
+  gchar *pipeline = g_strdup_printf (__VA_ARGS__); \
+  g_print ("TEST %2d line %3d  START   : %s\n", ++test, __LINE__, pipeline); \
+  cur = gst_parse_launch (pipeline, &error); \
+  if (error == NULL) { \
+    g_print ("TEST %2d line %3d CREATED\n", test, __LINE__); \
+  } else { \
+    g_print ("TEST %2d line %3d  FAILED  : %s\n", test, __LINE__, error->message); \
+    g_error_free (error); \
+    return -test; \
+  } \
+  g_free (pipeline); \
+}G_STMT_END
+#endif
+#define TEST_OK G_STMT_START{ \
+  gst_object_unref (GST_OBJECT (cur)); \
+  cur = NULL; \
+  g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \
+}G_STMT_END 
+#define TEST_RUN(iters) G_STMT_START{ \
+  gint it = iters; \
+  g_print ("TEST %2d line %3d   RUN\n", test, __LINE__); \
+  if (gst_element_set_state (cur, GST_STATE_PLAYING) == GST_STATE_FAILURE) { \
+    g_print ("TEST %2d line %3d  FAILED  : pipeline could not be set to state PLAYING\n", test, __LINE__); \
+    return -test; \
+  } \
+  iterations = 0; \
+  while (gst_bin_iterate (GST_BIN (cur)) && it != 0) { \
+    iterations++; \
+    it--; \
+  } \
+  if (gst_element_set_state (cur, GST_STATE_NULL) == GST_STATE_FAILURE) { \
+    g_print ("TEST %2d line %3d  FAILED  : pipeline could not be reset to state NULL\n", test, __LINE__); \
+    return -test; \
+  } \
+  g_print ("TEST %2d line %3d STOPPED  : %u iterations\n", test, __LINE__, iterations); \
+}G_STMT_END 
+#define TEST_FINISH G_STMT_START{ \
+  g_print("\n"); \
+  g_print("To run this test there are things required that you do not have. (see above)\n"); \
+  g_print("Please correct the above mentioned problem if you want to run this test.\n"); \
+  g_print("Currently the following tests will be ignored.\n"); \
+  g_print("\n"); \
+  exit (0); \
+}G_STMT_END 
+#define TEST_REQUIRE(condition, error) G_STMT_START{ \
+  if (condition) { \
+    g_print ("REQUIRE line %3d    OK\n", __LINE__); \
+  } else { \
+    g_print ("REQUIRE line %3d   EXIT   : %s\n", __LINE__, (error)); \
+    TEST_FINISH; \
+  } \
+}G_STMT_END 
+#define TEST_REQUIRE_ELEMENT(element_name) G_STMT_START{ \
+  GstElement *element = gst_element_factory_make ((element_name), NULL); \
+  if (element) { \
+    g_print ("REQUIRE line %3d    OK\n", __LINE__); \
+    gst_object_unref (GST_OBJECT (element)); \
+  } else { \
+    g_print ("REQUIRE line %3d   EXIT   : No element of type \"%s\" available. Exiting.\n", __LINE__, (element_name)); \
+    TEST_FINISH; \
+  } \
+}G_STMT_END 
+
+#define PIPELINE1 "filesrc blocksize =8192  location=%s ! mad ! osssink"
+#define PIPELINE2 "filesrc location=%s ! mpegdemux ! mpeg2dec ! xvideosink"
+#define PIPELINE3 "filesrc location=%s ! mpegdemux name = demux ! mpeg2dec ! { queue ! xvideosink } demux.audio_00 ! mad ! osssink"
+#define PIPELINE4 "pipeline. ( { filesrc location=%s ! spider name=spider ! { queue ! volume ! ( tee name=tee ! { queue ! ( goom ) ! colorspace ! ( xvideosink ) } tee. ! { queue ! ( osssink ) } ) } spider. ! { queue ! colorspace ( xvideosink ) } } )"
+#define PIPELINE5 "pipeline. ( { filesrc location=%s ! spider name=spider ! ( tee name=tee ! { queue ! spider ! ( goom ) ! colorspace ! ( xvideosink ) } tee. ! { queue ! volume ! ( osssink ) } ) spider. ! { queue! colorspace ( xvideosink ) } } )"
+
+/* FIXME: Should this run, too?
+#define PIPELINE3 "filesrc location=%s ! mpegdemux name = demux ! mpeg2dec ! { queue ! xvideosink } demux.audio_%%02d ! mad ! osssink"
+*/
+
+gint 
+main (gint argc, gchar *argv[]) 
+{
+  gst_init (&argc, &argv);
+
+goto here;
+here:
+
+  /**
+   * checks:
+   * - default playback pipeline
+   * - unsigned parameters
+   */
+  audio_file = g_build_filename (g_get_home_dir (), "music.mp3", NULL);
+  TEST_REQUIRE (g_file_test (audio_file, G_FILE_TEST_EXISTS), "The following tests requires a valid mp3 file music.mp3 in your home directory.");
+  TEST_REQUIRE_ELEMENT ("mad");
+  TEST_REQUIRE_ELEMENT ("osssink");
+  TEST_START (PIPELINE1, audio_file);
+  TEST_RUN (10);
+  TEST_OK;
+
+  /**
+   * checks:
+   * - default video playback pipeline (without audio)
+   * - SOMETIMES pads
+   */
+  video_file = g_build_filename (g_get_home_dir (), "video.mpeg", NULL);
+  TEST_REQUIRE (g_file_test (video_file, G_FILE_TEST_EXISTS), "The following tests requires a valid mpeg file video.mpeg in your home directory.");
+  TEST_REQUIRE_ELEMENT ("mpegdemux");
+  TEST_REQUIRE_ELEMENT ("mpeg2dec");
+  TEST_REQUIRE_ELEMENT ("xvideosink");
+  TEST_START (PIPELINE2, video_file);
+  TEST_RUN (50);
+  TEST_OK;
+
+  /**
+   * checks:
+   * - default video playback pipeline (with audio)
+   * - more SOMETIMES pads
+   */
+  TEST_START (PIPELINE3, video_file);
+  TEST_RUN (200);
+  TEST_OK;
+
+  /**
+   * checks:
+   * - default new gst-player pipeline
+   */
+  TEST_START (PIPELINE4, video_file);
+  TEST_RUN (500);
+  TEST_OK;
+
+  /**
+   * checks:
+   * - default old gst-player pipeline
+   */
+  TEST_START (PIPELINE5, video_file);
+  TEST_RUN (500);
+  TEST_OK;
+
+  g_free (audio_file);
+  g_free (video_file);
+  return 0;
+}