From 3d14cb78419fe54e86e6a838b919a303ae9e536f Mon Sep 17 00:00:00 2001 From: Cyril Hrubis Date: Mon, 7 Oct 2013 18:42:21 +0200 Subject: [PATCH] tests: filters: Better API Converage test. * More filters covered * Now with checks for correct errno values Signed-off-by: Cyril Hrubis --- tests/filters/APICoverage.gen.c.t | 159 ++++++++++++++++++++++++++------------ 1 file changed, 109 insertions(+), 50 deletions(-) diff --git a/tests/filters/APICoverage.gen.c.t b/tests/filters/APICoverage.gen.c.t index 323f6141..b4c82816 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 +#include +#include #include #include #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 -- 2.11.4.GIT