mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 03:01:03 +00:00
tests: fix tests when compiling with glib_checks=disabled
We won't be able to do ASSERT_CRITICAL, but the main body of the tests are still valid, and given we ship GStreamer with this configuration, it is important to be able to run some tests against it.
This commit is contained in:
parent
320ac0ce1a
commit
1335110409
11 changed files with 65 additions and 13 deletions
10
configure.ac
10
configure.ac
|
@ -118,6 +118,16 @@ AC_SUBST(GST_REGISTRY_DOC_TYPES)
|
|||
AG_GST_CHECK_SUBSYSTEM_DISABLE(PLUGIN,[plugin])
|
||||
AM_CONDITIONAL(GST_DISABLE_PLUGIN, test "x$GST_DISABLE_PLUGIN" = "xyes")
|
||||
|
||||
GST_DISABLE_CAST_CHECKS_DEFINE=0
|
||||
AC_SUBST(GST_DISABLE_CAST_CHECKS_DEFINE)
|
||||
|
||||
GST_DISABLE_GLIB_ASSERTS_DEFINE=0
|
||||
AC_SUBST(GST_DISABLE_GLIB_ASSERTS_DEFINE)
|
||||
|
||||
GST_DISABLE_GLIB_CHECKS_DEFINE=0
|
||||
AC_SUBST(GST_DISABLE_GLIB_CHECKS_DEFINE)
|
||||
|
||||
|
||||
AG_GST_ARG_DEBUG
|
||||
AG_GST_ARG_PROFILING
|
||||
AG_GST_ARG_VALGRIND
|
||||
|
|
|
@ -91,6 +91,28 @@
|
|||
*/
|
||||
@GST_DISABLE_REGISTRY_DEFINE@
|
||||
|
||||
/**
|
||||
* GST_DISABLE_CAST_CHECKS:
|
||||
*
|
||||
* Disable run-time GObject cast checks
|
||||
*/
|
||||
#define GST_DISABLE_CAST_CHECKS @GST_DISABLE_CAST_CHECKS_DEFINE@
|
||||
|
||||
/**
|
||||
* GST_DISABLE_GLIB_ASSERTS:
|
||||
*
|
||||
* Disable GLib assertion
|
||||
*/
|
||||
#define GST_DISABLE_GLIB_ASSERTS @GST_DISABLE_GLIB_ASSERTS_DEFINE@
|
||||
|
||||
/**
|
||||
* GST_DISABLE_GLIB_CHECKS:
|
||||
*
|
||||
* Disable GLib checks such as API guards
|
||||
*/
|
||||
#define GST_DISABLE_GLIB_CHECKS @GST_DISABLE_GLIB_CHECKS_DEFINE@
|
||||
|
||||
|
||||
/* FIXME: test and document these! */
|
||||
/* Configures the use of external plugins */
|
||||
@GST_DISABLE_PLUGIN_DEFINE@
|
||||
|
|
|
@ -180,6 +180,10 @@ else
|
|||
gst_cdata.set('GST_DISABLE_PARSE_DEFINE', '#define GST_DISABLE_PARSE 1')
|
||||
endif
|
||||
|
||||
gst_cdata.set10('GST_DISABLE_CAST_CHECKS_DEFINE', cast_checks.disabled())
|
||||
gst_cdata.set10('GST_DISABLE_GLIB_ASSERTS_DEFINE', glib_asserts.disabled())
|
||||
gst_cdata.set10('GST_DISABLE_GLIB_CHECKS_DEFINE', glib_checks.disabled())
|
||||
|
||||
# FIXME: add --disable-plugin option?
|
||||
gst_cdata.set('GST_DISABLE_PLUGIN_DEFINE', '#undef GST_DISABLE_PLUGIN')
|
||||
|
||||
|
|
|
@ -617,6 +617,10 @@ G_STMT_START { \
|
|||
#define THREAD_TEST_RUNNING() (!!_gst_check_threads_running)
|
||||
|
||||
/* additional assertions */
|
||||
|
||||
#if GST_DISABLE_GLIB_CHECKS
|
||||
#define ASSERT_CRITICAL(code)
|
||||
#else
|
||||
#define ASSERT_CRITICAL(code) \
|
||||
G_STMT_START { \
|
||||
_gst_check_expecting_log = TRUE; \
|
||||
|
@ -627,6 +631,7 @@ G_STMT_START { \
|
|||
"Expected g_critical, got nothing", NULL); \
|
||||
_gst_check_expecting_log = FALSE; \
|
||||
} G_STMT_END
|
||||
#endif /* GST_DISABLE_GLIB_CHECKS */
|
||||
|
||||
#define ASSERT_WARNING(code) \
|
||||
G_STMT_START { \
|
||||
|
|
|
@ -1102,19 +1102,17 @@ GST_END_TEST;
|
|||
|
||||
GST_START_TEST (test_broken)
|
||||
{
|
||||
GstCaps *c1;
|
||||
GstCaps *c1 = NULL;
|
||||
|
||||
/* NULL is not valid for media_type */
|
||||
ASSERT_CRITICAL (c1 =
|
||||
gst_caps_new_simple (NULL, "field", G_TYPE_INT, 1, NULL));
|
||||
fail_if (c1);
|
||||
|
||||
#ifndef G_DISABLE_CHECKS
|
||||
/* such a name is not valid, see gst_structure_validate_name() */
|
||||
ASSERT_CRITICAL (c1 =
|
||||
gst_caps_new_simple ("1#@abc", "field", G_TYPE_INT, 1, NULL));
|
||||
fail_if (c1);
|
||||
#endif
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
|
|
@ -949,6 +949,7 @@ GST_START_TEST (test_ghost_pads_src_link_unlink)
|
|||
fail_unless (unlinked_count2 == 0);
|
||||
|
||||
/* this should fail with a critial */
|
||||
dummy = NULL;
|
||||
ASSERT_CRITICAL (dummy = gst_ghost_pad_new ("ghostpad", srcpad));
|
||||
fail_unless (dummy == NULL);
|
||||
fail_unless (linked_count1 == 1);
|
||||
|
|
|
@ -427,6 +427,7 @@ GST_START_TEST (test_fake_object_parentage)
|
|||
parent = gst_object_get_parent (object1);
|
||||
fail_if (parent != NULL, "GstFakeObject has parent");
|
||||
/* try to set a NULL parent, this should give a warning */
|
||||
result = FALSE;
|
||||
ASSERT_CRITICAL (result = gst_object_set_parent (object1, NULL));
|
||||
fail_if (result, "GstFakeObject accepted NULL parent");
|
||||
/* try to set itself as parent, we expect a warning here */
|
||||
|
|
|
@ -188,6 +188,7 @@ GST_START_TEST (test_from_string)
|
|||
gst_structure_free (structure);
|
||||
|
||||
s = "0.10:decoder-video/mpeg, abc=(boolean)false";
|
||||
structure = NULL;
|
||||
ASSERT_CRITICAL (structure = gst_structure_from_string (s, NULL));
|
||||
fail_unless (structure == NULL, "Could not get structure from string %s", s);
|
||||
|
||||
|
@ -223,7 +224,7 @@ GST_END_TEST;
|
|||
|
||||
GST_START_TEST (test_to_string)
|
||||
{
|
||||
GstStructure *st1;
|
||||
GstStructure *st1 = NULL;
|
||||
|
||||
ASSERT_CRITICAL (st1 = gst_structure_new_empty ("Foo\nwith-newline"));
|
||||
fail_unless (st1 == NULL);
|
||||
|
@ -426,6 +427,7 @@ GST_START_TEST (test_structure_new)
|
|||
("0.10:decoder-video/mpeg")));
|
||||
|
||||
/* make sure we bail out correctly in case of an error or if parsing fails */
|
||||
s = NULL;
|
||||
ASSERT_CRITICAL (s = gst_structure_new ("^joo\nba\ndoo^",
|
||||
"abc", G_TYPE_BOOLEAN, FALSE, NULL));
|
||||
fail_unless (s == NULL);
|
||||
|
|
|
@ -85,7 +85,7 @@ GST_END_TEST;
|
|||
#ifndef GST_REMOVE_DEPRECATED
|
||||
GST_START_TEST (test_gst_uri_construct)
|
||||
{
|
||||
gchar *l;
|
||||
gchar *l = NULL;
|
||||
|
||||
/* URI with no protocol or empty protocol should return empty string */
|
||||
ASSERT_CRITICAL (l = gst_uri_construct (NULL, "/path/to/file"));
|
||||
|
|
|
@ -2954,8 +2954,10 @@ GST_START_TEST (test_deserialize_int_range)
|
|||
str =
|
||||
g_strdup_printf ("foo/bar, range=[ 1, %" G_GINT64_FORMAT " ];",
|
||||
(gint64) G_MAXINT + 1);
|
||||
s = NULL;
|
||||
ASSERT_CRITICAL (s = gst_structure_from_string (str, &end));
|
||||
g_free (str);
|
||||
if (s)
|
||||
gst_structure_free (s);
|
||||
str =
|
||||
g_strdup_printf ("foo/bar, range=[ %" G_GINT64_FORMAT ", %"
|
||||
|
@ -2963,6 +2965,7 @@ GST_START_TEST (test_deserialize_int_range)
|
|||
ASSERT_CRITICAL (s = gst_structure_from_string (str, NULL));
|
||||
end = NULL;
|
||||
g_free (str);
|
||||
if (s)
|
||||
gst_structure_free (s);
|
||||
|
||||
/* check a valid int64_range deserialization. Those ranges need to
|
||||
|
@ -2985,10 +2988,13 @@ GST_START_TEST (test_deserialize_int_range)
|
|||
str =
|
||||
g_strdup_printf ("foo/bar, range=(gint64)[ 1, %" G_GUINT64_FORMAT " ];",
|
||||
(guint64) G_MAXINT64 + 1);
|
||||
s = NULL;
|
||||
ASSERT_CRITICAL (s = gst_structure_from_string (str, &end));
|
||||
if (s) {
|
||||
fail_unless (*end == '\0');
|
||||
gst_structure_free (s);
|
||||
end = NULL;
|
||||
}
|
||||
g_free (str);
|
||||
|
||||
/* check invalid int64_range deserialization into a int64_range */
|
||||
|
@ -2997,6 +3003,7 @@ GST_START_TEST (test_deserialize_int_range)
|
|||
G_GUINT64_FORMAT " ];", (gint64) G_MAXINT, (guint64) G_MAXINT64 + 1);
|
||||
ASSERT_CRITICAL (s = gst_structure_from_string (str, NULL));
|
||||
g_free (str);
|
||||
if (s)
|
||||
gst_structure_free (s);
|
||||
|
||||
/* check invalid int64_range deserialization into a int_range */
|
||||
|
@ -3065,6 +3072,7 @@ GST_START_TEST (test_stepped_int_range_parsing)
|
|||
fail_unless (s != NULL);
|
||||
fail_unless (*end == '\0');
|
||||
gst_structure_free (s);
|
||||
s = NULL;
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
|
@ -3072,6 +3080,7 @@ GST_START_TEST (test_stepped_int_range_parsing)
|
|||
for (n = 0; n < G_N_ELEMENTS (bad_ranges); ++n) {
|
||||
str = g_strdup_printf ("foo/bar, range=%s", bad_ranges[n]);
|
||||
ASSERT_CRITICAL (s = gst_structure_from_string (str, &end));
|
||||
if (s)
|
||||
gst_structure_free (s);
|
||||
g_free (str);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ GST_START_TEST (test_peek1)
|
|||
GstBuffer *buffer;
|
||||
guint avail;
|
||||
GstMapInfo info;
|
||||
const guint8 *data1, *data2, *idata;
|
||||
const guint8 *data1 = NULL, *data2 = NULL, *idata = NULL;
|
||||
|
||||
adapter = gst_adapter_new ();
|
||||
fail_if (adapter == NULL);
|
||||
|
|
Loading…
Reference in a new issue