check/Makefile.am: add per-test valgrind targets
authorThomas Vander Stichele <thomas@apestaart.org>
Tue, 12 Jul 2005 12:20:01 +0000 (12:20 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Tue, 12 Jul 2005 12:20:01 +0000 (12:20 +0000)
Original commit message from CVS:

* check/Makefile.am:
add per-test valgrind targets
* check/gst-libs/gdp.c: (GST_START_TEST),
(gst_data_protocol_suite), (main):
clean up

ChangeLog
check/Makefile.am
check/gst-libs/gdp.c
tests/check/Makefile.am
tests/check/libs/gdp.c

index 61f04ab..eb77308 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
 2005-07-12  Thomas Vander Stichele  <thomas at apestaart dot org>
 
        * check/Makefile.am:
+         add per-test valgrind targets
+       * check/gst-libs/gdp.c: (GST_START_TEST),
+       (gst_data_protocol_suite), (main):
+         clean up
+
+2005-07-12  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+       * check/Makefile.am:
          instate more valgrindable tests
        * check/elements/gstfakesrc.c: (chain_func), (event_func),
        (GST_START_TEST), (fakesrc_suite):
index 4271ee1..b2f31ba 100644 (file)
@@ -1,7 +1,9 @@
+CHECK_REGISTRY=$(top_builddir)/check/test-registry.xml
+
 TESTS_ENVIRONMENT=\
        GST_PLUGIN_PATH_ONLY=yes \
        GST_PLUGIN_PATH=$(top_builddir)/gst \
-       GST_REGISTRY=$(top_builddir)/check/test-registry.xml
+       GST_REGISTRY=$(CHECK_REGISTRY)
 
 plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
 
@@ -22,6 +24,10 @@ clean-local:
          rm -rf $$i; \
        done
 
+$(CHECK_REGISTRY):
+       $(TESTS_ENVIRONMENT)                                    \
+       $(top_builddir)/tools/gst-register
+
 # FIXME: it'd be nicer to run the versioned register, but in that case
 # "make dist" complains about not finding gst-register-0.9.c
 TESTS = $(top_builddir)/tools/gst-register     \
@@ -73,8 +79,7 @@ TESTS_TO_FIX =                                        \
        gst/gstsystemclock                      \
        gst/gsttag                              \
        pipelines/cleanup                       \
-       pipelines/simple_launch_lines           \
-       gst-libs/gdp
+       pipelines/simple_launch_lines
 
 # these need fixing because the threads cause segfaults under valgrind
 TESTS_THREADED =                               \
@@ -95,16 +100,41 @@ check-local-disabled:
        @true
 endif
 
-valgrind:
+# valgrind any given test by running make test.valgrind
+%.valgrind: % $(CHECK_REGISTRY)
+       @$(TESTS_ENVIRONMENT)                                   \
+       libtool --mode=execute                                  \
+       $(VALGRIND_PATH) -q --suppressions=$(srcdir)/gst.supp   \
+       --tool=memcheck --trace-children=yes                    \
+       $*
+
+# valgrind all tests
+valgrind: $(TESTS)
+       @echo "Valgrinding tests ..."
+       $(TESTS_ENVIRONMENT) $(top_builddir)/tools/gst-register
+       @failed=0;                                                      \
+       for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
+               make $$t.valgrind;                                      \
+               if test "$$?" -ne 0; then                               \
+                        echo "Valgrind error for test $$t";            \
+                       failed=`expr $$failed + 1`;                     \
+                fi;                                                    \
+       done;                                                           \
+       if test "$$failed" -ne 0; then                                  \
+               echo "$$failed tests had leaks under valgrind";         \
+               false;                                                  \
+       fi
+
+valgrindy: $(TESTS)
        @echo "Valgrinding tests ..."
        $(TESTS_ENVIRONMENT) $(top_builddir)/tools/gst-register
        @failed=0;                                                      \
        for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
                $(TESTS_ENVIRONMENT)                                    \
-               CK_FORK=no                                              \
                libtool --mode=execute                                  \
                $(VALGRIND_PATH) -q --suppressions=$(srcdir)/gst.supp   \
-               --tool=memcheck $$t;                                    \
+               --tool=memcheck --trace-children=yes                    \
+               $$t;                                                    \
                if test "$$?" -ne 0; then                               \
                         echo "Valgrind error for test $$t";            \
                        failed=`expr $$failed + 1`;                     \
@@ -115,3 +145,4 @@ valgrind:
                false;                                                  \
        fi
 
+
index 0af1ead..aa1b334 100644 (file)
@@ -81,7 +81,8 @@ GST_START_TEST (test_conversion)
       "GST_WRITE_UINT64_BE: memcmp failed");
 }
 
-GST_END_TEST
+GST_END_TEST;
+
 /* test creation of header from buffer and back again */
 GST_START_TEST (test_buffer)
 {
@@ -138,10 +139,14 @@ GST_START_TEST (test_buffer)
   fail_unless (GST_BUFFER_FLAG_IS_SET (newbuffer, GST_BUFFER_FLAG_IN_CAPS),
       "GST_BUFFER_IN_CAPS flag should have been copied !");
 
+  /* clean up */
+  gst_buffer_unref (buffer);
+  gst_buffer_unref (newbuffer);
   g_free (header);
 }
 
-GST_END_TEST
+GST_END_TEST;
+
 GST_START_TEST (test_caps)
 {
   gchar *string, *newstring;
@@ -164,16 +169,21 @@ GST_START_TEST (test_caps)
       "Could not validate packet");
   newcaps = gst_dp_caps_from_packet (header_length, header, payload);
   fail_unless (newcaps != NULL, "Could not create caps from packet");
-  //g_return_val_if_fail (GST_IS_CAPS (newcaps), -1);
+  fail_unless (GST_IS_CAPS (newcaps));
   newstring = gst_caps_to_string (newcaps);
   g_message ("Received caps: %s\n", newstring);
   fail_unless (strcmp (string, newstring) == 0,
       "Created caps do not match original caps");
+
+  /* cleanup */
+  g_free (header);
+  g_free (payload);
   g_free (string);
   g_free (newstring);
 }
 
-GST_END_TEST
+GST_END_TEST;
+
 GST_START_TEST (test_event)
 {
   GstEvent *send;
@@ -196,6 +206,10 @@ GST_START_TEST (test_event)
       "Received event is not EOS");
   fail_unless (GST_EVENT_TIMESTAMP (receive) == GST_SECOND,
       "EOS timestamp is not 1.0 sec");
+
+  /* clean up */
+  g_free (header);
+  g_free (payload);
   gst_event_unref (send);
   gst_event_unref (receive);
 
@@ -214,6 +228,10 @@ GST_START_TEST (test_event)
       "Received event is not flush");
   fail_unless (GST_EVENT_TIMESTAMP (receive) == GST_SECOND * 2,
       "Flush timestamp is not 2.0 sec");
+
+  /* clean up */
+  g_free (header);
+  g_free (payload);
   gst_event_unref (send);
   gst_event_unref (receive);
 
@@ -237,11 +255,18 @@ GST_START_TEST (test_event)
       "Seek format is not time");
   fail_unless (GST_EVENT_SEEK_OFFSET (receive) == GST_SECOND,
       "Seek offset is not 1.0 sec");
+
+  /* clean up */
+  g_free (header);
+  g_free (payload);
   gst_event_unref (send);
   gst_event_unref (receive);
 }
-GST_END_TEST Suite *
-gst_object_suite (void)
+
+GST_END_TEST;
+
+Suite *
+gst_data_protocol_suite (void)
 {
   Suite *s = suite_create ("data protocol");
   TCase *tc_chain = tcase_create ("general");
@@ -260,7 +285,7 @@ main (int argc, char **argv)
 {
   int nf;
 
-  Suite *s = gst_object_suite ();
+  Suite *s = gst_data_protocol_suite ();
   SRunner *sr = srunner_create (s);
 
   gst_check_init (&argc, &argv);
index 4271ee1..b2f31ba 100644 (file)
@@ -1,7 +1,9 @@
+CHECK_REGISTRY=$(top_builddir)/check/test-registry.xml
+
 TESTS_ENVIRONMENT=\
        GST_PLUGIN_PATH_ONLY=yes \
        GST_PLUGIN_PATH=$(top_builddir)/gst \
-       GST_REGISTRY=$(top_builddir)/check/test-registry.xml
+       GST_REGISTRY=$(CHECK_REGISTRY)
 
 plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
 
@@ -22,6 +24,10 @@ clean-local:
          rm -rf $$i; \
        done
 
+$(CHECK_REGISTRY):
+       $(TESTS_ENVIRONMENT)                                    \
+       $(top_builddir)/tools/gst-register
+
 # FIXME: it'd be nicer to run the versioned register, but in that case
 # "make dist" complains about not finding gst-register-0.9.c
 TESTS = $(top_builddir)/tools/gst-register     \
@@ -73,8 +79,7 @@ TESTS_TO_FIX =                                        \
        gst/gstsystemclock                      \
        gst/gsttag                              \
        pipelines/cleanup                       \
-       pipelines/simple_launch_lines           \
-       gst-libs/gdp
+       pipelines/simple_launch_lines
 
 # these need fixing because the threads cause segfaults under valgrind
 TESTS_THREADED =                               \
@@ -95,16 +100,41 @@ check-local-disabled:
        @true
 endif
 
-valgrind:
+# valgrind any given test by running make test.valgrind
+%.valgrind: % $(CHECK_REGISTRY)
+       @$(TESTS_ENVIRONMENT)                                   \
+       libtool --mode=execute                                  \
+       $(VALGRIND_PATH) -q --suppressions=$(srcdir)/gst.supp   \
+       --tool=memcheck --trace-children=yes                    \
+       $*
+
+# valgrind all tests
+valgrind: $(TESTS)
+       @echo "Valgrinding tests ..."
+       $(TESTS_ENVIRONMENT) $(top_builddir)/tools/gst-register
+       @failed=0;                                                      \
+       for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
+               make $$t.valgrind;                                      \
+               if test "$$?" -ne 0; then                               \
+                        echo "Valgrind error for test $$t";            \
+                       failed=`expr $$failed + 1`;                     \
+                fi;                                                    \
+       done;                                                           \
+       if test "$$failed" -ne 0; then                                  \
+               echo "$$failed tests had leaks under valgrind";         \
+               false;                                                  \
+       fi
+
+valgrindy: $(TESTS)
        @echo "Valgrinding tests ..."
        $(TESTS_ENVIRONMENT) $(top_builddir)/tools/gst-register
        @failed=0;                                                      \
        for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
                $(TESTS_ENVIRONMENT)                                    \
-               CK_FORK=no                                              \
                libtool --mode=execute                                  \
                $(VALGRIND_PATH) -q --suppressions=$(srcdir)/gst.supp   \
-               --tool=memcheck $$t;                                    \
+               --tool=memcheck --trace-children=yes                    \
+               $$t;                                                    \
                if test "$$?" -ne 0; then                               \
                         echo "Valgrind error for test $$t";            \
                        failed=`expr $$failed + 1`;                     \
@@ -115,3 +145,4 @@ valgrind:
                false;                                                  \
        fi
 
+
index 0af1ead..aa1b334 100644 (file)
@@ -81,7 +81,8 @@ GST_START_TEST (test_conversion)
       "GST_WRITE_UINT64_BE: memcmp failed");
 }
 
-GST_END_TEST
+GST_END_TEST;
+
 /* test creation of header from buffer and back again */
 GST_START_TEST (test_buffer)
 {
@@ -138,10 +139,14 @@ GST_START_TEST (test_buffer)
   fail_unless (GST_BUFFER_FLAG_IS_SET (newbuffer, GST_BUFFER_FLAG_IN_CAPS),
       "GST_BUFFER_IN_CAPS flag should have been copied !");
 
+  /* clean up */
+  gst_buffer_unref (buffer);
+  gst_buffer_unref (newbuffer);
   g_free (header);
 }
 
-GST_END_TEST
+GST_END_TEST;
+
 GST_START_TEST (test_caps)
 {
   gchar *string, *newstring;
@@ -164,16 +169,21 @@ GST_START_TEST (test_caps)
       "Could not validate packet");
   newcaps = gst_dp_caps_from_packet (header_length, header, payload);
   fail_unless (newcaps != NULL, "Could not create caps from packet");
-  //g_return_val_if_fail (GST_IS_CAPS (newcaps), -1);
+  fail_unless (GST_IS_CAPS (newcaps));
   newstring = gst_caps_to_string (newcaps);
   g_message ("Received caps: %s\n", newstring);
   fail_unless (strcmp (string, newstring) == 0,
       "Created caps do not match original caps");
+
+  /* cleanup */
+  g_free (header);
+  g_free (payload);
   g_free (string);
   g_free (newstring);
 }
 
-GST_END_TEST
+GST_END_TEST;
+
 GST_START_TEST (test_event)
 {
   GstEvent *send;
@@ -196,6 +206,10 @@ GST_START_TEST (test_event)
       "Received event is not EOS");
   fail_unless (GST_EVENT_TIMESTAMP (receive) == GST_SECOND,
       "EOS timestamp is not 1.0 sec");
+
+  /* clean up */
+  g_free (header);
+  g_free (payload);
   gst_event_unref (send);
   gst_event_unref (receive);
 
@@ -214,6 +228,10 @@ GST_START_TEST (test_event)
       "Received event is not flush");
   fail_unless (GST_EVENT_TIMESTAMP (receive) == GST_SECOND * 2,
       "Flush timestamp is not 2.0 sec");
+
+  /* clean up */
+  g_free (header);
+  g_free (payload);
   gst_event_unref (send);
   gst_event_unref (receive);
 
@@ -237,11 +255,18 @@ GST_START_TEST (test_event)
       "Seek format is not time");
   fail_unless (GST_EVENT_SEEK_OFFSET (receive) == GST_SECOND,
       "Seek offset is not 1.0 sec");
+
+  /* clean up */
+  g_free (header);
+  g_free (payload);
   gst_event_unref (send);
   gst_event_unref (receive);
 }
-GST_END_TEST Suite *
-gst_object_suite (void)
+
+GST_END_TEST;
+
+Suite *
+gst_data_protocol_suite (void)
 {
   Suite *s = suite_create ("data protocol");
   TCase *tc_chain = tcase_create ("general");
@@ -260,7 +285,7 @@ main (int argc, char **argv)
 {
   int nf;
 
-  Suite *s = gst_object_suite ();
+  Suite *s = gst_data_protocol_suite ();
   SRunner *sr = srunner_create (s);
 
   gst_check_init (&argc, &argv);