libs/gst/check/gstcheck.*: create a macro and function so that the simple unit test...
authorThomas Vander Stichele <thomas@apestaart.org>
Sat, 1 Jul 2006 20:54:25 +0000 (20:54 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Sat, 1 Jul 2006 20:54:25 +0000 (20:54 +0000)
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_run_suite):
* libs/gst/check/gstcheck.h:
create a macro and function so that the simple unit test
case can be just one macro to create main()

ChangeLog
common
libs/gst/check/gstcheck.c
libs/gst/check/gstcheck.h

index 86e2547..6731d1e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-07-01  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+       * libs/gst/check/gstcheck.c: (gst_check_run_suite):
+       * libs/gst/check/gstcheck.h:
+         create a macro and function so that the simple unit test
+         case can be just one macro to create main()
+
 2006-06-30  Tim-Philipp Müller  <tim at centricular dot net>
 
        * gst/gstbin.c: (gst_bin_restore_thyself):
diff --git a/common b/common
index 123195d..f4348ab 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 123195d3bbcc0b6e1cf867d3a180685f8766a0be
+Subproject commit f4348ab157cc5e859f287e746004c0210880969a
index a18ad57..fbcabd6 100644 (file)
@@ -2,7 +2,7 @@
  *
  * Common code for GStreamer unittests
  *
- * Copyright (C) <2004> Thomas Vander Stichele <thomas at apestaart dot org>
+ * Copyright (C) 2004,2006 Thomas Vander Stichele <thomas at apestaart dot org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -292,3 +292,23 @@ gst_check_abi_list (GstCheckABIStruct list[], gboolean have_abi_sizes)
     }
   }
 }
+
+gint
+gst_check_run_suite (Suite * suite, const gchar * name, const gchar * fname)
+{
+  gint nf;
+
+  SRunner *sr = srunner_create (suite);
+
+  if (g_getenv ("GST_CHECK_XML")) {
+    /* how lucky we are to have __FILE__ end in .c */
+    gchar *xmlfilename = g_strdup_printf ("%sheck.xml", fname);
+
+    srunner_set_xml (sr, xmlfilename);
+  }
+
+  srunner_run_all (sr, CK_NORMAL);
+  nf = srunner_ntests_failed (sr);
+  srunner_free (sr);
+  return nf;
+}
index d50a27e..69bfcf0 100644 (file)
@@ -73,8 +73,7 @@ GstPad * gst_check_setup_sink_pad (GstElement *element,
     GstStaticPadTemplate *template, GstCaps *caps);
 void gst_check_teardown_sink_pad (GstElement *element);
 void gst_check_abi_list (GstCheckABIStruct list[], gboolean have_abi_sizes);
-
-
+gint gst_check_run_suite (Suite *suite, const gchar *name, const gchar *fname);
 
 #define fail_unless_message_error(msg, domain, code)           \
 gst_check_message_error (msg, GST_MESSAGE_ERROR,               \
@@ -277,3 +276,10 @@ fail_unless (gst_element_set_state (element,                       \
 
 #endif /* __GST_CHECK_H__ */
 
+#define GST_CHECK_MAIN(name)                                   \
+int main (int argc, char **argv)                               \
+{                                                              \
+  Suite *s = name ## _suite ();                                        \
+  gst_check_init (&argc, &argv);                               \
+  return gst_check_run_suite (s, # name, __FILE__);            \
+}