check/gst/gstcaps.c: New test suite. Only one test at the moment

Original commit message from CVS:
2005-02-11  Andy Wingo  <wingo@pobox.com>

* check/gst/gstcaps.c: New test suite. Only one test at the moment
-- this is an infrastructure commit.

* check/gst/gstobject.c (main):
* check/gst/gstdata.c (main):
* check/gst-libs/gdp.c (main): Use gst_check_init() to initialize
gstreamer.

* check/gstcheck.h: Declare all variables as extern so they are
defined once in gstcheck.c.
(ASSERT_CRITICAL): New macro, asserts that the expression passed
as an argument raises one or more critical logs.

* check/gstcheck.c: Define the extern-declared variables here.
(gst_check_log_message_func, gst_check_log_critical_func): The log
function was split in two, one for messages and one for criticals.
The criticals logfunc will fail if a critical was not expected.
The messages logfunc is the same as before.
(gst_check_init): Set up all log handlers, and initialize
gstreamer too.

* check/Makefile.am: Pulled over some pieces from the old
testsuite/ directory. Don't use --gst-fatal-warnings though, we
have some new mechanisms for that.
(TESTS): Added gst/gstcaps.
This commit is contained in:
Andy Wingo 2005-02-11 12:55:16 +00:00
parent 7c0804b15c
commit 9ffa8aff27
13 changed files with 198 additions and 42 deletions

View file

@ -1,3 +1,31 @@
2005-02-11 Andy Wingo <wingo@pobox.com>
* check/gst/gstcaps.c: New test suite. Only one test at the moment
-- this is an infrastructure commit.
* check/gst/gstobject.c (main):
* check/gst/gstdata.c (main):
* check/gst-libs/gdp.c (main): Use gst_check_init() to initialize
gstreamer.
* check/gstcheck.h: Declare all variables as extern so they are
defined once in gstcheck.c.
(ASSERT_CRITICAL): New macro, asserts that the expression passed
as an argument raises one or more critical logs.
* check/gstcheck.c: Define the extern-declared variables here.
(gst_check_log_message_func, gst_check_log_critical_func): The log
function was split in two, one for messages and one for criticals.
The criticals logfunc will fail if a critical was not expected.
The messages logfunc is the same as before.
(gst_check_init): Set up all log handlers, and initialize
gstreamer too.
* check/Makefile.am: Pulled over some pieces from the old
testsuite/ directory. Don't use --gst-fatal-warnings though, we
have some new mechanisms for that.
(TESTS): Added gst/gstcaps.
2005-02-10 Wim Taymans <wim@fluendo.com>
* docs/design/part-events.txt:

View file

@ -1,4 +1,26 @@
TESTS = \
TESTS_ENVIRONMENT=\
GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/check \
GST_REGISTRY=$(top_builddir)/check/test-registry.xml
plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
# make all tests depend on the versioned gst-register
$(TESTS): $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@
# rebuild gst-register-@GST_MAJORMINOR@ if needed
# the EXEEXT is because am 1.6 complained about overrides
$(top_builddir)/tools/gst-register-@GST_MAJORMINOR@$(EXEEXT):
cd $(top_builddir)/tools && make
# override to _not_ install the test plugins
install-pluginLTLIBRARIES:
# This rule is here so make distcheck works on machines where core
# dumps have PIDs appended
CLEANFILES = core.*
TESTS = $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@ \
gst/gstcaps \
gst/gstdata \
gst/gstobject \
gst-libs/gdp

View file

@ -243,7 +243,8 @@ START_TEST (test_event)
gst_event_unref (send);
gst_event_unref (receive);
}
END_TEST Suite * gst_object_suite (void)
END_TEST Suite *
gst_object_suite (void)
{
Suite *s = suite_create ("data protocol");
TCase *tc_chain = tcase_create ("general");
@ -265,9 +266,8 @@ main (int argc, char **argv)
Suite *s = gst_object_suite ();
SRunner *sr = srunner_create (s);
gst_init (&argc, &argv);
gst_check_init (&argc, &argv);
gst_dp_init ();
gst_check_init ();
srunner_run_all (sr, CK_NORMAL);
nf = srunner_ntests_failed (sr);

View file

@ -163,7 +163,8 @@ START_TEST (test_unref_threaded)
/* final unref */
gst_data_unref (data);
}
END_TEST Suite * gst_data_suite (void)
END_TEST Suite *
gst_data_suite (void)
{
Suite *s = suite_create ("GstData");
TCase *tc_chain = tcase_create ("general");
@ -185,8 +186,7 @@ main (int argc, char **argv)
Suite *s = gst_data_suite ();
SRunner *sr = srunner_create (s);
gst_init (&argc, &argv);
gst_check_init ();
gst_check_init (&argc, &argv);
srunner_run_all (sr, CK_NORMAL);
nf = srunner_ntests_failed (sr);

View file

@ -354,8 +354,7 @@ main (int argc, char **argv)
Suite *s = gst_object_suite ();
SRunner *sr = srunner_create (s);
gst_init (&argc, &argv);
gst_check_init ();
gst_check_init (&argc, &argv);
srunner_run_all (sr, CK_NORMAL);
nf = srunner_ntests_failed (sr);

View file

@ -20,7 +20,8 @@
* Boston, MA 02111-1307, USA.
*/
#include <gst/gst.h>
#include "gstcheck.h"
/* logging function for tests
* a test uses g_message() to log a debug line
@ -28,24 +29,53 @@
* messages
*/
gboolean _gst_check_debug = FALSE;
gboolean _gst_check_threads_running = FALSE;
GList *thread_list = NULL;
GMutex *mutex;
GCond *start_cond; /* used to notify main thread of thread startups */
GCond *sync_cond; /* used to synchronize all threads and main thread */
void gst_check_log_func
gboolean _gst_check_debug = FALSE;
gboolean _gst_check_raised_critical = FALSE;
gboolean _gst_check_expecting_log = FALSE;
void gst_check_log_message_func
(const gchar * log_domain, GLogLevelFlags log_level,
const gchar * message, gpointer user_data)
{
// g_print ("HANDLER CALLED\n");
if (_gst_check_debug) {
g_print (message);
}
}
void gst_check_log_critical_func
(const gchar * log_domain, GLogLevelFlags log_level,
const gchar * message, gpointer user_data)
{
if (!_gst_check_expecting_log)
fail ("Unexpected assertion: %s", message);
if (_gst_check_debug) {
g_print (message);
}
if (log_level & G_LOG_LEVEL_CRITICAL)
_gst_check_raised_critical = TRUE;
}
/* initialize GStreamer testing */
void
gst_check_init (void)
gst_check_init (int *argc, char **argv[])
{
gst_init (argc, argv);
if (g_getenv ("GST_TEST_DEBUG"))
_gst_check_debug = TRUE;
g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, gst_check_log_func, NULL);
g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, gst_check_log_message_func,
NULL);
g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL, gst_check_log_critical_func,
NULL);
g_log_set_handler ("GStreamer", G_LOG_LEVEL_CRITICAL,
gst_check_log_critical_func, NULL);
}

View file

@ -37,17 +37,19 @@
* a gst unit test can be run with GST_TEST_DEBUG env var set to see the
* messages
*/
gboolean _gst_check_threads_running = FALSE;
extern gboolean _gst_check_threads_running;
extern gboolean _gst_check_raised_critical;
extern gboolean _gst_check_expecting_log;
void gst_check_init (void);
void gst_check_init (int *argc, char **argv[]);
/***
* thread test macros and variables
*/
GList *thread_list = NULL;
GMutex *mutex;
GCond *start_cond; /* used to notify main thread of thread startups */
GCond *sync_cond; /* used to synchronize all threads and main thread */
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(); \
@ -133,5 +135,16 @@ G_STMT_START { \
#define THREAD_TEST_RUNNING() (_gst_check_threads_running == TRUE)
#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__, \
"Expected g_critical, got nothing: '"#code"'"); \
_gst_check_expecting_log = FALSE; \
} G_STMT_END
#endif /* __GST_CHECK_H__ */

View file

@ -1,4 +1,26 @@
TESTS = \
TESTS_ENVIRONMENT=\
GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/check \
GST_REGISTRY=$(top_builddir)/check/test-registry.xml
plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
# make all tests depend on the versioned gst-register
$(TESTS): $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@
# rebuild gst-register-@GST_MAJORMINOR@ if needed
# the EXEEXT is because am 1.6 complained about overrides
$(top_builddir)/tools/gst-register-@GST_MAJORMINOR@$(EXEEXT):
cd $(top_builddir)/tools && make
# override to _not_ install the test plugins
install-pluginLTLIBRARIES:
# This rule is here so make distcheck works on machines where core
# dumps have PIDs appended
CLEANFILES = core.*
TESTS = $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@ \
gst/gstcaps \
gst/gstdata \
gst/gstobject \
gst-libs/gdp

View file

@ -163,7 +163,8 @@ START_TEST (test_unref_threaded)
/* final unref */
gst_data_unref (data);
}
END_TEST Suite * gst_data_suite (void)
END_TEST Suite *
gst_data_suite (void)
{
Suite *s = suite_create ("GstData");
TCase *tc_chain = tcase_create ("general");
@ -185,8 +186,7 @@ main (int argc, char **argv)
Suite *s = gst_data_suite ();
SRunner *sr = srunner_create (s);
gst_init (&argc, &argv);
gst_check_init ();
gst_check_init (&argc, &argv);
srunner_run_all (sr, CK_NORMAL);
nf = srunner_ntests_failed (sr);

View file

@ -354,8 +354,7 @@ main (int argc, char **argv)
Suite *s = gst_object_suite ();
SRunner *sr = srunner_create (s);
gst_init (&argc, &argv);
gst_check_init ();
gst_check_init (&argc, &argv);
srunner_run_all (sr, CK_NORMAL);
nf = srunner_ntests_failed (sr);

View file

@ -20,7 +20,8 @@
* Boston, MA 02111-1307, USA.
*/
#include <gst/gst.h>
#include "gstcheck.h"
/* logging function for tests
* a test uses g_message() to log a debug line
@ -28,24 +29,53 @@
* messages
*/
gboolean _gst_check_debug = FALSE;
gboolean _gst_check_threads_running = FALSE;
GList *thread_list = NULL;
GMutex *mutex;
GCond *start_cond; /* used to notify main thread of thread startups */
GCond *sync_cond; /* used to synchronize all threads and main thread */
void gst_check_log_func
gboolean _gst_check_debug = FALSE;
gboolean _gst_check_raised_critical = FALSE;
gboolean _gst_check_expecting_log = FALSE;
void gst_check_log_message_func
(const gchar * log_domain, GLogLevelFlags log_level,
const gchar * message, gpointer user_data)
{
// g_print ("HANDLER CALLED\n");
if (_gst_check_debug) {
g_print (message);
}
}
void gst_check_log_critical_func
(const gchar * log_domain, GLogLevelFlags log_level,
const gchar * message, gpointer user_data)
{
if (!_gst_check_expecting_log)
fail ("Unexpected assertion: %s", message);
if (_gst_check_debug) {
g_print (message);
}
if (log_level & G_LOG_LEVEL_CRITICAL)
_gst_check_raised_critical = TRUE;
}
/* initialize GStreamer testing */
void
gst_check_init (void)
gst_check_init (int *argc, char **argv[])
{
gst_init (argc, argv);
if (g_getenv ("GST_TEST_DEBUG"))
_gst_check_debug = TRUE;
g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, gst_check_log_func, NULL);
g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, gst_check_log_message_func,
NULL);
g_log_set_handler (NULL, G_LOG_LEVEL_CRITICAL, gst_check_log_critical_func,
NULL);
g_log_set_handler ("GStreamer", G_LOG_LEVEL_CRITICAL,
gst_check_log_critical_func, NULL);
}

View file

@ -37,17 +37,19 @@
* a gst unit test can be run with GST_TEST_DEBUG env var set to see the
* messages
*/
gboolean _gst_check_threads_running = FALSE;
extern gboolean _gst_check_threads_running;
extern gboolean _gst_check_raised_critical;
extern gboolean _gst_check_expecting_log;
void gst_check_init (void);
void gst_check_init (int *argc, char **argv[]);
/***
* thread test macros and variables
*/
GList *thread_list = NULL;
GMutex *mutex;
GCond *start_cond; /* used to notify main thread of thread startups */
GCond *sync_cond; /* used to synchronize all threads and main thread */
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(); \
@ -133,5 +135,16 @@ G_STMT_START { \
#define THREAD_TEST_RUNNING() (_gst_check_threads_running == TRUE)
#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__, \
"Expected g_critical, got nothing: '"#code"'"); \
_gst_check_expecting_log = FALSE; \
} G_STMT_END
#endif /* __GST_CHECK_H__ */

View file

@ -243,7 +243,8 @@ START_TEST (test_event)
gst_event_unref (send);
gst_event_unref (receive);
}
END_TEST Suite * gst_object_suite (void)
END_TEST Suite *
gst_object_suite (void)
{
Suite *s = suite_create ("data protocol");
TCase *tc_chain = tcase_create ("general");
@ -265,9 +266,8 @@ main (int argc, char **argv)
Suite *s = gst_object_suite ();
SRunner *sr = srunner_create (s);
gst_init (&argc, &argv);
gst_check_init (&argc, &argv);
gst_dp_init ();
gst_check_init ();
srunner_run_all (sr, CK_NORMAL);
nf = srunner_ntests_failed (sr);