add asserts, fix up tests slightly

Original commit message from CVS:
add asserts, fix up tests slightly
This commit is contained in:
Thomas Vander Stichele 2004-04-13 10:44:29 +00:00
parent 0d4983a512
commit 21392d9227
4 changed files with 66 additions and 78 deletions

View file

@ -10,10 +10,13 @@ create_bin (void)
GstElement *element;
bin = gst_bin_new ("testbin");
g_assert (GST_IS_BIN (bin));
element = gst_element_factory_make ("fakesrc", NULL);
g_assert (GST_IS_ELEMENT (element));
gst_element_set_name (element, "test1");
gst_bin_add (GST_BIN (bin), element);
element = gst_element_factory_make ("fakesrc", NULL);
g_assert (GST_IS_ELEMENT (element));
gst_element_set_name (element, "test2");
gst_bin_add (GST_BIN (bin), element);

View file

@ -20,103 +20,94 @@ main (int argc, gchar * argv[])
else
iters = ITERS;
g_print ("starting element with pad test with %d iterations\n", iters);
usage1 = vmsize ();
element = gst_element_factory_make ("fakesink", NULL);;
g_assert (GST_IS_ELEMENT (element));
pad = gst_element_get_pad (element, "sink");
g_assert (GST_IS_PAD (pad));
g_assert (GST_OBJECT_FLOATING (element));
g_assert (!GST_OBJECT_FLOATING (pad));
g_assert (gst_pad_get_parent (pad) == element);
gst_object_unref (GST_OBJECT (element));
g_print ("create/addpad/unref new element %ld\n", vmsize () - usage1);
g_print ("create/addpad/unref 1 new element: %ld\n", vmsize () - usage1);
for (i = 0; i < iters; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
g_assert (GST_IS_ELEMENT (element));
gst_object_unref (GST_OBJECT (element));
}
g_print ("create/addpad/unref %d elements %ld\n", iters, vmsize () - usage1);
g_print ("create/unref %d elements: %ld\n", iters, vmsize () - usage1);
for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);
g_assert (GST_IS_ELEMENT (element));
element2 = gst_element_factory_make ("fakesrc", NULL);
gst_element_link_pads (element, "sink", element2, "src");
g_assert (GST_IS_ELEMENT (element2));
gst_element_link_pads (element2, "src", element, "sink");
g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element, "sink")));
gst_object_unref (GST_OBJECT (element));
g_assert (!GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
gst_object_unref (GST_OBJECT (element2));
}
g_print ("create/link/unref %d elements %ld\n", iters / 2,
vmsize () - usage1);
for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);
element2 = gst_element_factory_make ("fakesrc", NULL);
gst_element_link_pads (element, "sink", element2, "src");
g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element, "sink")));
gst_object_unref (GST_OBJECT (element));
g_assert (GST_OBJECT_DESTROYED (element));
g_assert (!GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
gst_object_unref (GST_OBJECT (element2));
gst_object_unref (GST_OBJECT (element));
}
g_print ("create/link/destroy %d elements %ld\n", iters / 2,
g_print ("create/link/unref %d element duos: %ld\n", iters / 2,
vmsize () - usage1);
element = gst_element_factory_make ("fakesink", NULL);;
g_assert (GST_IS_ELEMENT (element));
pad = gst_element_get_pad (element, "sink");
g_assert (GST_IS_PAD (pad));
gst_element_remove_pad (element, pad);
g_assert (gst_element_get_pad (element, "sink") == NULL);
gst_object_unref (GST_OBJECT (element));
g_print ("pad removal on one element: %ld\n", vmsize () - usage1);
g_print ("pad removal ok %ld\n", vmsize () - usage1);
for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
g_assert (GST_IS_ELEMENT (element));
pad = gst_element_get_pad (element, "sink");
g_assert (GST_IS_PAD (pad));
gst_element_remove_pad (element, pad);
g_assert (gst_element_get_pad (element, "sink") == NULL);
gst_object_unref (GST_OBJECT (element));
}
g_print ("pad removal loop %d %ld\n", iters / 2, vmsize () - usage1);
g_print ("pad removal loop on %d elements: %ld\n", iters / 2,
vmsize () - usage1);
for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
g_assert (GST_IS_ELEMENT (element));
pad = gst_element_get_pad (element, "sink");
g_assert (GST_IS_PAD (pad));
gst_object_ref (GST_OBJECT (pad));
gst_element_remove_pad (element, pad);
g_assert (gst_pad_get_parent (pad) == NULL);
gst_object_unref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (element));
}
g_print ("pad removal and test loop %d %ld\n", iters / 2,
g_print ("pad ref/removal/test loop on %d elements: %ld\n", iters / 2,
vmsize () - usage1);
element = gst_element_factory_make ("fakesink", NULL);;
g_assert (GST_IS_ELEMENT (element));
pad = gst_element_get_pad (element, "sink");
gst_object_unref (GST_OBJECT (element));
g_assert (GST_OBJECT_DESTROYED (element));
g_assert (gst_element_get_pad (element, "sink") == NULL);
g_assert (GST_IS_PAD (pad));
gst_object_unref (GST_OBJECT (element));
g_print ("pad destroy/removal ok %ld\n", vmsize () - usage1);
g_print ("pad unref on one element: %ld\n", vmsize () - usage1);
for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
element = gst_element_factory_make ("fakesink", NULL);
g_assert (GST_IS_ELEMENT (element));
pad = gst_element_get_pad (element, "sink");
gst_object_unref (GST_OBJECT (element));
g_assert (GST_IS_PAD (pad));
gst_object_unref (GST_OBJECT (element));
}
g_print ("pad destroy/removal loop %d %ld\n", iters / 2, vmsize () - usage1);
for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_object_unref (GST_OBJECT (pad));
g_assert (gst_element_get_pad (element, "sink") == NULL);
gst_object_unref (GST_OBJECT (element));
}
g_print ("pad destroy loop %d %ld\n", iters / 2, vmsize () - usage1);
g_print ("pad unref loop on %d elements: %ld\n", iters / 2,
vmsize () - usage1);
g_print ("leaked: %ld\n", vmsize () - usage1);

View file

@ -10,10 +10,13 @@ create_bin (void)
GstElement *element;
bin = gst_bin_new ("testbin");
g_assert (GST_IS_BIN (bin));
element = gst_element_factory_make ("fakesrc", NULL);
g_assert (GST_IS_ELEMENT (element));
gst_element_set_name (element, "test1");
gst_bin_add (GST_BIN (bin), element);
element = gst_element_factory_make ("fakesrc", NULL);
g_assert (GST_IS_ELEMENT (element));
gst_element_set_name (element, "test2");
gst_bin_add (GST_BIN (bin), element);

View file

@ -20,103 +20,94 @@ main (int argc, gchar * argv[])
else
iters = ITERS;
g_print ("starting element with pad test with %d iterations\n", iters);
usage1 = vmsize ();
element = gst_element_factory_make ("fakesink", NULL);;
g_assert (GST_IS_ELEMENT (element));
pad = gst_element_get_pad (element, "sink");
g_assert (GST_IS_PAD (pad));
g_assert (GST_OBJECT_FLOATING (element));
g_assert (!GST_OBJECT_FLOATING (pad));
g_assert (gst_pad_get_parent (pad) == element);
gst_object_unref (GST_OBJECT (element));
g_print ("create/addpad/unref new element %ld\n", vmsize () - usage1);
g_print ("create/addpad/unref 1 new element: %ld\n", vmsize () - usage1);
for (i = 0; i < iters; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
g_assert (GST_IS_ELEMENT (element));
gst_object_unref (GST_OBJECT (element));
}
g_print ("create/addpad/unref %d elements %ld\n", iters, vmsize () - usage1);
g_print ("create/unref %d elements: %ld\n", iters, vmsize () - usage1);
for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);
g_assert (GST_IS_ELEMENT (element));
element2 = gst_element_factory_make ("fakesrc", NULL);
gst_element_link_pads (element, "sink", element2, "src");
g_assert (GST_IS_ELEMENT (element2));
gst_element_link_pads (element2, "src", element, "sink");
g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element, "sink")));
gst_object_unref (GST_OBJECT (element));
g_assert (!GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
gst_object_unref (GST_OBJECT (element2));
}
g_print ("create/link/unref %d elements %ld\n", iters / 2,
vmsize () - usage1);
for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);
element2 = gst_element_factory_make ("fakesrc", NULL);
gst_element_link_pads (element, "sink", element2, "src");
g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
g_assert (GST_PAD_IS_LINKED (gst_element_get_pad (element, "sink")));
gst_object_unref (GST_OBJECT (element));
g_assert (GST_OBJECT_DESTROYED (element));
g_assert (!GST_PAD_IS_LINKED (gst_element_get_pad (element2, "src")));
gst_object_unref (GST_OBJECT (element2));
gst_object_unref (GST_OBJECT (element));
}
g_print ("create/link/destroy %d elements %ld\n", iters / 2,
g_print ("create/link/unref %d element duos: %ld\n", iters / 2,
vmsize () - usage1);
element = gst_element_factory_make ("fakesink", NULL);;
g_assert (GST_IS_ELEMENT (element));
pad = gst_element_get_pad (element, "sink");
g_assert (GST_IS_PAD (pad));
gst_element_remove_pad (element, pad);
g_assert (gst_element_get_pad (element, "sink") == NULL);
gst_object_unref (GST_OBJECT (element));
g_print ("pad removal on one element: %ld\n", vmsize () - usage1);
g_print ("pad removal ok %ld\n", vmsize () - usage1);
for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
g_assert (GST_IS_ELEMENT (element));
pad = gst_element_get_pad (element, "sink");
g_assert (GST_IS_PAD (pad));
gst_element_remove_pad (element, pad);
g_assert (gst_element_get_pad (element, "sink") == NULL);
gst_object_unref (GST_OBJECT (element));
}
g_print ("pad removal loop %d %ld\n", iters / 2, vmsize () - usage1);
g_print ("pad removal loop on %d elements: %ld\n", iters / 2,
vmsize () - usage1);
for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
g_assert (GST_IS_ELEMENT (element));
pad = gst_element_get_pad (element, "sink");
g_assert (GST_IS_PAD (pad));
gst_object_ref (GST_OBJECT (pad));
gst_element_remove_pad (element, pad);
g_assert (gst_pad_get_parent (pad) == NULL);
gst_object_unref (GST_OBJECT (pad));
gst_object_unref (GST_OBJECT (element));
}
g_print ("pad removal and test loop %d %ld\n", iters / 2,
g_print ("pad ref/removal/test loop on %d elements: %ld\n", iters / 2,
vmsize () - usage1);
element = gst_element_factory_make ("fakesink", NULL);;
g_assert (GST_IS_ELEMENT (element));
pad = gst_element_get_pad (element, "sink");
gst_object_unref (GST_OBJECT (element));
g_assert (GST_OBJECT_DESTROYED (element));
g_assert (gst_element_get_pad (element, "sink") == NULL);
g_assert (GST_IS_PAD (pad));
gst_object_unref (GST_OBJECT (element));
g_print ("pad destroy/removal ok %ld\n", vmsize () - usage1);
g_print ("pad unref on one element: %ld\n", vmsize () - usage1);
for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
element = gst_element_factory_make ("fakesink", NULL);
g_assert (GST_IS_ELEMENT (element));
pad = gst_element_get_pad (element, "sink");
gst_object_unref (GST_OBJECT (element));
g_assert (GST_IS_PAD (pad));
gst_object_unref (GST_OBJECT (element));
}
g_print ("pad destroy/removal loop %d %ld\n", iters / 2, vmsize () - usage1);
for (i = 0; i < iters / 2; i++) {
element = gst_element_factory_make ("fakesink", NULL);;
pad = gst_element_get_pad (element, "sink");
gst_object_unref (GST_OBJECT (pad));
g_assert (gst_element_get_pad (element, "sink") == NULL);
gst_object_unref (GST_OBJECT (element));
}
g_print ("pad destroy loop %d %ld\n", iters / 2, vmsize () - usage1);
g_print ("pad unref loop on %d elements: %ld\n", iters / 2,
vmsize () - usage1);
g_print ("leaked: %ld\n", vmsize () - usage1);