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_progress_cb'],
25 @ ['brightness_alloc', '', 'gp_pixmap:in',
26 @ 'float:p', 'gp_progress_cb'],
28 @ ['contrast', '', 'gp_pixmap:in', 'gp_pixmap:out',
29 @ 'float:p', 'gp_progress_cb'],
30 @ ['contrast_alloc', '', 'gp_pixmap:in',
31 @ 'float:p', 'gp_progress_cb'],
33 @ ['invert', '', 'gp_pixmap:in', 'gp_pixmap:out',
35 @ ['invert_alloc', '', 'gp_pixmap:in',
38 @ ['mirror_h', '', 'gp_pixmap:in', 'gp_pixmap:out',
40 @ ['mirror_h_alloc', '', 'gp_pixmap:in', 'gp_progress_cb'],
42 @ ['mirror_v', '', 'gp_pixmap:in', 'gp_pixmap:out',
44 @ ['mirror_v_alloc', '', 'gp_pixmap:in', 'gp_progress_cb'],
46 @ ['rotate_90', '', 'gp_pixmap:in', 'gp_pixmap:out',
48 @ ['rotate_90_alloc', '', 'gp_pixmap:in', 'gp_progress_cb'],
50 @ ['rotate_180', '', 'gp_pixmap:in', 'gp_pixmap:out',
52 @ ['rotate_180_alloc', '', 'gp_pixmap:in', 'gp_progress_cb'],
54 @ ['rotate_270', '', 'gp_pixmap:in', 'gp_pixmap:out',
56 @ ['rotate_270_alloc', '', 'gp_pixmap:in', 'gp_progress_cb'],
58 @ ['symmetry', 'H', 'gp_pixmap:in', 'gp_pixmap:out',
59 @ 'GP_MIRROR_H', 'gp_progress_cb'],
60 @ ['symmetry_alloc', 'H', 'gp_pixmap:in', 'GP_MIRROR_H',
63 @ ['symmetry', 'V', 'gp_pixmap:in', 'gp_pixmap:out',
64 @ 'GP_MIRROR_V', 'gp_progress_cb'],
65 @ ['symmetry_alloc', 'V', 'gp_pixmap:in', 'GP_MIRROR_V',
68 @ ['symmetry', '90', 'gp_pixmap:in', 'gp_pixmap:out',
69 @ 'GP_ROTATE_90', 'gp_progress_cb'],
70 @ ['symmetry_alloc', '90', 'gp_pixmap:in', 'GP_ROTATE_90',
73 @ ['symmetry', '180', 'gp_pixmap:in', 'gp_pixmap:out',
74 @ 'GP_ROTATE_180', 'gp_progress_cb'],
75 @ ['symmetry_alloc', '180', 'gp_pixmap:in', 'GP_ROTATE_180',
78 @ ['symmetry', '270', 'gp_pixmap:in', 'gp_pixmap:out',
79 @ 'GP_ROTATE_270', 'gp_progress_cb'],
80 @ ['symmetry_alloc', '270', 'gp_pixmap:in', 'GP_ROTATE_270',
83 @ ['convolution', '', 'gp_pixmap:in', 'gp_pixmap:out',
84 @ 'gp_filter_kernel_2d:kernel', 'gp_progress_cb'],
85 @ ['convolution_alloc', '', 'gp_pixmap:in',
86 @ 'gp_filter_kernel_2d:kernel', 'gp_progress_cb'],
88 @ ['gaussian_blur', '', 'gp_pixmap:in', 'gp_pixmap:out',
89 @ 'float:sigma_x', 'float:sigma_y', 'gp_progress_cb'],
90 @ ['gaussian_blur_alloc', '', 'gp_pixmap:in', 'float:sigma_x',
91 @ 'float:sigma_y', 'gp_progress_cb'],
93 @ ['gaussian_noise_add', '', 'gp_pixmap:in', 'gp_pixmap:out',
94 @ 'float:sigma', 'float:mu', 'gp_progress_cb'],
95 @ ['gaussian_noise_add_alloc', '', 'gp_pixmap:in',
96 @ 'float:sigma', 'float:mu', 'gp_progress_cb'],
98 @ ['median', '', 'gp_pixmap:in', 'gp_pixmap:out',
99 @ 'int:xmed', 'int:ymed', 'gp_progress_cb'],
100 @ ['median_alloc', '', 'gp_pixmap:in',
101 @ 'int:xmed', 'int:ymed', 'gp_progress_cb'],
103 @ ['weighted_median', '', 'gp_pixmap:in', 'gp_pixmap:out',
104 @ 'gp_median_weights:weights', 'gp_progress_cb'],
105 @ ['weighted_median_alloc', '', 'gp_pixmap:in',
106 @ 'gp_median_weights:weights', 'gp_progress_cb'],
108 @ ['sigma', '', 'gp_pixmap:in', 'gp_pixmap:out',
109 @ 'int:xrad', 'int:yrad', 'int:min', 'float:sigma',
111 @ ['sigma_alloc', '', 'gp_pixmap:in',
112 @ 'int:xrad', 'int:yrad', 'int:min', 'float:sigma',
115 @ ['resize_nn', '', 'gp_pixmap:in', 'gp_pixmap:out',
117 @ ['resize_nn_alloc', '', 'gp_pixmap:in', 'int:w', 'int:h',
120 @ ['floyd_steinberg', '', 'gp_pixmap:in', 'gp_pixmap:out',
122 @ ['floyd_steinberg_alloc', '', 'gp_pixmap:in', 'gp_pixel_type:G8',
125 @ ['hilbert_peano', '', 'gp_pixmap:in', 'gp_pixmap:out',
127 @ ['hilbert_peano_alloc', '', 'gp_pixmap:in', 'gp_pixel_type:G8',
131 @ def prep_pixmap(id):
132 gp_pixmap *{{ id }} = gp_pixmap_alloc(331, 331, pt);
134 @ def prep_float(id):
140 @ def prep_pixel_type(id):
141 gp_pixel_type {{ id }} = GP_PIXEL_{{ id }};
143 @ def prep_median_weights(id):
145 unsigned int {{ id }}_w[] = {
151 gp_median_weights {{ id }}_s = {
154 .weights = {{ id }}_w,
157 gp_median_weights *{{ id }} = &{{ id }}_s;
159 @ def prep_filter_kernel_2d(id):
160 float {{ id }}_kern[] = {
166 gp_filter_kernel_2d {{ id }}_s = {
170 .kernel = {{ id }}_kern,
173 gp_filter_kernel_2d *{{ 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_median_weights'):
184 {@ prep_median_weights(param.split(':', 1)[1]) @}
185 @ if (param.split(':', 1)[0] == 'gp_filter_kernel_2d'):
186 {@ prep_filter_kernel_2d(param.split(':', 1)[1]) @}
187 @ if (param.split(':', 1)[0] == 'gp_pixel_type'):
188 {@ prep_pixel_type(param.split(':', 1)[1]) @}
190 @ def do_param(param):
191 @ if param == 'gp_progress_cb':
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_pixel_type 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 }}},