index f486aa266f22a0df023947c2882937d72c2238d7..5e3f9950407467f3cee44d91a9e5e758ace5ebb9 100644 (file)
GST_DEBUG_CATEGORY_EXTERN (check_debug);
#define GST_CAT_DEFAULT check_debug
-#define __CHECK_VERSION_LATER_THAN(major,minor,micro) \
- (CHECK_MAJOR_VERSION > major || \
- (CHECK_MAJOR_VERSION == (major) && CHECK_MINOR_VERSION > (minor)) || \
- (CHECK_MAJOR_VERSION == (major) && CHECK_MINOR_VERSION == (minor) && \
- CHECK_MICRO_VERSION > (micro)))
-
/* logging function for tests
* a test uses g_message() to log a debug line
* a gst unit test can be run with GST_TEST_DEBUG env var set to see the
typedef struct
{
- char *name;
+ const char *name;
int size;
int abi_size;
}
GstElement *gst_check_setup_element (const gchar * factory);
void gst_check_teardown_element (GstElement * element);
GstPad *gst_check_setup_src_pad (GstElement * element,
- GstStaticPadTemplate * template, GstCaps * caps);
+ GstStaticPadTemplate * tmpl, GstCaps * caps);
GstPad * gst_check_setup_src_pad_by_name (GstElement * element,
- GstStaticPadTemplate * template, gchar *name);
+ GstStaticPadTemplate * tmpl, const gchar *name);
GstPad * gst_check_setup_sink_pad_by_name (GstElement * element,
- GstStaticPadTemplate * template, gchar *name);
-void gst_check_teardown_pad_by_name (GstElement * element, gchar *name);
+ GstStaticPadTemplate * tmpl, const gchar *name);
+void gst_check_teardown_pad_by_name (GstElement * element, const gchar *name);
void gst_check_teardown_src_pad (GstElement * element);
-void gst_check_drop_buffers ();
+void gst_check_drop_buffers (void);
void gst_check_caps_equal (GstCaps * caps1, GstCaps * caps2);
void gst_check_element_push_buffer_list (const gchar * element_name,
GList * buffer_in, GList * buffer_out, GstFlowReturn last_flow_return);
void gst_check_element_push_buffer (const gchar * element_name,
GstBuffer * buffer_in, GstBuffer * buffer_out);
GstPad *gst_check_setup_sink_pad (GstElement * element,
- GstStaticPadTemplate * template, GstCaps * caps);
+ GstStaticPadTemplate * tmpl, 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,
*
* wrapper for checks END_TEST
*/
-#if __CHECK_VERSION_LATER_THAN(0,9,3)
#define GST_START_TEST(__testname) \
static void __testname (int __i__)\
{\
GST_DEBUG ("test start"); \
tcase_fn_start (""# __testname, __FILE__, __LINE__);
-#define GST_END_TEST gst_task_cleanup_all (); \
- END_TEST
-#else
-#define GST_START_TEST(__testname) \
-static void __testname ()\
-{\
- GST_DEBUG ("test start"); \
- tcase_fn_start (""# __testname, __FILE__, __LINE__);
-
-#define GST_END_TEST gst_task_cleanup_all (); \
+#define GST_END_TEST GST_LOG ("cleaning up tasks"); \
+ gst_task_cleanup_all (); \
END_TEST
-#endif
-
/* additional fail macros */
/**
*/
#define assert_equals_int(a, b) fail_unless_equals_int(a, b)
+/**
+ * fail_unless_equals_int64:
+ * @a: a #gint64 value or expression
+ * @b: a #gint64 value or expression
+ *
+ * This macro checks that @a and @b are equal and aborts if this is not the
+ * case, printing both expressions and the values they evaluated to. This
+ * macro is for use in unit tests.
+ */
+#define fail_unless_equals_int64(a, b) \
+G_STMT_START { \
+ gint64 first = a; \
+ gint64 second = b; \
+ fail_unless(first == second, \
+ "'" #a "' (%" G_GINT64_FORMAT") is not equal to '" #b"' (%" \
+ G_GINT64_FORMAT")", first, second); \
+} G_STMT_END;
+/**
+ * assert_equals_int64:
+ * @a: a #gint64 value or expression
+ * @b: a #gint64 value or expression
+ *
+ * This macro checks that @a and @b are equal and aborts if this is not the
+ * case, printing both expressions and the values they evaluated to. This
+ * macro is for use in unit tests.
+ */
+#define assert_equals_int64(a, b) fail_unless_equals_int64(a, b)
+
/**
* fail_unless_equals_uint64:
* @a: a #guint64 value or expression
G_STMT_START { \
const gchar * first = a; \
const gchar * second = b; \
- fail_unless(strcmp (first, second) == 0, \
+ fail_unless(g_strcmp0 (first, second) == 0, \
"'" #a "' (%s) is not equal to '" #b"' (%s)", first, second); \
} G_STMT_END;
/**
MAIN_START_THREAD_FUNCTIONS(count, function, data); \
MAIN_SYNCHRONIZE();
+#if GLIB_CHECK_VERSION (2, 31, 0)
+#define g_thread_create gst_g_thread_create
+static inline GThread *
+gst_g_thread_create (GThreadFunc func, gpointer data, gboolean joinable,
+ GError **error)
+{
+ GThread *thread = g_thread_try_new ("gst-check", func, data, error);
+ if (!joinable)
+ g_thread_unref (thread);
+ return thread;
+}
+#define g_mutex_new gst_g_mutex_new
+static inline GMutex *
+gst_g_mutex_new (void)
+{
+ GMutex *mutex = g_slice_new (GMutex);
+ g_mutex_init (mutex);
+ return mutex;
+}
+#define g_mutex_free gst_g_mutex_free
+static inline void
+gst_g_mutex_free (GMutex *mutex)
+{
+ g_mutex_clear (mutex);
+ g_slice_free (GMutex, mutex);
+}
+#define g_static_rec_mutex_init gst_g_static_rec_mutex_init
+static inline void
+gst_g_static_rec_mutex_init (GStaticRecMutex *mutex)
+{
+ static const GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
+
+ *mutex = init_mutex;
+}
+#define g_cond_new gst_g_cond_new
+static inline GCond *
+gst_g_cond_new (void)
+{
+ GCond *cond = g_slice_new (GCond);
+ g_cond_init (cond);
+ return cond;
+}
+#define g_cond_free gst_g_cond_free
+static inline void
+gst_g_cond_free (GCond *cond)
+{
+ g_cond_clear (cond);
+ g_slice_free (GCond, cond);
+}
+#define g_cond_timed_wait gst_g_cond_timed_wait
+static inline gboolean
+gst_g_cond_timed_wait (GCond *cond, GMutex *mutex, GTimeVal *abs_time)
+{
+ gint64 end_time;
+
+ if (abs_time == NULL) {
+ g_cond_wait (cond, mutex);
+ return TRUE;
+ }
+
+ end_time = abs_time->tv_sec;
+ end_time *= 1000000;
+ end_time += abs_time->tv_usec;
+
+ /* would be nice if we had clock_rtoffset, but that didn't seem to
+ * make it into the kernel yet...
+ */
+ /* if CLOCK_MONOTONIC is not defined then g_get_montonic_time() and
+ * g_get_real_time() are returning the same clock and we'd add ~0
+ */
+ end_time += g_get_monotonic_time () - g_get_real_time ();
+ return g_cond_wait_until (cond, mutex, end_time);
+}
+#endif
+
#define MAIN_INIT() \
G_STMT_START { \
_gst_check_threads_running = TRUE; \
gboolean _gst_check_run_test_func (const gchar * func_name);
-#if __CHECK_VERSION_LATER_THAN(0,9,6)
static inline void
__gst_tcase_add_test (TCase * tc, TFun tf, const char * fname, int signal,
int allowed_exit_value, int start, int end)
_tcase_add_test (tc, tf, fname, signal, allowed_exit_value, start, end);
}
}
-#elif __CHECK_VERSION_LATER_THAN(0,9,3)
-static inline void
-__gst_tcase_add_test (TCase * tc, TFun tf, const char * fname, int signal,
- int start, int end)
-{
- if (_gst_check_run_test_func (fname)) {
- _tcase_add_test (tc, tf, fname, signal, start, end);
- }
-}
-#else
-static inline void
-__gst_tcase_add_test (TCase * tc, TFun tf, const char * fname, int signal)
-{
- if (_gst_check_run_test_func (fname)) {
- _tcase_add_test (tc, tf, fname, signal);
- }
-}
-#endif
#define _tcase_add_test __gst_tcase_add_test
-#undef __CHECK_VERSION_LATER_THAN
-
G_END_DECLS
#endif /* __GST_CHECK_H__ */