Commit ee18cc15 authored by Martin Nordholts's avatar Martin Nordholts

Add a simple tests case to ensure processing and caching sanity

Add a simple tests case to ensure processing and caching sanity. The
test case constructs a simple graph, processes it, checks the result,
changes input, processes again and finally checks the result a second
time. This test will immediately catch severe regressions.

svn path=/trunk/; revision=2952
parent 0797f3bc
2009-02-28 Martin Nordholts <martinn@svn.gnome.org>
Add a simple tests case to ensure processing and caching
sanity. The test case constructs a simple graph, processes it,
checks the result, changes input, processes again and finally
checks the result a second time. This test will immediately catch
severe regressions.
* Makefile.am
* configure.ac
* tests/Makefile.am (new file)
* tests/test-proxynop-processing.c (new file)
2009-02-28 Martin Nordholts <martinn@svn.gnome.org>
* gegl/gegl-dot.c: Print the GeglNode pointer at the end of the op
......
......@@ -5,7 +5,8 @@ SUBDIRS=\
operations \
bin \
tools \
examples
examples \
tests
if ENABLE_DOCS
SUBDIRS+= docs
......
......@@ -987,6 +987,7 @@ docs/gallery/Makefile
docs/gallery/data/Makefile
examples/Makefile
examples/data/Makefile
tests/Makefile
gegl.pc
gegl-uninstalled.pc
])
......
/Makefile
/Makefile.in
/.deps
/.libs
/*.lo
/*.la
/test-proxynop-processing*
\ No newline at end of file
TESTS = \
test-proxynop-processing$(EXEEXT)
test_proxynop_processing_SOURCES = \
test-proxynop-processing.c
test_proxynop_processing_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_srcdir)/gegl/ \
-I$(top_srcdir)/gegl/buffer \
-I$(top_srcdir)/gegl/property-types \
-I$(top_srcdir)/gegl/operation \
@DEP_CFLAGS@ @BABL_CFLAGS@
test_proxynop_processing_LDADD = \
$(top_srcdir)/gegl/libgegl-@GEGL_API_VERSION@.la \
@DEP_LIBS@ @BABL_LIBS@
EXTRA_PROGRAMS = \
$(TESTS)
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2009 Martin Nordholts
*/
#include "gegl.h"
#define RED 0
#define GREEN 1
#define BLUE 2
#define SUCCESS 0
#define FAILURE -1
int main(int argc, char *argv[])
{
int result = SUCCESS;
GeglNode *graph = NULL;
GeglNode *color_in_graph = NULL;
GeglNode *crop_in_graph = NULL;
GeglNode *graph_output_proxy = NULL;
GeglRectangle roi = { 0, 0, 1, 1 };
guchar result_buffer[3] = { 0, 0, 0 };
GeglColor *color1 = NULL;
GeglColor *color2 = NULL;
/* Init */
gegl_init (&argc, &argv);
color1 = gegl_color_new ("rgb(1.0, 0.0, 1.0)");
color2 = gegl_color_new ("rgb(0.0, 0.0, 1.0)");
/* Construct graph */
graph = gegl_node_new ();
color_in_graph = gegl_node_new_child (graph,
"operation", "gegl:color",
"value", color1,
NULL);
crop_in_graph = gegl_node_new_child (graph,
"operation", "gegl:crop",
"x", 0.0,
"y", 0.0,
"width", 1.0,
"height", 1.0,
NULL);
graph_output_proxy = gegl_node_get_output_proxy (graph,
"output");
gegl_node_link_many (color_in_graph,
crop_in_graph,
graph_output_proxy,
NULL);
/* Process the graph and make sure we get the expected result */
gegl_node_blit (graph_output_proxy,
1.0,
&roi,
babl_format ("RGB u8"),
result_buffer,
GEGL_AUTO_ROWSTRIDE,
GEGL_BLIT_DEFAULT);
if (result_buffer[RED] == 255 &&
result_buffer[GREEN] == 0 &&
result_buffer[BLUE] == 255)
{
result = SUCCESS;
}
else
{
result = FAILURE;
g_printerr ("Initial processing failed, you messed up GEGL pretty badly :(");
goto abort;
}
/* Process the graph AGAIN and make sure we get the expected result
* as this puts some stress on the caching mechanisms
*/
gegl_node_set (color_in_graph,
"value", color2,
NULL);
gegl_node_blit (graph_output_proxy,
1.0,
&roi,
babl_format ("RGB u8"),
result_buffer,
GEGL_AUTO_ROWSTRIDE,
GEGL_BLIT_DEFAULT);
if (result_buffer[RED] == 0 &&
result_buffer[GREEN] == 0 &&
result_buffer[BLUE] == 255)
{
result = SUCCESS;
}
else
{
result = FAILURE;
g_printerr ("Second processing failed, looks like you messed up caching. Fix!");
goto abort;
}
abort:
/* Cleanup */
g_object_unref (graph);
g_object_unref (color1);
g_object_unref (color2);
gegl_exit ();
return result;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment