diff --git a/tests/old/testsuite/refcounting/element.c b/tests/old/testsuite/refcounting/element.c index 338e8bcd0b..f61ffbcd45 100644 --- a/tests/old/testsuite/refcounting/element.c +++ b/tests/old/testsuite/refcounting/element.c @@ -1,104 +1,98 @@ #include #define ITERS 100000 +#include #include "mem.h" -static void -print_element_props (GstElement *element) -{ - g_print ("name %s\n", gst_element_get_name (element)); - g_print ("flags 0x%08x\n", GST_FLAGS (element)); -} - int main (int argc, gchar *argv[]) { GstElement *element; - long usage1, usage2; - gint i; + long usage1; + gint i, iters; gst_init (&argc, &argv); - g_print ("creating new element\n"); - element = gst_element_new (); - usage1 = vmsize(); - print_element_props (element); - g_print ("unref new element %ld\n", vmsize()-usage1); - gst_object_unref (GST_OBJECT (element)); + if (argc == 2) + iters = atoi (argv[1]); + else + iters = ITERS; + + g_print ("starting test\n"); + usage1 = vmsize(); + + element = gst_element_new (); + gst_object_unref (GST_OBJECT (element)); + g_print ("create/unref new element %ld\n", vmsize()-usage1); + + for (i=0; i #define ITERS 100000 +#include #include "mem.h" -static void -print_pad_props (GstPad *pad) -{ - g_print ("name %s\n", gst_pad_get_name (pad)); - g_print ("flags 0x%08x\n", GST_FLAGS (pad)); -} - static GstElement* create_element (gchar *padname, GstPadDirection dir) { @@ -30,29 +24,34 @@ main (int argc, gchar *argv[]) GstElement *element2; GstPad *pad; long usage1; - gint i; + gint i, iters; gst_init (&argc, &argv); - g_print ("creating new element\n"); - element = gst_element_new (); + if (argc == 2) + iters = atoi (argv[1]); + else + iters = ITERS; + + + g_print ("starting element with pad test with %d iterations\n", iters); usage1 = vmsize(); - pad = gst_pad_new ("sink", GST_PAD_SINK); - print_pad_props (pad); - gst_element_add_pad (element, pad); - print_pad_props (pad); - - g_print ("unref new element %ld\n", vmsize()-usage1); + element = create_element ("sink", GST_PAD_SINK); + pad = gst_element_get_pad (element, "sink"); + 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); - for (i=0; i #define ITERS 100000 +#include #include "mem.h" -static void -print_object_props (GstObject *object) -{ - g_print ("name %s\n", gst_object_get_name (object)); - g_print ("flags 0x%08lx\n", GST_FLAGS (object)); -} - int main (int argc, gchar *argv[]) { - GstObject *object; - long usage1, usage2; - gint i; + GstObject *object, *object2; + long usage1; + gint i, iters; gst_init (&argc, &argv); - g_print ("creating new object\n"); - object = gst_object_new (); - usage1 = vmsize(); - print_object_props (object); - g_print ("unref new object %ld\n", vmsize()-usage1); - gst_object_unref (object); + if (argc == 2) + iters = atoi (argv[1]); + else + iters = ITERS; + + g_print ("starting test with %d iterations\n", iters); + usage1 = vmsize(); + object = gst_object_new (); + gst_object_unref (object); + g_print ("create/unref new object %ld\n", vmsize()-usage1); + + for (i=0; i #define ITERS 100000 +#include #include "mem.h" -static void -print_pad_props (GstPad *pad) -{ - g_print ("name %s\n", gst_pad_get_name (pad)); - g_print ("flags 0x%08x\n", GST_FLAGS (pad)); -} - int main (int argc, gchar *argv[]) { @@ -17,90 +11,89 @@ main (int argc, gchar *argv[]) GstPad *pad2; GstPadTemplate *padtempl; long usage1; - gint i; + gint i, iters; gst_init (&argc, &argv); - g_print ("creating new pad\n"); - pad = gst_pad_new ("padname", GST_PAD_SINK); - usage1 = vmsize(); - print_pad_props (pad); - g_print ("unref new pad %ld\n", vmsize()-usage1); - gst_object_unref (GST_OBJECT (pad)); + if (argc == 2) + iters = atoi (argv[1]); + else + iters = ITERS; + + g_print ("starting pad test\n"); + usage1 = vmsize(); + + pad = gst_pad_new ("padname", GST_PAD_SINK); + gst_object_unref (GST_OBJECT (pad)); + g_print ("create/unref new pad %ld\n", vmsize()-usage1); + + for (i=0; i #define ITERS 100000 +#include #include "mem.h" -static void -print_element_props (GstElement *element) -{ - g_print ("name %s\n", gst_element_get_name (element)); - g_print ("flags 0x%08x\n", GST_FLAGS (element)); -} - int main (int argc, gchar *argv[]) { GstElement *element; - long usage1, usage2; - gint i; + long usage1; + gint i, iters; gst_init (&argc, &argv); - g_print ("creating new element\n"); - element = gst_element_new (); - usage1 = vmsize(); - print_element_props (element); - g_print ("unref new element %ld\n", vmsize()-usage1); - gst_object_unref (GST_OBJECT (element)); + if (argc == 2) + iters = atoi (argv[1]); + else + iters = ITERS; + + g_print ("starting test\n"); + usage1 = vmsize(); + + element = gst_element_new (); + gst_object_unref (GST_OBJECT (element)); + g_print ("create/unref new element %ld\n", vmsize()-usage1); + + for (i=0; i #define ITERS 100000 +#include #include "mem.h" -static void -print_pad_props (GstPad *pad) -{ - g_print ("name %s\n", gst_pad_get_name (pad)); - g_print ("flags 0x%08x\n", GST_FLAGS (pad)); -} - static GstElement* create_element (gchar *padname, GstPadDirection dir) { @@ -30,29 +24,34 @@ main (int argc, gchar *argv[]) GstElement *element2; GstPad *pad; long usage1; - gint i; + gint i, iters; gst_init (&argc, &argv); - g_print ("creating new element\n"); - element = gst_element_new (); + if (argc == 2) + iters = atoi (argv[1]); + else + iters = ITERS; + + + g_print ("starting element with pad test with %d iterations\n", iters); usage1 = vmsize(); - pad = gst_pad_new ("sink", GST_PAD_SINK); - print_pad_props (pad); - gst_element_add_pad (element, pad); - print_pad_props (pad); - - g_print ("unref new element %ld\n", vmsize()-usage1); + element = create_element ("sink", GST_PAD_SINK); + pad = gst_element_get_pad (element, "sink"); + 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); - for (i=0; i #define ITERS 100000 +#include #include "mem.h" -static void -print_object_props (GstObject *object) -{ - g_print ("name %s\n", gst_object_get_name (object)); - g_print ("flags 0x%08lx\n", GST_FLAGS (object)); -} - int main (int argc, gchar *argv[]) { - GstObject *object; - long usage1, usage2; - gint i; + GstObject *object, *object2; + long usage1; + gint i, iters; gst_init (&argc, &argv); - g_print ("creating new object\n"); - object = gst_object_new (); - usage1 = vmsize(); - print_object_props (object); - g_print ("unref new object %ld\n", vmsize()-usage1); - gst_object_unref (object); + if (argc == 2) + iters = atoi (argv[1]); + else + iters = ITERS; + + g_print ("starting test with %d iterations\n", iters); + usage1 = vmsize(); + object = gst_object_new (); + gst_object_unref (object); + g_print ("create/unref new object %ld\n", vmsize()-usage1); + + for (i=0; i #define ITERS 100000 +#include #include "mem.h" -static void -print_pad_props (GstPad *pad) -{ - g_print ("name %s\n", gst_pad_get_name (pad)); - g_print ("flags 0x%08x\n", GST_FLAGS (pad)); -} - int main (int argc, gchar *argv[]) { @@ -17,90 +11,89 @@ main (int argc, gchar *argv[]) GstPad *pad2; GstPadTemplate *padtempl; long usage1; - gint i; + gint i, iters; gst_init (&argc, &argv); - g_print ("creating new pad\n"); - pad = gst_pad_new ("padname", GST_PAD_SINK); - usage1 = vmsize(); - print_pad_props (pad); - g_print ("unref new pad %ld\n", vmsize()-usage1); - gst_object_unref (GST_OBJECT (pad)); + if (argc == 2) + iters = atoi (argv[1]); + else + iters = ITERS; + + g_print ("starting pad test\n"); + usage1 = vmsize(); + + pad = gst_pad_new ("padname", GST_PAD_SINK); + gst_object_unref (GST_OBJECT (pad)); + g_print ("create/unref new pad %ld\n", vmsize()-usage1); + + for (i=0; i