tests/check/generic/states.c: Copy the current generic/states example from -base and adapt so we can use the exact sa...

Original commit message from CVS:
* tests/check/generic/states.c: (GST_START_TEST), (states_suite):
Copy the current generic/states example from -base and adapt so
we can use the exact same code everywhere.
Check a STATES_IGNORE_ELEMENTS env var which can be used
to ignore certain element factories for this test, which is
what is being done in -base
* tests/check/Makefile.am:
Mention this environment variable.
This commit is contained in:
Thomas Vander Stichele 2007-02-28 12:40:45 +00:00
parent 7553c996a4
commit 155fa0066d
3 changed files with 99 additions and 46 deletions

View file

@ -1,3 +1,14 @@
2007-02-28 Thomas Vander Stichele <thomas at apestaart dot org>
* tests/check/generic/states.c: (GST_START_TEST), (states_suite):
Copy the current generic/states example from -base and adapt so
we can use the exact same code everywhere.
Check a STATES_IGNORE_ELEMENTS env var which can be used
to ignore certain element factories for this test, which is
what is being done in -base
* tests/check/Makefile.am:
Mention this environment variable.
2007-02-27 Wim Taymans <wim@fluendo.com> 2007-02-27 Wim Taymans <wim@fluendo.com>
* docs/gst/gstreamer-sections.txt: * docs/gst/gstreamer-sections.txt:

View file

@ -8,7 +8,7 @@ REGISTRY_ENVIRONMENT = \
GST_REGISTRY=$(CHECK_REGISTRY) GST_REGISTRY=$(CHECK_REGISTRY)
TESTS_ENVIRONMENT = \ TESTS_ENVIRONMENT = \
$(REGISTRY_ENVIRONMENT) \ $(REGISTRY_ENVIRONMENT) \
GST_PLUGIN_SYSTEM_PATH= \ GST_PLUGIN_SYSTEM_PATH= \
GST_PLUGIN_PATH=$(top_builddir)/plugins GST_PLUGIN_PATH=$(top_builddir)/plugins
@ -43,8 +43,8 @@ if GST_DISABLE_REGISTRY
REGISTRY_CHECKS = REGISTRY_CHECKS =
else else
REGISTRY_CHECKS = \ REGISTRY_CHECKS = \
gst/gst \ gst/gst \
gst/gstbin \ gst/gstbin \
gst/gstelement \ gst/gstelement \
gst/gstevent \ gst/gstevent \
gst/gstghostpad \ gst/gstghostpad \
@ -54,9 +54,9 @@ REGISTRY_CHECKS = \
gst/gstutils \ gst/gstutils \
generic/sinks \ generic/sinks \
elements/fakesink \ elements/fakesink \
elements/fakesrc \ elements/fakesrc \
elements/fdsrc \ elements/fdsrc \
elements/filesrc \ elements/filesrc \
elements/identity \ elements/identity \
libs/basesrc \ libs/basesrc \
libs/controller \ libs/controller \
@ -64,30 +64,30 @@ REGISTRY_CHECKS = \
pipelines/stress pipelines/stress
endif endif
check_PROGRAMS = \ check_PROGRAMS = \
gst/gstabi \ gst/gstabi \
gst/gstbuffer \ gst/gstbuffer \
gst/gstbus \ gst/gstbus \
gst/gstcaps \ gst/gstcaps \
gst/gstinfo \ gst/gstinfo \
gst/gstiterator \ gst/gstiterator \
gst/gstmessage \ gst/gstmessage \
gst/gstminiobject \ gst/gstminiobject \
gst/gstobject \ gst/gstobject \
gst/gstpad \ gst/gstpad \
gst/gstsegment \ gst/gstsegment \
gst/gstsystemclock \ gst/gstsystemclock \
gst/gststructure \ gst/gststructure \
gst/gsttag \ gst/gsttag \
gst/gsttagsetter \ gst/gsttagsetter \
gst/gsttask \ gst/gsttask \
gst/gstvalue \ gst/gstvalue \
$(LOADSAVE_CHECKS) \ $(LOADSAVE_CHECKS) \
generic/states \ generic/states \
$(PARSE_CHECKS) \ $(PARSE_CHECKS) \
$(REGISTRY_CHECKS) \ $(REGISTRY_CHECKS) \
libs/libsabi \ libs/libsabi \
libs/gdp \ libs/gdp \
libs/adapter \ libs/adapter \
libs/gstnetclientclock \ libs/gstnetclientclock \
libs/gstnettimeprovider libs/gstnettimeprovider
@ -95,10 +95,13 @@ check_PROGRAMS = \
# failing tests # failing tests
# queue : tests is unstable (race conditions) # queue : tests is unstable (race conditions)
noinst_PROGRAMS = \ noinst_PROGRAMS = \
gst/gstpipeline \ gst/gstpipeline \
libs/collectpads \ libs/collectpads \
elements/queue elements/queue
# elements to ignore for the state tests
# STATE_IGNORE_ELEMENTS =
#
TESTS = $(check_PROGRAMS) TESTS = $(check_PROGRAMS)
noinst_HEADERS = \ noinst_HEADERS = \
@ -207,7 +210,7 @@ coverage-report:
rm -r coverage rm -r coverage
for dir in $(COVERAGE_DIRS); do \ for dir in $(COVERAGE_DIRS); do \
mkdir -p coverage/$$dir; \ mkdir -p coverage/$$dir; \
make -C $(top_builddir)/$$dir gcov; \ make -C $(top_builddir)/$$dir gcov; \
done done
for dir in $(COVERAGE_DIRS); do \ for dir in $(COVERAGE_DIRS); do \
files="`ls $(top_builddir)/$$dir/*.gcov.out 2> /dev/null`"; \ files="`ls $(top_builddir)/$$dir/*.gcov.out 2> /dev/null`"; \

View file

@ -20,6 +20,10 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <unistd.h> #include <unistd.h>
#include <gst/check/gstcheck.h> #include <gst/check/gstcheck.h>
@ -28,34 +32,73 @@ GST_START_TEST (test_state_changes)
{ {
GstElement *element; GstElement *element;
GList *features, *f; GList *features, *f;
GList *plugins, *p;
gchar **ignorelist = NULL;
const gchar *STATE_IGNORE_ELEMENTS = NULL;
features = gst_registry_get_feature_list (gst_registry_get_default (), GST_DEBUG ("testing elements from source %s", PACKAGE);
GST_TYPE_ELEMENT_FACTORY); STATE_IGNORE_ELEMENTS = g_getenv ("STATE_IGNORE_ELEMENTS");
if (STATE_IGNORE_ELEMENTS) {
for (f = features; f; f = f->next) { GST_DEBUG ("Will ignore element factories: '%s'", STATE_IGNORE_ELEMENTS);
GstPluginFeature *feature = f->data; ignorelist = g_strsplit (STATE_IGNORE_ELEMENTS, " ", 0);
const gchar *name = gst_plugin_feature_get_name (feature);
GST_DEBUG ("testing element %s", name);
element = gst_element_factory_make (name, name);
gst_element_set_state (element, GST_STATE_READY);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_PLAYING);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_READY);
gst_element_set_state (element, GST_STATE_NULL);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_READY);
gst_element_set_state (element, GST_STATE_PLAYING);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (element));
} }
gst_plugin_feature_list_free (features);
gst_task_cleanup_all (); plugins = gst_registry_get_plugin_list (gst_registry_get_default ());
for (p = plugins; p; p = p->next) {
GstPlugin *plugin = p->data;
if (strcmp (gst_plugin_get_source (plugin), PACKAGE) != 0)
continue;
features =
gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
gst_plugin_get_name (plugin));
for (f = features; f; f = f->next) {
GstPluginFeature *feature = f->data;
const gchar *name = gst_plugin_feature_get_name (feature);
gboolean ignore = FALSE;
if (!GST_IS_ELEMENT_FACTORY (feature))
continue;
if (ignorelist) {
gchar **s;
for (s = ignorelist; s && *s; ++s) {
if (g_str_has_prefix (name, *s)) {
GST_DEBUG ("ignoring element %s", name);
ignore = TRUE;
}
}
if (ignore)
continue;
}
GST_DEBUG ("testing element %s", name);
element = gst_element_factory_make (name, name);
fail_if (element == NULL, "Could not make element from factory %s", name);
if (GST_IS_PIPELINE (element)) {
GST_DEBUG ("element %s is a pipeline", name);
}
gst_element_set_state (element, GST_STATE_READY);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_PLAYING);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_READY);
gst_element_set_state (element, GST_STATE_NULL);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_READY);
gst_element_set_state (element, GST_STATE_PLAYING);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (element));
}
}
g_strfreev (ignorelist);
} }
GST_END_TEST; GST_END_TEST;
@ -66,10 +109,6 @@ states_suite (void)
Suite *s = suite_create ("states"); Suite *s = suite_create ("states");
TCase *tc_chain = tcase_create ("general"); TCase *tc_chain = tcase_create ("general");
/* Use a long timeout, as we test all elements and take
* at least 0.2 seconds each */
tcase_set_timeout (tc_chain, 120);
suite_add_tcase (s, tc_chain); suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_state_changes); tcase_add_test (tc_chain, test_state_changes);