testsuite/threads/: Added testsuite to show bug #159566
authorWim Taymans <wim.taymans@gmail.com>
Fri, 26 Nov 2004 18:29:06 +0000 (18:29 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Fri, 26 Nov 2004 18:29:06 +0000 (18:29 +0000)
Original commit message from CVS:
* testsuite/threads/159566.c: (object_deep_notify), (main):
* testsuite/threads/Makefile.am:
Added testsuite to show bug #159566

ChangeLog
tests/old/testsuite/threads/159566.c [new file with mode: 0644]
tests/old/testsuite/threads/Makefile.am
testsuite/threads/159566.c [new file with mode: 0644]
testsuite/threads/Makefile.am

index 6a2b719..43bce9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-11-26  Wim Taymans  <wim@fluendo.com>
+
+       * testsuite/threads/159566.c: (object_deep_notify), (main):
+       * testsuite/threads/Makefile.am:
+       Added testsuite to show bug #159566
+
 2004-11-25  Wim Taymans  <wim@fluendo.com>
 
        * gst/gstthread.c: (gst_thread_dispose), (gst_thread_change_state),
diff --git a/tests/old/testsuite/threads/159566.c b/tests/old/testsuite/threads/159566.c
new file mode 100644 (file)
index 0000000..abb704c
--- /dev/null
@@ -0,0 +1,95 @@
+#include <string.h>
+#include <unistd.h>
+#include <gst/gst.h>
+
+static GstElement *src1, *sink1;
+static gboolean need_src1 = TRUE;
+static gint iter = 0;
+
+static void
+object_deep_notify (GObject * object, GstObject * orig,
+    GParamSpec * pspec, gchar ** excluded_props)
+{
+  GValue value = { 0, };        /* the important thing is that value.type = 0 */
+  gchar *str = NULL;
+
+  if (strcmp (pspec->name, "last-message") != 0)
+    return;
+
+  if (GST_ELEMENT (orig) != src1 && GST_ELEMENT (orig) != sink1)
+    return;
+
+  g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+  g_object_get_property (G_OBJECT (orig), pspec->name, &value);
+
+  str = g_strdup_value_contents (&value);
+  g_value_unset (&value);
+
+  if (strstr (str, "E (type:") != NULL) {
+    g_free (str);
+    return;
+  }
+
+  if (iter++ == 100) {
+    g_print (".");
+    iter = 0;
+  }
+  g_free (str);
+  if (need_src1 && GST_ELEMENT (orig) != src1) {
+    g_assert_not_reached ();
+  } else if (!need_src1 && GST_ELEMENT (orig) != sink1) {
+    g_assert_not_reached ();
+  }
+  need_src1 = !need_src1;
+}
+
+
+int
+main (int argc, char **argv)
+{
+  GstElement *thread1, *thread2, *pipeline;
+  GstElement *src2, *sink2;
+
+  gst_init (&argc, &argv);
+
+  pipeline = gst_element_factory_make ("pipeline", "pipeline");
+  thread1 = gst_element_factory_make ("thread", "thread1");
+  g_assert (thread1);
+
+  src1 = gst_element_factory_make ("fakesrc", "src1");
+  g_assert (src1);
+  sink1 = gst_element_factory_make ("fakesink", "sink1");
+  g_assert (sink1);
+
+  thread2 = gst_element_factory_make ("thread", "thread2");
+  g_assert (thread2);
+
+  src2 = gst_element_factory_make ("fakesrc", "src2");
+  g_assert (src2);
+  sink2 = gst_element_factory_make ("fakesink", "sink2");
+  g_assert (sink2);
+
+  gst_bin_add_many (GST_BIN (thread1), src1, sink1, NULL);
+  gst_bin_add_many (GST_BIN (thread2), src2, sink2, NULL);
+
+  gst_bin_add (GST_BIN (pipeline), thread1);
+  gst_bin_add (GST_BIN (pipeline), thread2);
+
+  g_signal_connect (G_OBJECT (pipeline), "deep_notify",
+      G_CALLBACK (object_deep_notify), NULL);
+
+  if (!gst_element_link_many (src1, sink1, NULL))
+    g_assert_not_reached ();
+
+  if (!gst_element_link_many (src2, sink2, NULL))
+    g_assert_not_reached ();
+
+  /* run a bit */
+  if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+    g_assert_not_reached ();
+
+  sleep (10000);
+  g_print ("done\n");
+
+  return 0;
+}
index 741bda1..0c246a2 100644 (file)
@@ -1,7 +1,8 @@
 include ../Rules
 
-tests_pass = thread1 thread2 thread3 thread4 thread5 threade threadf
-tests_fail = 
+tests_pass = thread1 thread2 thread3 thread4 thread5 threade threadf 
+tests_fail = 159566
+
 # threadh
 
 tests_ignore = queue threadb threadc threadd staticrec threadg
diff --git a/testsuite/threads/159566.c b/testsuite/threads/159566.c
new file mode 100644 (file)
index 0000000..abb704c
--- /dev/null
@@ -0,0 +1,95 @@
+#include <string.h>
+#include <unistd.h>
+#include <gst/gst.h>
+
+static GstElement *src1, *sink1;
+static gboolean need_src1 = TRUE;
+static gint iter = 0;
+
+static void
+object_deep_notify (GObject * object, GstObject * orig,
+    GParamSpec * pspec, gchar ** excluded_props)
+{
+  GValue value = { 0, };        /* the important thing is that value.type = 0 */
+  gchar *str = NULL;
+
+  if (strcmp (pspec->name, "last-message") != 0)
+    return;
+
+  if (GST_ELEMENT (orig) != src1 && GST_ELEMENT (orig) != sink1)
+    return;
+
+  g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+  g_object_get_property (G_OBJECT (orig), pspec->name, &value);
+
+  str = g_strdup_value_contents (&value);
+  g_value_unset (&value);
+
+  if (strstr (str, "E (type:") != NULL) {
+    g_free (str);
+    return;
+  }
+
+  if (iter++ == 100) {
+    g_print (".");
+    iter = 0;
+  }
+  g_free (str);
+  if (need_src1 && GST_ELEMENT (orig) != src1) {
+    g_assert_not_reached ();
+  } else if (!need_src1 && GST_ELEMENT (orig) != sink1) {
+    g_assert_not_reached ();
+  }
+  need_src1 = !need_src1;
+}
+
+
+int
+main (int argc, char **argv)
+{
+  GstElement *thread1, *thread2, *pipeline;
+  GstElement *src2, *sink2;
+
+  gst_init (&argc, &argv);
+
+  pipeline = gst_element_factory_make ("pipeline", "pipeline");
+  thread1 = gst_element_factory_make ("thread", "thread1");
+  g_assert (thread1);
+
+  src1 = gst_element_factory_make ("fakesrc", "src1");
+  g_assert (src1);
+  sink1 = gst_element_factory_make ("fakesink", "sink1");
+  g_assert (sink1);
+
+  thread2 = gst_element_factory_make ("thread", "thread2");
+  g_assert (thread2);
+
+  src2 = gst_element_factory_make ("fakesrc", "src2");
+  g_assert (src2);
+  sink2 = gst_element_factory_make ("fakesink", "sink2");
+  g_assert (sink2);
+
+  gst_bin_add_many (GST_BIN (thread1), src1, sink1, NULL);
+  gst_bin_add_many (GST_BIN (thread2), src2, sink2, NULL);
+
+  gst_bin_add (GST_BIN (pipeline), thread1);
+  gst_bin_add (GST_BIN (pipeline), thread2);
+
+  g_signal_connect (G_OBJECT (pipeline), "deep_notify",
+      G_CALLBACK (object_deep_notify), NULL);
+
+  if (!gst_element_link_many (src1, sink1, NULL))
+    g_assert_not_reached ();
+
+  if (!gst_element_link_many (src2, sink2, NULL))
+    g_assert_not_reached ();
+
+  /* run a bit */
+  if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
+    g_assert_not_reached ();
+
+  sleep (10000);
+  g_print ("done\n");
+
+  return 0;
+}
index 741bda1..0c246a2 100644 (file)
@@ -1,7 +1,8 @@
 include ../Rules
 
-tests_pass = thread1 thread2 thread3 thread4 thread5 threade threadf
-tests_fail = 
+tests_pass = thread1 thread2 thread3 thread4 thread5 threade threadf 
+tests_fail = 159566
+
 # threadh
 
 tests_ignore = queue threadb threadc threadd staticrec threadg