mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-27 11:32:51 +00:00
gst/gstcaps.c: don't print error messages when there is no error
Original commit message from CVS: * gst/gstcaps.c: (gst_caps_structure_simplify): don't print error messages when there is no error * gst/gstvalue.c: (gst_value_compare_int_range): compare the second value, too * testsuite/caps/Makefile.am: * testsuite/caps/random.c: (assert_on_error), (main): add tests to make sure the two things above are checked for
This commit is contained in:
parent
af9e417b2c
commit
7193393c18
7 changed files with 164 additions and 3 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2004-05-25 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||||
|
|
||||||
|
* gst/gstcaps.c: (gst_caps_structure_simplify):
|
||||||
|
don't print error messages when there is no error
|
||||||
|
* gst/gstvalue.c: (gst_value_compare_int_range):
|
||||||
|
compare the second value, too
|
||||||
|
* testsuite/caps/Makefile.am:
|
||||||
|
* testsuite/caps/random.c: (assert_on_error), (main):
|
||||||
|
add tests to make sure the two things above are checked for
|
||||||
|
|
||||||
2004-05-24 Thomas Vander Stichele <thomas at apestaart dot org>
|
2004-05-24 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* configure.ac:
|
* configure.ac:
|
||||||
|
|
|
@ -1184,6 +1184,8 @@ gst_caps_structure_simplify (GstStructure ** result,
|
||||||
gst_caps_structure_figure_out_union, &field)) {
|
gst_caps_structure_figure_out_union, &field)) {
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
|
/* now we know all of simplify's fields are the same in compare
|
||||||
|
* but at most one field: field.name */
|
||||||
if (G_IS_VALUE (&field.value)) {
|
if (G_IS_VALUE (&field.value)) {
|
||||||
if (gst_structure_n_fields (simplify) == gst_structure_n_fields (compare)) {
|
if (gst_structure_n_fields (simplify) == gst_structure_n_fields (compare)) {
|
||||||
gst_structure_id_set_value (compare, field.name, &field.value);
|
gst_structure_id_set_value (compare, field.name, &field.value);
|
||||||
|
@ -1191,6 +1193,11 @@ gst_caps_structure_simplify (GstStructure ** result,
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
g_value_unset (&field.value);
|
g_value_unset (&field.value);
|
||||||
|
} else if (gst_structure_n_fields (simplify) <=
|
||||||
|
gst_structure_n_fields (compare)) {
|
||||||
|
/* compare is just more specific, will be optimized away later */
|
||||||
|
/* FIXME: do this here? */
|
||||||
|
GST_LOG ("found a case that will be optimized later.");
|
||||||
} else {
|
} else {
|
||||||
gchar *one = gst_structure_to_string (simplify);
|
gchar *one = gst_structure_to_string (simplify);
|
||||||
gchar *two = gst_structure_to_string (compare);
|
gchar *two = gst_structure_to_string (compare);
|
||||||
|
|
|
@ -639,7 +639,7 @@ static int
|
||||||
gst_value_compare_int_range (const GValue * value1, const GValue * value2)
|
gst_value_compare_int_range (const GValue * value1, const GValue * value2)
|
||||||
{
|
{
|
||||||
if (value2->data[0].v_int == value1->data[0].v_int &&
|
if (value2->data[0].v_int == value1->data[0].v_int &&
|
||||||
value2->data[0].v_int == value1->data[0].v_int)
|
value2->data[1].v_int == value1->data[1].v_int)
|
||||||
return GST_VALUE_EQUAL;
|
return GST_VALUE_EQUAL;
|
||||||
return GST_VALUE_UNORDERED;
|
return GST_VALUE_UNORDERED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,8 @@ tests_pass = \
|
||||||
renegotiate \
|
renegotiate \
|
||||||
subtract \
|
subtract \
|
||||||
sets \
|
sets \
|
||||||
simplify
|
simplify \
|
||||||
|
random
|
||||||
|
|
||||||
EXTRA_DIST = caps_strings
|
EXTRA_DIST = caps_strings
|
||||||
|
|
||||||
|
@ -61,3 +62,5 @@ simplify_LDADD = $(GST_OBJ_LIBS)
|
||||||
simplify_CFLAGS = $(GST_OBJ_CFLAGS) $(XML_CFLAGS)
|
simplify_CFLAGS = $(GST_OBJ_CFLAGS) $(XML_CFLAGS)
|
||||||
renegotiate_LDADD = $(GST_OBJ_LIBS)
|
renegotiate_LDADD = $(GST_OBJ_LIBS)
|
||||||
renegotiate_CFLAGS = $(GST_OBJ_CFLAGS) $(XML_CFLAGS)
|
renegotiate_CFLAGS = $(GST_OBJ_CFLAGS) $(XML_CFLAGS)
|
||||||
|
random_LDADD = $(GST_OBJ_LIBS)
|
||||||
|
random_CFLAGS = $(GST_OBJ_CFLAGS) $(XML_CFLAGS)
|
||||||
|
|
69
tests/old/testsuite/caps/random.c
Normal file
69
tests/old/testsuite/caps/random.c
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
assert_on_error (GstDebugCategory * category, GstDebugLevel level,
|
||||||
|
const gchar * file, const gchar * function, gint line, GObject * object,
|
||||||
|
GstDebugMessage * message, gpointer data)
|
||||||
|
{
|
||||||
|
g_assert (level != GST_LEVEL_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
main (gint argc, gchar * argv[])
|
||||||
|
{
|
||||||
|
/* this file contains random tests for stuff that went wrong in some version
|
||||||
|
* and should be tested so we're sure it works right now
|
||||||
|
* Please add what exactly the code tests for in your test */
|
||||||
|
|
||||||
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
/* TEST 1:
|
||||||
|
* gstcaps.c 1.120 used a code path that caused a GST_ERROR for the tested
|
||||||
|
* caps when simplifying even though that is absolutely valid */
|
||||||
|
{
|
||||||
|
GstCaps *caps =
|
||||||
|
gst_caps_from_string
|
||||||
|
("some/type, a=(int)2, b=(int)3, c=bla; some/type, a=(int)2, c=bla");
|
||||||
|
gst_debug_add_log_function (assert_on_error, NULL);
|
||||||
|
gst_caps_do_simplify (caps);
|
||||||
|
gst_debug_remove_log_function (assert_on_error);
|
||||||
|
gst_caps_free (caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TEST 2:
|
||||||
|
* gstvalue.c 1.34 had a broken comparison function for int ranges that
|
||||||
|
* returned GST_VALUE_EQUAL even though the range end was different */
|
||||||
|
{
|
||||||
|
GValue v1 = { 0, };
|
||||||
|
GValue v2 = { 0, };
|
||||||
|
|
||||||
|
g_value_init (&v1, GST_TYPE_INT_RANGE);
|
||||||
|
g_value_init (&v2, GST_TYPE_INT_RANGE);
|
||||||
|
gst_value_set_int_range (&v1, 1, 2);
|
||||||
|
gst_value_set_int_range (&v2, 1, 3);
|
||||||
|
g_assert (gst_value_compare (&v1, &v2) != GST_VALUE_EQUAL);
|
||||||
|
g_value_unset (&v1);
|
||||||
|
g_value_unset (&v2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -21,7 +21,8 @@ tests_pass = \
|
||||||
renegotiate \
|
renegotiate \
|
||||||
subtract \
|
subtract \
|
||||||
sets \
|
sets \
|
||||||
simplify
|
simplify \
|
||||||
|
random
|
||||||
|
|
||||||
EXTRA_DIST = caps_strings
|
EXTRA_DIST = caps_strings
|
||||||
|
|
||||||
|
@ -61,3 +62,5 @@ simplify_LDADD = $(GST_OBJ_LIBS)
|
||||||
simplify_CFLAGS = $(GST_OBJ_CFLAGS) $(XML_CFLAGS)
|
simplify_CFLAGS = $(GST_OBJ_CFLAGS) $(XML_CFLAGS)
|
||||||
renegotiate_LDADD = $(GST_OBJ_LIBS)
|
renegotiate_LDADD = $(GST_OBJ_LIBS)
|
||||||
renegotiate_CFLAGS = $(GST_OBJ_CFLAGS) $(XML_CFLAGS)
|
renegotiate_CFLAGS = $(GST_OBJ_CFLAGS) $(XML_CFLAGS)
|
||||||
|
random_LDADD = $(GST_OBJ_LIBS)
|
||||||
|
random_CFLAGS = $(GST_OBJ_CFLAGS) $(XML_CFLAGS)
|
||||||
|
|
69
testsuite/caps/random.c
Normal file
69
testsuite/caps/random.c
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
assert_on_error (GstDebugCategory * category, GstDebugLevel level,
|
||||||
|
const gchar * file, const gchar * function, gint line, GObject * object,
|
||||||
|
GstDebugMessage * message, gpointer data)
|
||||||
|
{
|
||||||
|
g_assert (level != GST_LEVEL_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
main (gint argc, gchar * argv[])
|
||||||
|
{
|
||||||
|
/* this file contains random tests for stuff that went wrong in some version
|
||||||
|
* and should be tested so we're sure it works right now
|
||||||
|
* Please add what exactly the code tests for in your test */
|
||||||
|
|
||||||
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
/* TEST 1:
|
||||||
|
* gstcaps.c 1.120 used a code path that caused a GST_ERROR for the tested
|
||||||
|
* caps when simplifying even though that is absolutely valid */
|
||||||
|
{
|
||||||
|
GstCaps *caps =
|
||||||
|
gst_caps_from_string
|
||||||
|
("some/type, a=(int)2, b=(int)3, c=bla; some/type, a=(int)2, c=bla");
|
||||||
|
gst_debug_add_log_function (assert_on_error, NULL);
|
||||||
|
gst_caps_do_simplify (caps);
|
||||||
|
gst_debug_remove_log_function (assert_on_error);
|
||||||
|
gst_caps_free (caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TEST 2:
|
||||||
|
* gstvalue.c 1.34 had a broken comparison function for int ranges that
|
||||||
|
* returned GST_VALUE_EQUAL even though the range end was different */
|
||||||
|
{
|
||||||
|
GValue v1 = { 0, };
|
||||||
|
GValue v2 = { 0, };
|
||||||
|
|
||||||
|
g_value_init (&v1, GST_TYPE_INT_RANGE);
|
||||||
|
g_value_init (&v2, GST_TYPE_INT_RANGE);
|
||||||
|
gst_value_set_int_range (&v1, 1, 2);
|
||||||
|
gst_value_set_int_range (&v2, 1, 3);
|
||||||
|
g_assert (gst_value_compare (&v1, &v2) != GST_VALUE_EQUAL);
|
||||||
|
g_value_unset (&v1);
|
||||||
|
g_value_unset (&v2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in a new issue