3 * Filters API coverage tests.
5 * The purpose of this test is to exercise as much codepaths as possible
6 * without checking for result corectness.
8 * We check for correct return value correcness though.
10 * Copyright (C) 2009-2014 Cyril Hrubis <metan@ucw.cz>
17 #include <core/GP_Pixmap.h>
18 #include <filters/GP_Filters.h>
23 @ ['Brightness', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
24 @ 'float:p', 'GP_ProgressCallback'],
25 @ ['BrightnessAlloc', '', 'GP_Pixmap:in',
26 @ 'float:p', 'GP_ProgressCallback'],
28 @ ['Contrast', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
29 @ 'float:p', 'GP_ProgressCallback'],
30 @ ['ContrastAlloc', '', 'GP_Pixmap:in',
31 @ 'float:p', 'GP_ProgressCallback'],
33 @ ['Invert', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
34 @ 'GP_ProgressCallback'],
35 @ ['InvertAlloc', '', 'GP_Pixmap:in',
36 @ 'GP_ProgressCallback'],
38 @ ['MirrorH', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
39 @ 'GP_ProgressCallback'],
40 @ ['MirrorHAlloc', '', 'GP_Pixmap:in', 'GP_ProgressCallback'],
42 @ ['MirrorV', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
43 @ 'GP_ProgressCallback'],
44 @ ['MirrorVAlloc', '', 'GP_Pixmap:in', 'GP_ProgressCallback'],
46 @ ['Rotate90', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
47 @ 'GP_ProgressCallback'],
48 @ ['Rotate90Alloc', '', 'GP_Pixmap:in', 'GP_ProgressCallback'],
50 @ ['Rotate180', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
51 @ 'GP_ProgressCallback'],
52 @ ['Rotate180Alloc', '', 'GP_Pixmap:in', 'GP_ProgressCallback'],
54 @ ['Rotate270', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
55 @ 'GP_ProgressCallback'],
56 @ ['Rotate270Alloc', '', 'GP_Pixmap:in', 'GP_ProgressCallback'],
58 @ ['Symmetry', 'H', 'GP_Pixmap:in', 'GP_Pixmap:out',
59 @ 'GP_MIRROR_H', 'GP_ProgressCallback'],
60 @ ['SymmetryAlloc', 'H', 'GP_Pixmap:in', 'GP_MIRROR_H',
61 @ 'GP_ProgressCallback'],
63 @ ['Symmetry', 'V', 'GP_Pixmap:in', 'GP_Pixmap:out',
64 @ 'GP_MIRROR_V', 'GP_ProgressCallback'],
65 @ ['SymmetryAlloc', 'V', 'GP_Pixmap:in', 'GP_MIRROR_V',
66 @ 'GP_ProgressCallback'],
68 @ ['Symmetry', '90', 'GP_Pixmap:in', 'GP_Pixmap:out',
69 @ 'GP_ROTATE_90', 'GP_ProgressCallback'],
70 @ ['SymmetryAlloc', '90', 'GP_Pixmap:in', 'GP_ROTATE_90',
71 @ 'GP_ProgressCallback'],
73 @ ['Symmetry', '180', 'GP_Pixmap:in', 'GP_Pixmap:out',
74 @ 'GP_ROTATE_180', 'GP_ProgressCallback'],
75 @ ['SymmetryAlloc', '180', 'GP_Pixmap:in', 'GP_ROTATE_180',
76 @ 'GP_ProgressCallback'],
78 @ ['Symmetry', '270', 'GP_Pixmap:in', 'GP_Pixmap:out',
79 @ 'GP_ROTATE_270', 'GP_ProgressCallback'],
80 @ ['SymmetryAlloc', '270', 'GP_Pixmap:in', 'GP_ROTATE_270',
81 @ 'GP_ProgressCallback'],
83 @ ['Convolution', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
84 @ 'GP_FilterKernel2D:kernel', 'GP_ProgressCallback'],
85 @ ['ConvolutionAlloc', '', 'GP_Pixmap:in',
86 @ 'GP_FilterKernel2D:kernel', 'GP_ProgressCallback'],
88 @ ['GaussianBlur', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
89 @ 'float:sigma_x', 'float:sigma_y', 'GP_ProgressCallback'],
90 @ ['GaussianBlurAlloc', '', 'GP_Pixmap:in', 'float:sigma_x',
91 @ 'float:sigma_y', 'GP_ProgressCallback'],
93 @ ['GaussianNoiseAdd', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
94 @ 'float:sigma', 'float:mu', 'GP_ProgressCallback'],
95 @ ['GaussianNoiseAddAlloc', '', 'GP_Pixmap:in',
96 @ 'float:sigma', 'float:mu', 'GP_ProgressCallback'],
98 @ ['Median', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
99 @ 'int:xmed', 'int:ymed', 'GP_ProgressCallback'],
100 @ ['MedianAlloc', '', 'GP_Pixmap:in',
101 @ 'int:xmed', 'int:ymed', 'GP_ProgressCallback'],
103 @ ['WeightedMedian', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
104 @ 'GP_MedianWeights:weights', 'GP_ProgressCallback'],
105 @ ['WeightedMedianAlloc', '', 'GP_Pixmap:in',
106 @ 'GP_MedianWeights:weights', 'GP_ProgressCallback'],
108 @ ['Sigma', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
109 @ 'int:xrad', 'int:yrad', 'int:min', 'float:sigma',
110 @ 'GP_ProgressCallback'],
111 @ ['SigmaAlloc', '', 'GP_Pixmap:in',
112 @ 'int:xrad', 'int:yrad', 'int:min', 'float:sigma',
113 @ 'GP_ProgressCallback'],
115 @ ['ResizeNN', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
116 @ 'GP_ProgressCallback'],
117 @ ['ResizeNNAlloc', '', 'GP_Pixmap:in', 'int:w', 'int:h',
118 @ 'GP_ProgressCallback'],
120 @ ['FloydSteinberg', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
121 @ 'GP_ProgressCallback'],
122 @ ['FloydSteinbergAlloc', '', 'GP_Pixmap:in', 'GP_PixelType:G8',
123 @ 'GP_ProgressCallback'],
125 @ ['HilbertPeano', '', 'GP_Pixmap:in', 'GP_Pixmap:out',
126 @ 'GP_ProgressCallback'],
127 @ ['HilbertPeanoAlloc', '', 'GP_Pixmap:in', 'GP_PixelType:G8',
128 @ 'GP_ProgressCallback'],
131 @ def prep_pixmap(id):
132 GP_Pixmap *{{ id }} = GP_PixmapAlloc(331, 331, pt);
134 @ def prep_float(id):
140 @ def prep_pixel_type(id):
141 GP_PixelType {{ id }} = GP_PIXEL_{{ id }};
143 @ def prep_median_weights(id):
145 unsigned int {{ id }}_w[] = {
151 GP_MedianWeights {{ id }}_s = {
154 .weights = {{ id }}_w,
157 GP_MedianWeights *{{ id }} = &{{ id }}_s;
159 @ def prep_filter_kernel_2d(id):
160 float {{ id }}_kern[] = {
166 GP_FilterKernel2D {{ id }}_s = {
170 .kernel = {{ id }}_kern,
173 GP_FilterKernel2D *{{ id }} = &{{ id }}_s;
176 @ def prep_param(param):
177 @ if (param.split(':', 1)[0] == 'GP_Pixmap'):
178 {@ prep_pixmap(param.split(':', 1)[1]) @}
179 @ if (param.split(':', 1)[0] == 'float'):
180 {@ prep_float(param.split(':', 1)[1]) @}
181 @ if (param.split(':', 1)[0] == 'int'):
182 {@ prep_int(param.split(':', 1)[1]) @}
183 @ if (param.split(':', 1)[0] == 'GP_MedianWeights'):
184 {@ prep_median_weights(param.split(':', 1)[1]) @}
185 @ if (param.split(':', 1)[0] == 'GP_FilterKernel2D'):
186 {@ prep_filter_kernel_2d(param.split(':', 1)[1]) @}
187 @ if (param.split(':', 1)[0] == 'GP_PixelType'):
188 {@ prep_pixel_type(param.split(':', 1)[1]) @}
190 @ def do_param(param):
191 @ if param == 'GP_ProgressCallback':
196 @ def get_param(param):
197 @ if len(param.split(':', 1)) == 1:
198 @ return do_param(param)
200 @ return param.split(':', 1)[1]
202 @ def gen_params(params):
203 @ res = map(get_param, params)
204 @ return ', '.join(res)
206 @ for fn in API_List:
207 static int filter_{{ fn[0] }}_{{ fn[1] }}(GP_PixelType pt)
209 @ for param in fn[1:]:
210 {@ prep_param(param) @}
211 @ if 'Alloc' in fn[0]:
217 res = GP_Filter{{ fn[0] }}({{ gen_params(fn[2:]) }});
219 @ if 'Alloc' in fn[0]:
226 tst_msg("Not Implemented");
230 tst_msg("Not suitable pixel type");
234 tst_msg("Unexpected errno %s", strerror(errno));
243 @ for fn in API_List:
244 @ for pt in pixeltypes:
245 @ if not pt.is_unknown():
246 static int filter_{{ fn[0] }}_{{ fn[1] }}_{{ pt.name }}(void)
248 return filter_{{ fn[0] }}_{{ fn[1] }}({{ pt.C_type }});
252 const struct tst_suite tst_suite = {
253 .suite_name = "Filters API Coverage",
255 @ for fn in API_List:
256 @ for pt in pixeltypes:
257 @ if not pt.is_unknown():
258 {.name = "Filter {{ fn[0] }} {{ fn[1] }} {{ pt.name }}",
259 .tst_fn = filter_{{ fn[0] }}_{{ fn[1] }}_{{ pt.name }}},