This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 3d14cb78419fe54e86e6a838b919a303ae9e536f (commit) via 74c604b15d7fcc320bd64b1efda533ea0d54c228 (commit) from 22988118088f5fb0de21f8ea6ada75be2b42f446 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/3d14cb78419fe54e86e6a838b919a303ae9e5...
commit 3d14cb78419fe54e86e6a838b919a303ae9e536f Author: Cyril Hrubis metan@ucw.cz Date: Mon Oct 7 18:42:21 2013 +0200
tests: filters: Better API Converage test.
* More filters covered
* Now with checks for correct errno values
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/filters/APICoverage.gen.c.t b/tests/filters/APICoverage.gen.c.t index 323f614..b4c8281 100644 --- a/tests/filters/APICoverage.gen.c.t +++ b/tests/filters/APICoverage.gen.c.t @@ -20,96 +20,123 @@ * * *****************************************************************************/
- /* - - The purpose of this test is to exercise as much codepaths as possible - without checking for result corectness. +%% extends "base.test.c.t"
- */ +%% block descr +Filters API coverage tests.
-%% extends "base.test.c.t" +The purpose of this test is to exercise as much codepaths as possible +without checking for result corectness.
-{% block descr %}Filters API coverage tests.{% endblock %} +We check for correct return value correcness though. +%% endblock descr
%% block body
#include <stdio.h> +#include <string.h> +#include <errno.h>
#include <core/GP_Context.h> #include <filters/GP_Filters.h>
#include "tst_test.h"
-%% set API_List = [['MirrorH', 'GP_Context:in', 'GP_Context:out', +%% set API_List = [['MirrorH', '', 'GP_Context:in', 'GP_Context:out', + 'GP_ProgressCallback'], + ['MirrorHAlloc', '', 'GP_Context:in', 'GP_ProgressCallback'], + + ['MirrorV', '', 'GP_Context:in', 'GP_Context:out', + 'GP_ProgressCallback'], + ['MirrorVAlloc', '', 'GP_Context:in', 'GP_ProgressCallback'], + + ['Rotate90', '', 'GP_Context:in', 'GP_Context:out', 'GP_ProgressCallback'], - ['MirrorHAlloc', 'GP_Context:in', 'GP_ProgressCallback'], + ['Rotate90Alloc', '', 'GP_Context:in', 'GP_ProgressCallback'],
- ['MirrorV', 'GP_Context:in', 'GP_Context:out', + ['Rotate180', '', 'GP_Context:in', 'GP_Context:out', 'GP_ProgressCallback'], - ['MirrorVAlloc', 'GP_Context:in', 'GP_ProgressCallback'], + ['Rotate180Alloc', '', 'GP_Context:in', 'GP_ProgressCallback'],
- ['Rotate90', 'GP_Context:in', 'GP_Context:out', + ['Rotate270', '', 'GP_Context:in', 'GP_Context:out', 'GP_ProgressCallback'], - ['Rotate90Alloc', 'GP_Context:in', 'GP_ProgressCallback'], + ['Rotate270Alloc', '', 'GP_Context:in', 'GP_ProgressCallback'],
- ['Rotate180', 'GP_Context:in', 'GP_Context:out', + ['Symmetry', 'H', 'GP_Context:in', 'GP_Context:out', + 'GP_MIRROR_H', 'GP_ProgressCallback'], + ['SymmetryAlloc', 'H', 'GP_Context:in', 'GP_MIRROR_H', 'GP_ProgressCallback'], - ['Rotate180Alloc', 'GP_Context:in', 'GP_ProgressCallback'],
- ['Rotate270', 'GP_Context:in', 'GP_Context:out', + ['Symmetry', 'V', 'GP_Context:in', 'GP_Context:out', + 'GP_MIRROR_V', 'GP_ProgressCallback'], + ['SymmetryAlloc', 'V', 'GP_Context:in', 'GP_MIRROR_V', 'GP_ProgressCallback'], - ['Rotate270Alloc', 'GP_Context:in', 'GP_ProgressCallback'],
- ['Convolution', 'GP_Context:in', 'GP_Context:out', + ['Symmetry', '90', 'GP_Context:in', 'GP_Context:out', + 'GP_ROTATE_90', 'GP_ProgressCallback'], + ['SymmetryAlloc', '90', 'GP_Context:in', 'GP_ROTATE_90', + 'GP_ProgressCallback'], + + ['Symmetry', '180', 'GP_Context:in', 'GP_Context:out', + 'GP_ROTATE_180', 'GP_ProgressCallback'], + ['SymmetryAlloc', '180', 'GP_Context:in', 'GP_ROTATE_180', + 'GP_ProgressCallback'], + + ['Symmetry', '270', 'GP_Context:in', 'GP_Context:out', + 'GP_ROTATE_270', 'GP_ProgressCallback'], + ['SymmetryAlloc', '270', 'GP_Context:in', 'GP_ROTATE_270', + 'GP_ProgressCallback'], + + ['Convolution', '', 'GP_Context:in', 'GP_Context:out', 'GP_FilterKernel2D:kernel', 'GP_ProgressCallback'], - ['ConvolutionAlloc', 'GP_Context:in', + ['ConvolutionAlloc', '', 'GP_Context:in', 'GP_FilterKernel2D:kernel', 'GP_ProgressCallback'],
- ['GaussianBlur', 'GP_Context:in', 'GP_Context:out', + ['GaussianBlur', '', 'GP_Context:in', 'GP_Context:out', 'float:sigma_x', 'float:sigma_y', 'GP_ProgressCallback'], - ['GaussianBlurAlloc', 'GP_Context:in', 'float:sigma_x', + ['GaussianBlurAlloc', '', 'GP_Context:in', 'float:sigma_x', 'float:sigma_y', 'GP_ProgressCallback'],
- ['GaussianNoiseAdd', 'GP_Context:in', 'GP_Context:out', + ['GaussianNoiseAdd', '', 'GP_Context:in', 'GP_Context:out', 'float:sigma', 'float:mu', 'GP_ProgressCallback'], - ['GaussianNoiseAddAlloc', 'GP_Context:in', + ['GaussianNoiseAddAlloc', '', 'GP_Context:in', 'float:sigma', 'float:mu', 'GP_ProgressCallback'],
- ['Median', 'GP_Context:in', 'GP_Context:out', + ['Median', '', 'GP_Context:in', 'GP_Context:out', 'int:xmed', 'int:ymed', 'GP_ProgressCallback'], - ['MedianAlloc', 'GP_Context:in', + ['MedianAlloc', '', 'GP_Context:in', 'int:xmed', 'int:ymed', 'GP_ProgressCallback'],
- ['WeightedMedian', 'GP_Context:in', 'GP_Context:out', + ['WeightedMedian', '', 'GP_Context:in', 'GP_Context:out', 'GP_MedianWeights:weights', 'GP_ProgressCallback'], - ['WeightedMedianAlloc', 'GP_Context:in', + ['WeightedMedianAlloc', '', 'GP_Context:in', 'GP_MedianWeights:weights', 'GP_ProgressCallback'],
- ['Sigma', 'GP_Context:in', 'GP_Context:out', + ['Sigma', '', 'GP_Context:in', 'GP_Context:out', 'int:xrad', 'int:yrad', 'int:min', 'float:sigma', 'GP_ProgressCallback'], - ['SigmaAlloc', 'GP_Context:in', + ['SigmaAlloc', '', 'GP_Context:in', 'int:xrad', 'int:yrad', 'int:min', 'float:sigma', 'GP_ProgressCallback'],
- ['ResizeNN', 'GP_Context:in', 'GP_Context:out', + ['ResizeNN', '', 'GP_Context:in', 'GP_Context:out', 'GP_ProgressCallback'], - ['ResizeNNAlloc', 'GP_Context:in', 'int:w', 'int:h', + ['ResizeNNAlloc', '', 'GP_Context:in', 'int:w', 'int:h', 'GP_ProgressCallback'],
- ['FloydSteinberg', 'GP_Context:in', 'GP_Context:out', + ['FloydSteinberg', '', 'GP_Context:in', 'GP_Context:out', 'GP_ProgressCallback'], - ['FloydSteinbergAlloc', 'GP_Context:in', 'GP_PixelType:G8', + ['FloydSteinbergAlloc', '', 'GP_Context:in', 'GP_PixelType:G8', 'GP_ProgressCallback'],
- ['HilbertPeano', 'GP_Context:in', 'GP_Context:out', + ['HilbertPeano', '', 'GP_Context:in', 'GP_Context:out', 'GP_ProgressCallback'], - ['HilbertPeanoAlloc', 'GP_Context:in', 'GP_PixelType:G8', + ['HilbertPeanoAlloc', '', 'GP_Context:in', 'GP_PixelType:G8', 'GP_ProgressCallback'], ]
-%% macro prep_context(id, pt) - GP_Context *{{ id }} = GP_ContextAlloc(331, 331, GP_PIXEL_{{ pt.name }}); +%% macro prep_context(id) + GP_Context *{{ id }} = GP_ContextAlloc(331, 331, pt); %% endmacro
%% macro prep_float(id) @@ -159,9 +186,9 @@ GP_FilterKernel2D *{{ id }} = &{{ id }}_s; %% endmacro
-%% macro prep_param(param, pt) +%% macro prep_param(param) %% if (param.split(':', 1)[0] == 'GP_Context') -{{ prep_context(param.split(':', 1)[1], pt) }} +{{ prep_context(param.split(':', 1)[1]) }} %% endif %% if (param.split(':', 1)[0] == 'float') {{ prep_float(param.split(':', 1)[1]) }} @@ -180,23 +207,55 @@ %% endif %% endmacro
-{% macro get_param(param) %}{% if len(param.split(':', 1)) == 1 %}NULL{% else %}{{ param.split(':', 1)[1] }}{% endif %}{% endmacro %} +{% macro do_param(param) %}{% if param == 'GP_ProgressCallback' %}NULL{% else %}{{ param }}{% endif %}{% endmacro %}
-%% for fn in API_List -%% for pt in pixeltypes -%% if not pt.is_unknown() +{% macro get_param(param) %}{% if len(param.split(':', 1)) == 1 %}{{ do_param(param) }}{% else %}{{ param.split(':', 1)[1] }}{% endif %}{% endmacro %}
-static int Filter_{{ fn[0]}}_{{ pt.name }}(void) +%% for fn in API_List +static int filter_{{ fn[0] }}_{{ fn[1] }}(GP_PixelType pt) { -%% for param in fn[1:] -{{ prep_param(param, pt) }} -%% endfor +%% for param in fn[1:] +{{ prep_param(param) }} +%% endfor +%% if 'Alloc' in fn[0] + GP_Context *res; +%% else + int res; +%% endif + + res = GP_Filter{{ fn[0] }}({{ get_param(fn[2]) }}{% for param in fn[3:] %}, {{ get_param(param) }}{% endfor %});
- GP_Filter{{ fn[0] }}({{ get_param(fn[1]) }}{% for param in fn[2:] %}, {{ get_param(param) }}{% endfor %}); +%% if 'Alloc' in fn[0] + if (res == NULL) { +%% else + if (res) { +%% endif + switch (errno) { + case ENOSYS: + tst_msg("Not Implemented"); + return TST_SUCCESS; + break; + case EINVAL: + tst_msg("Not suitable pixel type"); + return TST_SUCCESS; + break; + default: + tst_msg("Unexpected errno %s", strerror(errno)); + return TST_FAILED; + } + }
return TST_SUCCESS; } +%% endfor
+%% for fn in API_List +%% for pt in pixeltypes +%% if not pt.is_unknown() +static int filter_{{ fn[0] }}_{{ fn[1] }}_{{ pt.name }}(void) +{ + return filter_{{ fn[0] }}_{{ fn[1] }}({{ pt.C_type }}); +} %% endif %% endfor %% endfor @@ -207,8 +266,8 @@ const struct tst_suite tst_suite = { %% for fn in API_List %% for pt in pixeltypes %% if not pt.is_unknown() - {.name = "Filter {{ fn[0] }} {{ pt.name }}", - .tst_fn = Filter_{{ fn[0] }}_{{ pt.name }}}, + {.name = "Filter {{ fn[0] }} {{ fn[1] }} {{ pt.name }}", + .tst_fn = filter_{{ fn[0] }}_{{ fn[1] }}_{{ pt.name }}}, %% endif %% endfor %% endfor
http://repo.or.cz/w/gfxprim.git/commit/74c604b15d7fcc320bd64b1efda533ea0d54c...
commit 74c604b15d7fcc320bd64b1efda533ea0d54c228 Author: Cyril Hrubis metan@ucw.cz Date: Mon Oct 7 17:59:39 2013 +0200
tests: filters: Implement compare tests.
The tests runs the same filter using different APIs and compares results, fails if resulting contexts does not match.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/filters/FiltersCompare.gen.c.t b/tests/filters/FiltersCompare.gen.c.t new file mode 100644 index 0000000..5ee38c6 --- /dev/null +++ b/tests/filters/FiltersCompare.gen.c.t @@ -0,0 +1,241 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim 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 * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +%% extends "base.test.c.t" + +%% block descr +Filters Compare + +Calls different API for the same filter (Alloc vs In-place, etc.) and copares +the results (which must be the same). +%% endblock descr + +%% block body + +#include <stdio.h> +#include <errno.h> +#include <string.h> + +#include <core/GP_Context.h> +#include <filters/GP_Filters.h> + +#include "tst_test.h" + +/* +The format is [[name1, [fn1, [params]], [fn2, [params]], ...], + [name2, [fn3, [params]], [fn4, [params]], ...], + ...] + +All results from filters listed under one name are compared. +*/ +%% set compare_list = [['MirrorH', + ['MirrorH', ['dst', 'dst', 'NULL']], + ['MirrorHAlloc', ['src', 'NULL']], + ['Symmetry', ['dst', 'dst', 'GP_MIRROR_H', 'NULL']], + ['SymmetryAlloc', ['src', 'GP_MIRROR_H', 'NULL']], + ], + ['MirrorV', + ['MirrorV', ['dst', 'dst', 'NULL']], + ['MirrorVAlloc', ['src', 'NULL']], + ['Symmetry', ['dst', 'dst', 'GP_MIRROR_V', 'NULL']], + ['SymmetryAlloc', ['src', 'GP_MIRROR_V', 'NULL']], + ], + ['Rotate90', + ['Rotate90', ['dst', 'dst', 'NULL']], + ['Rotate90Alloc', ['src', 'NULL']], + ['Symmetry', ['dst', 'dst', 'GP_ROTATE_90', 'NULL']], + ['SymmetryAlloc', ['src', 'GP_ROTATE_90', 'NULL']], + ], + ['Rotate180', + ['Rotate180', ['dst', 'dst', 'NULL']], + ['Rotate180Alloc', ['src', 'NULL']], + ['Symmetry', ['dst', 'dst', 'GP_ROTATE_180', 'NULL']], + ['SymmetryAlloc', ['src', 'GP_ROTATE_180', 'NULL']], + ], + ['Rotate270', + ['Rotate270', ['dst', 'dst', 'NULL']], + ['Rotate270Alloc', ['src', 'NULL']], + ['Symmetry', ['dst', 'dst', 'GP_ROTATE_270', 'NULL']], + ['SymmetryAlloc', ['src', 'GP_ROTATE_270', 'NULL']], + ], + + ['ResizeNN', + ['Resize', ['dst', 'dst', 'GP_INTERP_NN', 'NULL']], + ['ResizeAlloc', ['src', 'src->w', 'src->h', + 'GP_INTERP_NN', 'NULL']], + ], + ['ResizeLinearInt', + ['Resize', ['dst', 'dst', 'GP_INTERP_LINEAR_INT', 'NULL']], + ['ResizeAlloc', ['src', 'src->w', 'src->h', + 'GP_INTERP_LINEAR_INT', 'NULL']], + ], + ['ResizeLinearLFInt', + ['Resize', ['dst', 'dst', 'GP_INTERP_LINEAR_LF_INT', 'NULL']], + ['ResizeAlloc', ['src', 'src->w', 'src->h', + 'GP_INTERP_LINEAR_LF_INT', 'NULL']], + ], + ['ResizeCubicInt', + ['Resize', ['dst', 'dst', 'GP_INTERP_CUBIC_INT', 'NULL']], + ['ResizeAlloc', ['src', 'src->w', 'src->h', + 'GP_INTERP_CUBIC_INT', 'NULL']], + ], + ['ResizeCubic', + ['Resize', ['dst', 'dst', 'GP_INTERP_CUBIC', 'NULL']], + ['ResizeAlloc', ['src', 'src->w', 'src->h', + 'GP_INTERP_CUBIC', 'NULL']], + ], + + ['Laplace', + ['Laplace', ['dst', 'dst', 'NULL']], + ['LaplaceAlloc', ['src', 'NULL']], + ], + ['EdgeSharpening', + ['EdgeSharpening', ['dst', 'dst', '0.2', 'NULL']], + ['EdgeSharpeningAlloc', ['src', '0.2', 'NULL']], + ], + + ['Median', + ['Median', ['dst', 'dst', '3', '2', 'NULL']], + ['MedianAlloc', ['src', '3', '2', 'NULL']], + ], + + ['Sigma', + ['Sigma', ['dst', 'dst', '3', '2', '4', '0.5', 'NULL']], + ['SigmaAlloc', ['src', '3', '2', '4', '0.5', 'NULL']], + ], + + ['GaussianBlur', + ['GaussianBlur', ['dst', 'dst', '10', '12', 'NULL']], + ['GaussianBlurAlloc', ['src', '10', '12', 'NULL']] + ], +] + +%%- macro arr2params(arr) +{{ arr[0] }}{% for i in arr[1:] %}, {{ i }}{% endfor%} +%%- endmacro + +%% macro apply_filter(filter) +%% if 'dst' in filter[1] + dst = GP_ContextCopy(src, GP_COPY_WITH_PIXELS); + if (GP_Filter{{ filter[0] }}({{ arr2params(filter[1]) }})) { + int err = errno; + GP_ContextFree(dst); + dst = NULL; + errno = err; + } + +%% else + dst = GP_Filter{{ filter[0] }}({{ arr2params(filter[1]) }}); +%% endif + +%% endmacro + + +%% for fs in compare_list +static int compare_{{ fs[0] }}(GP_PixelType pt) +{ + GP_Context *src = GP_ContextAlloc(134, 1072, pt); + GP_Context *dst, *ref; + int fail = 0; + + errno = 0; + + if (!src) { + tst_msg("Malloc Failed :("); + return TST_UNTESTED; + } + + /* randomize context content */ + GP_FilterGaussianNoiseAdd(src, src, 10, 0, NULL); + + /* Create reference result */ +{{ apply_filter(fs[1]) }} + ref = dst; + + if (ref == NULL) { + GP_ContextFree(src); + switch (errno) { + case ENOSYS: + tst_msg("Not implemented"); + return TST_SKIPPED; + case EINVAL: + tst_msg("Couldn't be implemented"); + return TST_SKIPPED; + default: + tst_msg("Unexpected errno %s", strerror(errno)); + return TST_FAILED; + } + } + +%% for i in fs[2:] +{{ apply_filter(i) }} + + if (!GP_ContextEqual(ref, dst)) { + fail++; + tst_msg("Results for {{ fs[1][0] }} and {{ i[0] }} differs"); + } + + + GP_ContextFree(dst); +%% endfor + + GP_ContextFree(src); + GP_ContextFree(ref); + + if (fail) { + tst_msg("%i failure(s)", fail); + return TST_FAILED; + } + + return TST_SUCCESS; +} + +%% endfor + +%% for fs in compare_list +%% for pt in pixeltypes +%% if not pt.is_unknown() +static int compare_{{ fs[0] }}_{{ pt.name }}(void) +{ + return compare_{{ fs[0] }}({{ pt.C_type }}); +} +%% endif +%% endfor +%% endfor + +const struct tst_suite tst_suite = { + .suite_name = "Filters Compare", + .tests = { +%% for fs in compare_list +%% for pt in pixeltypes +%% if not pt.is_unknown() + {.name = "Compare {{ fs[0] }} {{ pt.name }}", + .tst_fn = compare_{{ fs[0] }}_{{ pt.name }}, + .flags = TST_CHECK_MALLOC}, +%% endif +%% endfor +%% endfor + {.name = NULL} + } +}; + +%% endblock body diff --git a/tests/filters/Makefile b/tests/filters/Makefile index 986710f..8834428 100644 --- a/tests/filters/Makefile +++ b/tests/filters/Makefile @@ -3,9 +3,9 @@ include $(TOPDIR)/pre.mk
CSOURCES=FilterMirrorH.c
-GENSOURCES=APICoverage.gen.c +GENSOURCES=APICoverage.gen.c FiltersCompare.gen.c
-APPS=FilterMirrorH APICoverage.gen +APPS=FilterMirrorH APICoverage.gen FiltersCompare.gen
include ../tests.mk
diff --git a/tests/filters/test_list.txt b/tests/filters/test_list.txt index 4b3dee1..0e62d87 100644 --- a/tests/filters/test_list.txt +++ b/tests/filters/test_list.txt @@ -1,4 +1,5 @@ # Filters test list
APICoverage.gen +FiltersCompare.gen FilterMirrorH
-----------------------------------------------------------------------
Summary of changes: tests/filters/APICoverage.gen.c.t | 159 +++++++++++++++------- tests/filters/FiltersCompare.gen.c.t | 241 ++++++++++++++++++++++++++++++++++ tests/filters/Makefile | 4 +- tests/filters/test_list.txt | 1 + 4 files changed, 353 insertions(+), 52 deletions(-) create mode 100644 tests/filters/FiltersCompare.gen.c.t
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.