check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* Common code for GStreamer unittests
|
|
|
|
*
|
|
|
|
* Copyright (C) <2004> 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
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_CHECK_H__
|
|
|
|
#define __GST_CHECK_H__
|
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2007-06-14 15:56:03 +00:00
|
|
|
#include <math.h>
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
|
|
|
|
#include <check.h>
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2007-01-12 12:48:25 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2005-07-09 16:36:18 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (check_debug);
|
|
|
|
#define GST_CAT_DEFAULT check_debug
|
|
|
|
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
/* 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
|
|
|
|
* messages
|
|
|
|
*/
|
|
|
|
extern gboolean _gst_check_threads_running;
|
|
|
|
extern gboolean _gst_check_raised_critical;
|
2005-09-09 14:34:43 +00:00
|
|
|
extern gboolean _gst_check_raised_warning;
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
extern gboolean _gst_check_expecting_log;
|
|
|
|
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
/* global variables used in test methods */
|
|
|
|
GList * buffers;
|
|
|
|
|
2006-06-02 16:41:02 +00:00
|
|
|
GMutex *check_mutex;
|
|
|
|
GCond *check_cond;
|
|
|
|
|
2006-06-06 13:48:20 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
int size;
|
|
|
|
int abi_size;
|
|
|
|
}
|
|
|
|
GstCheckABIStruct;
|
|
|
|
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
void gst_check_init (int *argc, char **argv[]);
|
|
|
|
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
GstFlowReturn gst_check_chain_func (GstPad *pad, GstBuffer *buffer);
|
|
|
|
|
2005-08-20 20:15:53 +00:00
|
|
|
void gst_check_message_error (GstMessage *message, GstMessageType type, GQuark domain, gint code);
|
|
|
|
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
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);
|
|
|
|
void gst_check_teardown_src_pad (GstElement *element);
|
|
|
|
GstPad * gst_check_setup_sink_pad (GstElement *element,
|
|
|
|
GstStaticPadTemplate *template, GstCaps *caps);
|
|
|
|
void gst_check_teardown_sink_pad (GstElement *element);
|
2006-06-06 13:48:20 +00:00
|
|
|
void gst_check_abi_list (GstCheckABIStruct list[], gboolean have_abi_sizes);
|
2006-07-01 20:54:25 +00:00
|
|
|
gint gst_check_run_suite (Suite *suite, const gchar *name, const gchar *fname);
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
|
2005-08-20 20:15:53 +00:00
|
|
|
#define fail_unless_message_error(msg, domain, code) \
|
|
|
|
gst_check_message_error (msg, GST_MESSAGE_ERROR, \
|
|
|
|
GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code)
|
2006-07-02 22:05:48 +00:00
|
|
|
#define assert_message_error(m, d, c) fail_unless_message_error(m, d, c)
|
2005-08-20 20:15:53 +00:00
|
|
|
|
2007-08-13 13:33:07 +00:00
|
|
|
/**
|
|
|
|
* GST_START_TEST:
|
|
|
|
* @__testname: test function name
|
|
|
|
*
|
|
|
|
* wrapper for checks START_TEST
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* GST_END_TEST:
|
|
|
|
*
|
|
|
|
* wrapper for checks END_TEST
|
2005-07-09 16:36:18 +00:00
|
|
|
*/
|
2007-12-20 09:20:27 +00:00
|
|
|
#if CHECK_MAJOR_VERSION > 0 || \
|
|
|
|
(CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION > 9) || \
|
|
|
|
(CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION == 9 && CHECK_MICRO_VERSION > 3)
|
2005-07-09 16:36:18 +00:00
|
|
|
#define GST_START_TEST(__testname) \
|
2006-11-20 11:11:20 +00:00
|
|
|
static void __testname (int __i__)\
|
2005-07-09 16:36:18 +00:00
|
|
|
{\
|
|
|
|
GST_DEBUG ("test start"); \
|
|
|
|
tcase_fn_start (""# __testname, __FILE__, __LINE__);
|
|
|
|
|
|
|
|
#define GST_END_TEST END_TEST
|
2006-11-20 11:11:20 +00:00
|
|
|
#else
|
|
|
|
#define GST_START_TEST(__testname) \
|
|
|
|
static void __testname ()\
|
|
|
|
{\
|
|
|
|
GST_DEBUG ("test start"); \
|
|
|
|
tcase_fn_start (""# __testname, __FILE__, __LINE__);
|
|
|
|
|
|
|
|
#define GST_END_TEST END_TEST
|
|
|
|
#endif
|
|
|
|
|
2005-07-09 16:36:18 +00:00
|
|
|
|
2005-08-20 20:15:53 +00:00
|
|
|
/* additional fail macros */
|
2007-06-14 11:56:44 +00:00
|
|
|
/**
|
|
|
|
* fail_unless_equals_int:
|
|
|
|
* @a: a #gint value or expression
|
|
|
|
* @b: a #gint 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.
|
|
|
|
*/
|
2005-08-20 20:15:53 +00:00
|
|
|
#define fail_unless_equals_int(a, b) \
|
|
|
|
G_STMT_START { \
|
|
|
|
int first = a; \
|
|
|
|
int second = b; \
|
|
|
|
fail_unless(first == second, \
|
|
|
|
"'" #a "' (%d) is not equal to '" #b"' (%d)", first, second); \
|
|
|
|
} G_STMT_END;
|
2007-06-14 11:56:44 +00:00
|
|
|
/**
|
|
|
|
* assert_equals_int:
|
|
|
|
* @a: a #gint value or expression
|
|
|
|
* @b: a #gint 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.
|
|
|
|
*/
|
2006-07-02 22:05:48 +00:00
|
|
|
#define assert_equals_int(a, b) fail_unless_equals_int(a, b)
|
2005-08-20 20:15:53 +00:00
|
|
|
|
2007-06-14 11:56:44 +00:00
|
|
|
/**
|
|
|
|
* fail_unless_equals_uint64:
|
|
|
|
* @a: a #guint64 value or expression
|
|
|
|
* @b: a #guint64 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.
|
|
|
|
*/
|
2005-08-25 16:27:44 +00:00
|
|
|
#define fail_unless_equals_uint64(a, b) \
|
|
|
|
G_STMT_START { \
|
|
|
|
guint64 first = a; \
|
|
|
|
guint64 second = b; \
|
|
|
|
fail_unless(first == second, \
|
|
|
|
"'" #a "' (%" G_GUINT64_FORMAT ") is not equal to '" #b"' (%" \
|
|
|
|
G_GUINT64_FORMAT ")", first, second); \
|
|
|
|
} G_STMT_END;
|
2007-06-14 11:56:44 +00:00
|
|
|
/**
|
|
|
|
* assert_equals_uint64:
|
|
|
|
* @a: a #guint64 value or expression
|
|
|
|
* @b: a #guint64 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.
|
|
|
|
*/
|
2006-07-02 22:05:48 +00:00
|
|
|
#define assert_equals_uint64(a, b) fail_unless_equals_uint64(a, b)
|
2005-08-25 16:27:44 +00:00
|
|
|
|
2007-06-14 11:56:44 +00:00
|
|
|
/**
|
|
|
|
* fail_unless_equals_string:
|
|
|
|
* @a: a string literal or expression
|
|
|
|
* @b: a string literal or expression
|
|
|
|
*
|
|
|
|
* This macro checks that @a and @b are equal (as per strcmp) 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.
|
|
|
|
*/
|
2006-08-15 18:29:22 +00:00
|
|
|
#define fail_unless_equals_string(a, b) \
|
|
|
|
G_STMT_START { \
|
|
|
|
const gchar * first = a; \
|
|
|
|
const gchar * second = b; \
|
|
|
|
fail_unless(strcmp (first, second) == 0, \
|
|
|
|
"'" #a "' (%s) is not equal to '" #b"' (%s)", first, second); \
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
} G_STMT_END;
|
2007-06-14 11:56:44 +00:00
|
|
|
/**
|
|
|
|
* assert_equals_string:
|
|
|
|
* @a: a string literal or expression
|
|
|
|
* @b: a string literal or expression
|
|
|
|
*
|
|
|
|
* This macro checks that @a and @b are equal (as per strcmp) 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.
|
|
|
|
*/
|
2006-07-02 22:05:48 +00:00
|
|
|
#define assert_equals_string(a, b) fail_unless_equals_string(a, b)
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
|
2007-06-14 11:56:44 +00:00
|
|
|
/**
|
|
|
|
* fail_unless_equals_float:
|
|
|
|
* @a: a #gdouble or #gfloat value or expression
|
|
|
|
* @b: a #gdouble or #gfloat value or expression
|
|
|
|
*
|
2007-06-14 15:56:03 +00:00
|
|
|
* This macro checks that @a and @b are (almost) 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.
|
2007-06-14 11:56:44 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.14
|
|
|
|
*/
|
|
|
|
#define fail_unless_equals_float(a, b) \
|
|
|
|
G_STMT_START { \
|
|
|
|
double first = a; \
|
|
|
|
double second = b; \
|
2007-06-14 15:56:03 +00:00
|
|
|
/* This will only work for 'normal' values and values around 0, \
|
|
|
|
* which should be good enough for our purposes here */ \
|
|
|
|
fail_unless(fabs (first - second) < 0.0000001, \
|
|
|
|
"'" #a "' (%g) is not equal to '" #b "' (%g)", first, second);\
|
2007-06-14 11:56:44 +00:00
|
|
|
} G_STMT_END;
|
2007-06-14 15:56:03 +00:00
|
|
|
|
2007-06-14 11:56:44 +00:00
|
|
|
/**
|
|
|
|
* assert_equals_float:
|
|
|
|
* @a: a #gdouble or #gfloat value or expression
|
|
|
|
* @b: a #gdouble or #gfloat value or expression
|
|
|
|
*
|
2007-06-14 15:56:03 +00:00
|
|
|
* This macro checks that @a and @b are (almost) 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.
|
2007-06-14 11:56:44 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.14
|
|
|
|
*/
|
|
|
|
#define assert_equals_float(a, b) fail_unless_equals_float(a, b)
|
|
|
|
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
/***
|
|
|
|
* thread test macros and variables
|
|
|
|
*/
|
|
|
|
extern GList *thread_list;
|
|
|
|
extern GMutex *mutex;
|
|
|
|
extern GCond *start_cond; /* used to notify main thread of thread startups */
|
|
|
|
extern GCond *sync_cond; /* used to synchronize all threads and main thread */
|
|
|
|
|
|
|
|
#define MAIN_START_THREADS(count, function, data) \
|
|
|
|
MAIN_INIT(); \
|
|
|
|
MAIN_START_THREAD_FUNCTIONS(count, function, data); \
|
|
|
|
MAIN_SYNCHRONIZE();
|
|
|
|
|
|
|
|
#define MAIN_INIT() \
|
|
|
|
G_STMT_START { \
|
|
|
|
_gst_check_threads_running = TRUE; \
|
|
|
|
\
|
|
|
|
mutex = g_mutex_new (); \
|
|
|
|
start_cond = g_cond_new (); \
|
|
|
|
sync_cond = g_cond_new (); \
|
|
|
|
} G_STMT_END;
|
|
|
|
|
|
|
|
#define MAIN_START_THREAD_FUNCTIONS(count, function, data) \
|
|
|
|
G_STMT_START { \
|
|
|
|
int i; \
|
|
|
|
for (i = 0; i < count; ++i) { \
|
|
|
|
MAIN_START_THREAD_FUNCTION (i, function, data); \
|
|
|
|
} \
|
|
|
|
} G_STMT_END;
|
|
|
|
|
|
|
|
#define MAIN_START_THREAD_FUNCTION(i, function, data) \
|
|
|
|
G_STMT_START { \
|
|
|
|
GThread *thread = NULL; \
|
2005-11-24 18:40:58 +00:00
|
|
|
GST_DEBUG ("MAIN: creating thread %d", i); \
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
g_mutex_lock (mutex); \
|
|
|
|
thread = g_thread_create ((GThreadFunc) function, data, \
|
|
|
|
TRUE, NULL); \
|
|
|
|
/* wait for thread to signal us that it's ready */ \
|
2005-11-24 18:40:58 +00:00
|
|
|
GST_DEBUG ("MAIN: waiting for thread %d", i); \
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
g_cond_wait (start_cond, mutex); \
|
|
|
|
g_mutex_unlock (mutex); \
|
|
|
|
\
|
|
|
|
thread_list = g_list_append (thread_list, thread); \
|
|
|
|
} G_STMT_END;
|
|
|
|
|
|
|
|
|
|
|
|
#define MAIN_SYNCHRONIZE() \
|
|
|
|
G_STMT_START { \
|
2005-11-24 18:40:58 +00:00
|
|
|
GST_DEBUG ("MAIN: synchronizing"); \
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
g_cond_broadcast (sync_cond); \
|
2005-11-24 18:40:58 +00:00
|
|
|
GST_DEBUG ("MAIN: synchronized"); \
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
} G_STMT_END;
|
|
|
|
|
|
|
|
#define MAIN_STOP_THREADS() \
|
|
|
|
G_STMT_START { \
|
|
|
|
_gst_check_threads_running = FALSE; \
|
|
|
|
\
|
|
|
|
/* join all threads */ \
|
2005-11-24 18:40:58 +00:00
|
|
|
GST_DEBUG ("MAIN: joining"); \
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
g_list_foreach (thread_list, (GFunc) g_thread_join, NULL); \
|
2005-11-24 18:40:58 +00:00
|
|
|
GST_DEBUG ("MAIN: joined"); \
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
} G_STMT_END;
|
|
|
|
|
|
|
|
#define THREAD_START() \
|
|
|
|
THREAD_STARTED(); \
|
|
|
|
THREAD_SYNCHRONIZE();
|
|
|
|
|
|
|
|
#define THREAD_STARTED() \
|
|
|
|
G_STMT_START { \
|
|
|
|
/* signal main thread that we started */ \
|
2005-11-24 18:40:58 +00:00
|
|
|
GST_DEBUG ("THREAD %p: started", g_thread_self ()); \
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
g_mutex_lock (mutex); \
|
|
|
|
g_cond_signal (start_cond); \
|
|
|
|
} G_STMT_END;
|
|
|
|
|
|
|
|
#define THREAD_SYNCHRONIZE() \
|
|
|
|
G_STMT_START { \
|
|
|
|
/* synchronize everyone */ \
|
2005-11-24 18:40:58 +00:00
|
|
|
GST_DEBUG ("THREAD %p: syncing", g_thread_self ()); \
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
g_cond_wait (sync_cond, mutex); \
|
2005-11-24 18:40:58 +00:00
|
|
|
GST_DEBUG ("THREAD %p: synced", g_thread_self ()); \
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
g_mutex_unlock (mutex); \
|
|
|
|
} G_STMT_END;
|
|
|
|
|
|
|
|
#define THREAD_SWITCH() \
|
|
|
|
G_STMT_START { \
|
|
|
|
/* a minimal sleep is a context switch */ \
|
|
|
|
g_usleep (1); \
|
|
|
|
} G_STMT_END;
|
|
|
|
|
|
|
|
#define THREAD_TEST_RUNNING() (_gst_check_threads_running == TRUE)
|
|
|
|
|
2005-07-09 16:36:18 +00:00
|
|
|
/* additional assertions */
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
#define ASSERT_CRITICAL(code) \
|
|
|
|
G_STMT_START { \
|
|
|
|
_gst_check_expecting_log = TRUE; \
|
|
|
|
_gst_check_raised_critical = FALSE; \
|
|
|
|
code; \
|
|
|
|
_fail_unless (_gst_check_raised_critical, __FILE__, __LINE__, \
|
2006-08-15 09:33:24 +00:00
|
|
|
"Expected g_critical, got nothing", NULL); \
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
_gst_check_expecting_log = FALSE; \
|
|
|
|
} G_STMT_END
|
|
|
|
|
2005-09-09 14:34:43 +00:00
|
|
|
#define ASSERT_WARNING(code) \
|
|
|
|
G_STMT_START { \
|
|
|
|
_gst_check_expecting_log = TRUE; \
|
|
|
|
_gst_check_raised_warning = FALSE; \
|
|
|
|
code; \
|
|
|
|
_fail_unless (_gst_check_raised_warning, __FILE__, __LINE__, \
|
2006-08-15 09:33:24 +00:00
|
|
|
"Expected g_warning, got nothing", NULL); \
|
2005-09-09 14:34:43 +00:00
|
|
|
_gst_check_expecting_log = FALSE; \
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
|
2005-06-19 00:52:31 +00:00
|
|
|
#define ASSERT_OBJECT_REFCOUNT(object, name, value) \
|
|
|
|
G_STMT_START { \
|
|
|
|
int rc; \
|
|
|
|
rc = GST_OBJECT_REFCOUNT_VALUE (object); \
|
|
|
|
fail_unless (rc == value, \
|
2005-08-21 15:01:18 +00:00
|
|
|
"%s (%p) refcount is %d instead of %d", \
|
|
|
|
name, object, rc, value); \
|
2005-06-19 00:52:31 +00:00
|
|
|
} G_STMT_END
|
|
|
|
|
2005-08-22 09:25:51 +00:00
|
|
|
#define ASSERT_OBJECT_REFCOUNT_BETWEEN(object, name, lower, upper) \
|
|
|
|
G_STMT_START { \
|
|
|
|
int rc = GST_OBJECT_REFCOUNT_VALUE (object); \
|
|
|
|
int lo = lower; \
|
|
|
|
int hi = upper; \
|
|
|
|
\
|
|
|
|
fail_unless (rc >= lo, \
|
|
|
|
"%s (%p) refcount %d is smaller than %d", \
|
|
|
|
name, object, rc, lo); \
|
|
|
|
fail_unless (rc <= hi, \
|
|
|
|
"%s (%p) refcount %d is bigger than %d", \
|
|
|
|
name, object, rc, hi); \
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
|
2005-06-19 00:52:31 +00:00
|
|
|
#define ASSERT_CAPS_REFCOUNT(caps, name, value) \
|
2005-07-11 18:41:49 +00:00
|
|
|
ASSERT_MINI_OBJECT_REFCOUNT(caps, name, value)
|
|
|
|
|
2005-08-14 22:29:07 +00:00
|
|
|
#define ASSERT_BUFFER_REFCOUNT(buffer, name, value) \
|
|
|
|
ASSERT_MINI_OBJECT_REFCOUNT(buffer, name, value)
|
|
|
|
|
2005-07-11 18:41:49 +00:00
|
|
|
#define ASSERT_MINI_OBJECT_REFCOUNT(caps, name, value) \
|
2005-06-19 00:52:31 +00:00
|
|
|
G_STMT_START { \
|
|
|
|
int rc; \
|
|
|
|
rc = GST_MINI_OBJECT_REFCOUNT_VALUE (caps); \
|
|
|
|
fail_unless (rc == value, \
|
|
|
|
name " refcount is %d instead of %d", rc, value);\
|
|
|
|
} G_STMT_END
|
|
|
|
|
2006-05-10 15:49:30 +00:00
|
|
|
#define ASSERT_SET_STATE(element, state, ret) \
|
|
|
|
fail_unless (gst_element_set_state (element, \
|
|
|
|
state) == ret, \
|
|
|
|
"could not change state to " #state);
|
check/: Added checks.
Original commit message from CVS:
* check/.cvsignore:
* check/Makefile.am:
* check/gst-libs/.cvsignore:
* check/gst-libs/gdp.c: (START_TEST), (gst_object_suite), (main):
* check/gst/.cvsignore:
* check/gst/gstbus.c: (pound_bus_with_messages), (pull_messages),
(START_TEST), (gstbus_suite), (main):
* check/gst/gstcaps.c: (START_TEST), (gst_caps_suite), (main):
* check/gst/gstdata.c: (START_TEST), (thread_ref), (thread_unref),
(gst_data_suite), (main):
* check/gst/gstiterator.c: (make_list_of_ints), (START_TEST),
(add_fold_func), (gstiterator_suite), (main):
* check/gst/gstobject.c: (gst_fake_object_get_type), (START_TEST),
(thread_name_object), (thread_name_object_default),
(gst_object_name_compare), (gst_object_suite), (main):
* check/gst/gstpad.c: (START_TEST), (thread_link_unlink),
(gst_pad_suite), (main):
* check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_init):
* check/gstcheck.h:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (START_TEST), (simple_launch_lines_suite), (main):
Added checks.
2005-03-07 18:33:37 +00:00
|
|
|
|
2006-07-01 20:54:25 +00:00
|
|
|
#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__); \
|
|
|
|
}
|
2007-01-12 12:48:25 +00:00
|
|
|
|
2007-10-16 16:12:36 +00:00
|
|
|
/* Hack to allow run-time selection of unit tests to run via the
|
|
|
|
* GST_CHECKS environment variable (test function names, comma-separated) */
|
|
|
|
|
|
|
|
gboolean _gst_check_run_test_func (const gchar * func_name);
|
|
|
|
|
2007-12-20 09:20:27 +00:00
|
|
|
#if CHECK_MAJOR_VERSION > 0 || \
|
|
|
|
(CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION > 9) || \
|
|
|
|
(CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION == 9 && CHECK_MICRO_VERSION > 3)
|
2007-10-16 16:12:36 +00:00
|
|
|
static inline void
|
2007-12-20 09:20:27 +00:00
|
|
|
__gst_tcase_add_test (TCase * tc, TFun tf, const char * fname, int signal,
|
|
|
|
int start, int end)
|
2007-10-16 16:12:36 +00:00
|
|
|
{
|
2007-12-20 09:20:27 +00:00
|
|
|
if (_gst_check_run_test_func (fname)) {
|
|
|
|
_tcase_add_test (tc, tf, fname, signal, start, end);
|
2007-10-16 16:12:36 +00:00
|
|
|
}
|
|
|
|
}
|
2007-12-20 09:20:27 +00:00
|
|
|
#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
|
2007-10-16 16:12:36 +00:00
|
|
|
|
2007-12-20 09:20:27 +00:00
|
|
|
#define _tcase_add_test __gst_tcase_add_test
|
2007-10-16 16:12:36 +00:00
|
|
|
|
2007-01-12 12:48:25 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_CHECK_H__ */
|