check: optionally check env var for us to make sure test env is set up
[platform/upstream/gstreamer.git] / libs / gst / check / gstcheck.h
1 /* GStreamer
2  *
3  * Common code for GStreamer unittests
4  *
5  * Copyright (C) <2004> Thomas Vander Stichele <thomas at apestaart dot org>
6  * Copyright (C) <2008> Thijs Vermeir <thijsvermeir@gmail.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23
24 #ifndef __GST_CHECK_H__
25 #define __GST_CHECK_H__
26
27 #include <signal.h>
28 #include <string.h>
29 #include <stdlib.h>
30 #include <math.h>
31
32 #include <gst/check/internal-check.h>
33
34 #include <gst/gst.h>
35
36 G_BEGIN_DECLS
37
38 GST_DEBUG_CATEGORY_EXTERN (check_debug);
39 #define GST_CAT_DEFAULT check_debug
40
41 /* logging function for tests
42  * a test uses g_message() to log a debug line
43  * a gst unit test can be run with GST_TEST_DEBUG env var set to see the
44  * messages
45  */
46 extern gboolean _gst_check_threads_running;
47 extern gboolean _gst_check_raised_critical;
48 extern gboolean _gst_check_raised_warning;
49 extern gboolean _gst_check_expecting_log;
50
51 /* global variables used in test methods */
52 extern GList * buffers;
53
54 extern GMutex check_mutex;
55 extern GCond check_cond;
56
57 typedef struct
58 {
59   const char *name;
60   int size;
61   int abi_size;
62 }
63 GstCheckABIStruct;
64
65 void gst_check_init (int *argc, char **argv[]);
66
67 GstFlowReturn gst_check_chain_func (GstPad * pad, GstObject * parent, GstBuffer * buffer);
68
69 void gst_check_message_error (GstMessage * message, GstMessageType type,
70     GQuark domain, gint code);
71
72 GstElement *gst_check_setup_element (const gchar * factory);
73 void gst_check_teardown_element (GstElement * element);
74 GstPad *gst_check_setup_src_pad (GstElement * element,
75     GstStaticPadTemplate * tmpl);
76 GstPad *gst_check_setup_src_pad_from_template (GstElement * element,
77     GstPadTemplate * tmpl);
78 GstPad * gst_check_setup_src_pad_by_name (GstElement * element,
79           GstStaticPadTemplate * tmpl, const gchar *name);
80 GstPad * gst_check_setup_src_pad_by_name_from_template (GstElement * element,
81           GstPadTemplate * tmpl, const gchar *name);
82 GstPad *gst_check_setup_sink_pad (GstElement * element,
83     GstStaticPadTemplate * tmpl);
84 GstPad *gst_check_setup_sink_pad_from_template (GstElement * element,
85     GstPadTemplate * tmpl);
86 GstPad * gst_check_setup_sink_pad_by_name (GstElement * element, 
87           GstStaticPadTemplate * tmpl, const gchar *name);
88 GstPad * gst_check_setup_sink_pad_by_name_from_template (GstElement * element, 
89           GstPadTemplate * tmpl, const gchar *name);
90 void gst_check_teardown_pad_by_name (GstElement * element, const gchar *name);
91 void gst_check_teardown_src_pad (GstElement * element);
92 void gst_check_drop_buffers (void);
93 void gst_check_caps_equal (GstCaps * caps1, GstCaps * caps2);
94 void gst_check_buffer_data (GstBuffer * buffer, gconstpointer data, gsize size);
95 void gst_check_element_push_buffer_list (const gchar * element_name,
96     GList * buffer_in, GstCaps * caps_in, GList * buffer_out,
97     GstCaps * caps_out, GstFlowReturn last_flow_return);
98 void gst_check_element_push_buffer (const gchar * element_name,
99     GstBuffer * buffer_in, GstCaps * caps_in, GstBuffer * buffer_out,
100     GstCaps *caps_out);
101 void gst_check_teardown_sink_pad (GstElement * element);
102 void gst_check_abi_list (GstCheckABIStruct list[], gboolean have_abi_sizes);
103 gint gst_check_run_suite (Suite * suite, const gchar * name,
104     const gchar * fname);
105 void gst_check_setup_events (GstPad * srcpad, GstElement * element,
106     GstCaps * caps, GstFormat format);
107 void gst_check_setup_events_with_stream_id (GstPad * srcpad,
108     GstElement * element, GstCaps * caps, GstFormat format,
109     const gchar * stream_id);
110 void gst_check_objects_destroyed_on_unref (gpointer object_to_unref, gpointer first_object, ...)
111   G_GNUC_NULL_TERMINATED;
112 void gst_check_object_destroyed_on_unref (gpointer object_to_unref);
113
114 #define fail_unless_message_error(msg, domain, code)            \
115 gst_check_message_error (msg, GST_MESSAGE_ERROR,                \
116   GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code)
117 #define assert_message_error(m, d, c) fail_unless_message_error(m, d, c)
118
119 #ifdef GST_CHECK_TEST_ENVIRONMENT_BEACON
120 #define GST_DO_CHECK_TEST_ENVIRONMENT \
121 G_STMT_START {                        \
122   if (g_getenv (GST_CHECK_TEST_ENVIRONMENT_BEACON) == NULL) \
123     fail ("Test environment not set up correctly! Expected environment " \
124        "variable '%s' to be set.", GST_CHECK_TEST_ENVIRONMENT_BEACON); \
125 } G_STMT_END
126
127 #else
128 #define GST_DO_CHECK_TEST_ENVIRONMENT /* nothing to check */
129 #endif
130
131 /**
132  * GST_START_TEST:
133  * @__testname: test function name
134  *
135  * wrapper for checks START_TEST
136  */
137 /**
138  * GST_END_TEST:
139  *
140  * wrapper for checks END_TEST
141  */
142 #define GST_START_TEST(__testname) \
143 static void __testname (int __i__)\
144 {\
145   GST_DEBUG ("test start"); \
146   GST_DO_CHECK_TEST_ENVIRONMENT; \
147   tcase_fn_start (""# __testname, __FILE__, __LINE__);
148
149 #define GST_END_TEST GST_LOG ("cleaning up tasks"); \
150                      gst_task_cleanup_all (); \
151                      END_TEST
152
153 /* additional fail macros */
154 /**
155  * fail_unless_equals_int:
156  * @a: a #gint value or expression
157  * @b: a #gint value or expression
158  *
159  * This macro checks that @a and @b are equal and aborts if this is not the
160  * case, printing both expressions and the values they evaluated to. This
161  * macro is for use in unit tests.
162  */
163 #define fail_unless_equals_int(a, b)                                    \
164 G_STMT_START {                                                          \
165   int first = a;                                                        \
166   int second = b;                                                       \
167   fail_unless(first == second,                                          \
168     "'" #a "' (%d) is not equal to '" #b"' (%d)", first, second);       \
169 } G_STMT_END;
170 /**
171  * assert_equals_int:
172  * @a: a #gint value or expression
173  * @b: a #gint value or expression
174  *
175  * This macro checks that @a and @b are equal and aborts if this is not the
176  * case, printing both expressions and the values they evaluated to. This
177  * macro is for use in unit tests.
178  */
179 #define assert_equals_int(a, b) fail_unless_equals_int(a, b)
180
181 /**
182  * fail_unless_equals_int_hex:
183  * @a: a #gint value or expression
184  * @b: a #gint value or expression
185  *
186  * This macro checks that @a and @b are equal and aborts if this is not the
187  * case, printing both expressions and the values they evaluated to in
188  * hexadecimal format. This macro is for use in unit tests.
189  *
190  * Since: 1.2
191  */
192 #define fail_unless_equals_int_hex(a, b)                                \
193 G_STMT_START {                                                          \
194   int first = a;                                                        \
195   int second = b;                                                       \
196   fail_unless(first == second,                                          \
197     "'" #a "' (0x%08x) is not equal to '" #b"' (0x%08x)", first, second);\
198 } G_STMT_END;
199
200 /**
201  * assert_equals_int_hex:
202  * @a: a #gint value or expression
203  * @b: a #gint value or expression
204  *
205  * This macro checks that @a and @b are equal and aborts if this is not the
206  * case, printing both expressions and the values they evaluated to in
207  * hexadecimal format. This macro is for use in unit tests.
208  *
209  * Since: 1.2
210  */
211 #define assert_equals_int_hex(a, b) fail_unless_equals_int_hex(a, b)
212
213 /**
214  * fail_unless_equals_int64:
215  * @a: a #gint64 value or expression
216  * @b: a #gint64 value or expression
217  *
218  * This macro checks that @a and @b are equal and aborts if this is not the
219  * case, printing both expressions and the values they evaluated to. This
220  * macro is for use in unit tests.
221  */
222 #define fail_unless_equals_int64(a, b)                                  \
223 G_STMT_START {                                                          \
224   gint64 first = a;                                                     \
225   gint64 second = b;                                                    \
226   fail_unless(first == second,                                          \
227     "'" #a "' (%" G_GINT64_FORMAT") is not equal to '" #b"' (%"         \
228     G_GINT64_FORMAT")", first, second);                                 \
229 } G_STMT_END;
230 /**
231  * assert_equals_int64:
232  * @a: a #gint64 value or expression
233  * @b: a #gint64 value or expression
234  *
235  * This macro checks that @a and @b are equal and aborts if this is not the
236  * case, printing both expressions and the values they evaluated to. This
237  * macro is for use in unit tests.
238  */
239 #define assert_equals_int64(a, b) fail_unless_equals_int64(a, b)
240
241 /**
242  * fail_unless_equals_int64_hex:
243  * @a: a #gint64 value or expression
244  * @b: a #gint64 value or expression
245  *
246  * This macro checks that @a and @b are equal and aborts if this is not the
247  * case, printing both expressions and the values they evaluated to in
248  * hexadecimal format. This macro is for use in unit tests.
249  *
250  * Since: 1.2
251  */
252 #define fail_unless_equals_int64_hex(a, b)                              \
253 G_STMT_START {                                                          \
254   gint64 first = a;                                                     \
255   gint64 second = b;                                                    \
256   fail_unless(first == second,                                          \
257     "'" #a "' (0x%016x) is not equal to '" #b"' (0x%016x)", first, second);\
258 } G_STMT_END;
259 /**
260  * assert_equals_int64_hex:
261  * @a: a #gint64 value or expression
262  * @b: a #gint64 value or expression
263  *
264  * This macro checks that @a and @b are equal and aborts if this is not the
265  * case, printing both expressions and the values they evaluated to in
266  * hexadecimal format. This macro is for use in unit tests.
267  *
268  * Since: 1.2
269  */
270 #define assert_equals_int64_hex(a,b) fail_unless_equals_int64_hex(a,b)
271
272 /**
273  * fail_unless_equals_uint64:
274  * @a: a #guint64 value or expression
275  * @b: a #guint64 value or expression
276  *
277  * This macro checks that @a and @b are equal and aborts if this is not the
278  * case, printing both expressions and the values they evaluated to. This
279  * macro is for use in unit tests.
280  */
281 #define fail_unless_equals_uint64(a, b)                                 \
282 G_STMT_START {                                                          \
283   guint64 first = a;                                                    \
284   guint64 second = b;                                                   \
285   fail_unless(first == second,                                          \
286     "'" #a "' (%" G_GUINT64_FORMAT ") is not equal to '" #b"' (%"       \
287     G_GUINT64_FORMAT ")", first, second);                               \
288 } G_STMT_END;
289 /**
290  * assert_equals_uint64:
291  * @a: a #guint64 value or expression
292  * @b: a #guint64 value or expression
293  *
294  * This macro checks that @a and @b are equal and aborts if this is not the
295  * case, printing both expressions and the values they evaluated to. This
296  * macro is for use in unit tests.
297  */
298 #define assert_equals_uint64(a, b) fail_unless_equals_uint64(a, b)
299
300 /**
301  * fail_unless_equals_uint64_hex:
302  * @a: a #gint64 value or expression
303  * @b: a #gint64 value or expression
304  *
305  * This macro checks that @a and @b are equal and aborts if this is not the
306  * case, printing both expressions and the values they evaluated to in
307  * hexadecimal format. This macro is for use in unit tests.
308  *
309  * Since: 1.2
310  */
311 #define fail_unless_equals_uint64_hex(a, b)                             \
312 G_STMT_START {                                                          \
313   guint64 first = a;                                                    \
314   guint64 second = b;                                                   \
315   fail_unless(first == second,                                          \
316     "'" #a "' (0x%016x) is not equal to '" #b"' (0x%016x)", first, second);\
317 } G_STMT_END;
318 /**
319  * assert_equals_uint64_hex:
320  * @a: a #guint64 value or expression
321  * @b: a #guint64 value or expression
322  *
323  * This macro checks that @a and @b are equal and aborts if this is not the
324  * case, printing both expressions and the values they evaluated to in
325  * hexadecimal format. This macro is for use in unit tests.
326  *
327  * Since: 1.2
328  */
329 #define assert_equals_uint64_hex(a,b) fail_unless_equals_uint64_hex(a,b)
330
331 /**
332  * fail_unless_equals_string:
333  * @a: a string literal or expression
334  * @b: a string literal or expression
335  *
336  * This macro checks that @a and @b are equal (as per strcmp) and aborts if
337  * this is not the case, printing both expressions and the values they
338  * evaluated to. This macro is for use in unit tests.
339  */
340 #define fail_unless_equals_string(a, b)                             \
341 G_STMT_START {                                                      \
342   const gchar * first = a;                                          \
343   const gchar * second = b;                                         \
344   fail_unless(g_strcmp0 (first, second) == 0,                          \
345     "'" #a "' (%s) is not equal to '" #b"' (%s)", first, second);   \
346 } G_STMT_END;
347 /**
348  * assert_equals_string:
349  * @a: a string literal or expression
350  * @b: a string literal or expression
351  *
352  * This macro checks that @a and @b are equal (as per strcmp) and aborts if
353  * this is not the case, printing both expressions and the values they
354  * evaluated to. This macro is for use in unit tests.
355  */
356 #define assert_equals_string(a, b) fail_unless_equals_string(a, b)
357
358 /**
359  * fail_unless_equals_float:
360  * @a: a #gdouble or #gfloat value or expression
361  * @b: a #gdouble or #gfloat value or expression
362  *
363  * This macro checks that @a and @b are (almost) equal and aborts if this
364  * is not the case, printing both expressions and the values they evaluated
365  * to. This macro is for use in unit tests.
366  */
367 #define fail_unless_equals_float(a, b)                            \
368 G_STMT_START {                                                    \
369   double first = a;                                               \
370   double second = b;                                              \
371   /* This will only work for 'normal' values and values around 0, \
372    * which should be good enough for our purposes here */         \
373   fail_unless(fabs (first - second) < 0.0000001,                  \
374     "'" #a "' (%g) is not equal to '" #b "' (%g)", first, second);\
375 } G_STMT_END;
376
377 /**
378  * assert_equals_float:
379  * @a: a #gdouble or #gfloat value or expression
380  * @b: a #gdouble or #gfloat value or expression
381  *
382  * This macro checks that @a and @b are (almost) equal and aborts if this
383  * is not the case, printing both expressions and the values they evaluated
384  * to. This macro is for use in unit tests.
385  */
386 #define assert_equals_float(a, b) fail_unless_equals_float(a, b)
387
388 /**
389  * fail_unless_equals_pointer:
390  * @a: a pointer value or expression
391  * @b: a pointer value or expression
392  *
393  * This macro checks that @a and @b are equal and aborts if this
394  * is not the case, printing both expressions and the values they
395  * evaluated to. This macro is for use in unit tests.
396  *
397  * Since: 1.2
398  */
399 #define fail_unless_equals_pointer(a, b)                          \
400 G_STMT_START {                                                    \
401   gpointer first = a;                                             \
402   gpointer second = b;                                            \
403   fail_unless(first == second,                                    \
404     "'" #a "' (%p) is not equal to '" #b "' (%p)", first, second);\
405 } G_STMT_END;
406
407 /**
408  * assert_equals_pointer:
409  * @a: a pointer value or expression
410  * @b: a pointer value or expression
411  *
412  * This macro checks that @a and @b are equal and aborts if this
413  * is not the case, printing both expressions and the values they
414  * evaluated to. This macro is for use in unit tests.
415  *
416  * Since: 1.2
417  */
418 #define assert_equals_pointer(a, b) fail_unless_equals_pointer(a, b)
419
420 /***
421  * thread test macros and variables
422  */
423 extern GList *thread_list;
424 extern GMutex mutex;
425 extern GCond start_cond;       /* used to notify main thread of thread startups */
426 extern GCond sync_cond;        /* used to synchronize all threads and main thread */
427
428 #define MAIN_START_THREADS(count, function, data)               \
429 MAIN_INIT();                                                    \
430 MAIN_START_THREAD_FUNCTIONS(count, function, data);             \
431 MAIN_SYNCHRONIZE();
432
433 #define MAIN_INIT()                     \
434 G_STMT_START {                          \
435   g_mutex_init (&mutex);                \
436   g_cond_init (&start_cond);            \
437   g_cond_init (&sync_cond);             \
438   _gst_check_threads_running = TRUE;    \
439 } G_STMT_END;
440
441 #define MAIN_START_THREAD_FUNCTIONS(count, function, data)      \
442 G_STMT_START {                                                  \
443   int i;                                                        \
444   for (i = 0; i < count; ++i) {                                 \
445     MAIN_START_THREAD_FUNCTION (i, function, data);             \
446   }                                                             \
447 } G_STMT_END;
448
449 #define MAIN_START_THREAD_FUNCTION(i, function, data)           \
450 G_STMT_START {                                                  \
451     GThread *thread = NULL;                                     \
452     GST_DEBUG ("MAIN: creating thread %d", i);                  \
453     g_mutex_lock (&mutex);                                      \
454     thread = g_thread_try_new ("gst-check",                     \
455         (GThreadFunc) function, data, NULL);                    \
456     /* wait for thread to signal us that it's ready */          \
457     GST_DEBUG ("MAIN: waiting for thread %d", i);               \
458     g_cond_wait (&start_cond, &mutex);                          \
459     g_mutex_unlock (&mutex);                                    \
460                                                                 \
461     thread_list = g_list_append (thread_list, thread);          \
462 } G_STMT_END;
463
464
465 #define MAIN_SYNCHRONIZE()              \
466 G_STMT_START {                          \
467   GST_DEBUG ("MAIN: synchronizing");    \
468   g_cond_broadcast (&sync_cond);        \
469   GST_DEBUG ("MAIN: synchronized");     \
470 } G_STMT_END;
471
472 #define MAIN_STOP_THREADS()                                     \
473 G_STMT_START {                                                  \
474   _gst_check_threads_running = FALSE;                           \
475                                                                 \
476   /* join all threads */                                        \
477   GST_DEBUG ("MAIN: joining");                                  \
478   g_list_foreach (thread_list, (GFunc) g_thread_join, NULL);    \
479   g_list_free (thread_list);                                    \
480   thread_list = NULL;                                           \
481   g_mutex_clear (&mutex);                                       \
482   g_cond_clear (&start_cond);                                   \
483   g_cond_clear (&sync_cond);                                    \
484   GST_DEBUG ("MAIN: joined");                                   \
485 } G_STMT_END;
486
487 #define THREAD_START()                                          \
488 THREAD_STARTED();                                               \
489 THREAD_SYNCHRONIZE();
490
491 #define THREAD_STARTED()                                        \
492 G_STMT_START {                                                  \
493   /* signal main thread that we started */                      \
494   GST_DEBUG ("THREAD %p: started", g_thread_self ());           \
495   g_mutex_lock (&mutex);                                        \
496   g_cond_signal (&start_cond);                                  \
497 } G_STMT_END;
498
499 #define THREAD_SYNCHRONIZE()                                    \
500 G_STMT_START {                                                  \
501   /* synchronize everyone */                                    \
502   GST_DEBUG ("THREAD %p: syncing", g_thread_self ());           \
503   fail_if (g_mutex_trylock (&mutex),                            \
504       "bug in unit test, mutex should be locked at this point");\
505   g_cond_wait (&sync_cond, &mutex);                             \
506   GST_DEBUG ("THREAD %p: synced", g_thread_self ());            \
507   g_mutex_unlock (&mutex);                                      \
508 } G_STMT_END;
509
510 #define THREAD_SWITCH()                                         \
511 G_STMT_START {                                                  \
512   /* a minimal sleep is a context switch */                     \
513   g_usleep (1);                                                 \
514 } G_STMT_END;
515
516 #define THREAD_TEST_RUNNING()   (!!_gst_check_threads_running)
517
518 /* additional assertions */
519 #define ASSERT_CRITICAL(code)                                   \
520 G_STMT_START {                                                  \
521   _gst_check_expecting_log = TRUE;                              \
522   _gst_check_raised_critical = FALSE;                           \
523   code;                                                         \
524   if (!_gst_check_raised_critical)                              \
525     _ck_assert_failed (__FILE__, __LINE__,                      \
526         "Expected g_critical, got nothing", NULL);              \
527   _gst_check_expecting_log = FALSE;                             \
528 } G_STMT_END
529
530 #define ASSERT_WARNING(code)                                    \
531 G_STMT_START {                                                  \
532   _gst_check_expecting_log = TRUE;                              \
533   _gst_check_raised_warning = FALSE;                            \
534   code;                                                         \
535   if (!_gst_check_raised_warning)                               \
536     _ck_assert_failed (__FILE__, __LINE__,                      \
537         "Expected g_warning, got nothing", NULL);               \
538   _gst_check_expecting_log = FALSE;                             \
539 } G_STMT_END
540
541
542 #define ASSERT_OBJECT_REFCOUNT(object, name, value)             \
543 G_STMT_START {                                                  \
544   int rc;                                                       \
545   rc = GST_OBJECT_REFCOUNT_VALUE (object);                      \
546   fail_unless (rc == value,                                     \
547       "%s (%p) refcount is %d instead of %d",                   \
548       name, object, rc, value);                                 \
549 } G_STMT_END
550
551 #define ASSERT_OBJECT_REFCOUNT_BETWEEN(object, name, lower, upper)      \
552 G_STMT_START {                                                          \
553   int rc = GST_OBJECT_REFCOUNT_VALUE (object);                          \
554   int lo = lower;                                                       \
555   int hi = upper;                                                       \
556                                                                         \
557   fail_unless (rc >= lo,                                                \
558       "%s (%p) refcount %d is smaller than %d",                         \
559       name, object, rc, lo);                                            \
560   fail_unless (rc <= hi,                                                \
561       "%s (%p) refcount %d is bigger than %d",                          \
562       name, object, rc, hi);                                            \
563 } G_STMT_END
564
565
566 #define ASSERT_CAPS_REFCOUNT(caps, name, value)                 \
567         ASSERT_MINI_OBJECT_REFCOUNT(caps, name, value)
568
569 #define ASSERT_BUFFER_REFCOUNT(buffer, name, value)             \
570         ASSERT_MINI_OBJECT_REFCOUNT(buffer, name, value)
571
572 #define ASSERT_MINI_OBJECT_REFCOUNT(miniobj, name, value)       \
573 G_STMT_START {                                                  \
574   int rc;                                                       \
575   rc = GST_MINI_OBJECT_REFCOUNT_VALUE (miniobj);                \
576   fail_unless (rc == value,                                     \
577                name " (%p) refcount is %d instead of %d", miniobj, rc, value); \
578 } G_STMT_END
579
580 #define ASSERT_SET_STATE(element, state, ret)                   \
581 fail_unless (gst_element_set_state (GST_ELEMENT(element),       \
582   state) == ret,                                                \
583   "could not change state to " #state);
584
585 #define GST_CHECK_MAIN(name)                                    \
586 int main (int argc, char **argv)                                \
587 {                                                               \
588   Suite *s;                                                     \
589   gst_check_init (&argc, &argv);                                \
590   s = name ## _suite ();                                        \
591   return gst_check_run_suite (s, # name, __FILE__);             \
592 }
593
594 /* Hack to allow run-time selection of unit tests to run via the
595  * GST_CHECKS environment variable (test function names globs, comma
596  * separated), or GST_CHECKS_IGNORE with the same semantics */
597
598 gboolean _gst_check_run_test_func (const gchar * func_name);
599
600 static inline void
601 __gst_tcase_add_test (TCase * tc, TFun tf, const char * fname, int signal,
602     int allowed_exit_value, int start, int end)
603 {
604   if (_gst_check_run_test_func (fname)) {
605     _tcase_add_test (tc, tf, fname, signal, allowed_exit_value, start, end);
606   }
607 }
608
609 #define _tcase_add_test __gst_tcase_add_test
610
611 /* A special variant to add broken tests. These are normally skipped, but can be 
612  * forced to run via GST_CHECKS */
613 #define tcase_skip_broken_test(chain,test_func) \
614 G_STMT_START {                                                  \
615   const char *env = g_getenv ("GST_CHECKS");                    \
616                                                                 \
617   if (env != NULL && g_pattern_match_simple (env, G_STRINGIFY (test_func))) {   \
618     tcase_add_test(chain,test_func);                            \
619   } else {                                                      \
620     g_printerr ("FIXME: skipping test %s because it's broken\n", G_STRINGIFY (test_func)); \
621   } \
622 } G_STMT_END
623
624 G_END_DECLS
625
626 #endif /* __GST_CHECK_H__ */