• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * v4l-test: Test environment for Video For Linux Two API
3  *
4  * 16 Jul 2009  0.24 Test cases added for VIDIOC_G_JPEGCOMP and VIDIOC_ENUM_FRAMESIZES
5  * 23 May 2009  0.23 Test cases added for VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS
6  *  5 May 2009  0.22 Test cases added for VIDIOC_QUERYBUF
7  * 29 Apr 2009  0.21 Test cases added for VIDIOC_REQBUFS
8  * 18 Apr 2009  0.20 NULL parameter test suite split to read only, write only
9  *                   and write/read ioctl suite
10  * 16 Apr 2009  0.19 Test cases added for VIDIOC_S_FMT
11  *  5 Apr 2009  0.18 Test cases for VIDIOC_QUERYMENU added
12  *  4 Apr 2009  0.17 Test cases for VIDIOC_G_FMT added
13  * 29 Mar 2009  0.16 Test case for VIDIOC_S_FREQUENCY with NULL parameter added
14  * 22 Mar 2009  0.15 Test cases added for VIDIOC_G_OUTPUT and VIDIOC_S_OUTPUT
15  * 18 Mar 2009  0.14 Test cases added for VIDIOC_G_PARM
16  *  7 Mar 2009  0.13 Test cases added for VIDIOC_S_CROP
17  * 22 Feb 2009  0.12 Test cases added for VIDIOC_S_CTRL
18  * 19 Feb 2009  0.11 Test cases added for VIDIOC_G_CTRL
19  *  7 Feb 2009  0.10 Test cases added for VIDIOC_G_AUDIO, VIDIOC_G_AUDOUT,
20  *                   VIDIOC_S_AUDIO and VIDIOC_G_CROP
21  *  3 Feb 2009  0.9  Test cases for VIDIOC_G_AUDIO and VIDIOC_G_AUDOUT added
22  *  2 Feb 2009  0.8  Test cases for VIDIOC_G_MODULATOR, VIDIOC_G_PRIORITY
23  *                   and VIDIOC_S_PRIORITY added
24  *  1 Feb 2009  0.7  Test cases for VIDIOC_S_FREQUENCY added
25  * 31 Jan 2009  0.6  Test cases for VIDIOC_G_TUNER added
26  * 18 Jan 2009  0.5  Test cases for MAX_EM28XX_INPUT and MAX_EM28XX_TVNORMS
27  *                   removed
28  *  1 Jan 2009  0.4  Test cases for VIDIOC_ENUMOUTPUT, VIDIOC_ENUMAUDOUT,
29  *                   VIDIOC_QUERYCTRL added;
30  *                   New test cases for VIDIOC_ENUMAUDIO, VIDIOC_ENUM_FMT,
31  *                   VIDIOC_ENUM_STD
32  * 23 Dec 2008  0.3  Test cases for VIDIOC_LOG_STATUS added
33  * 22 Dec 2008  0.2  Test cases with NULL parameter added;
34  *                   Test cases for VIDIOC_CROPCAP added
35  * 18 Dec 2008  0.1  First release
36  *
37  * Written by M�rton N�meth <nm127@freemail.hu>
38  * Released under GPL
39  */
40 
41 #include <stdio.h>
42 #include <sys/types.h>
43 #include <sys/stat.h>
44 #include <fcntl.h>
45 #include <unistd.h>
46 #include <sys/ioctl.h>
47 #include <errno.h>
48 #include <string.h>
49 
50 #include <linux/videodev2.h>
51 #include <linux/errno.h>
52 
53 #include <CUnit/CUnit.h>
54 #include <CUnit/Basic.h>
55 
56 #include "v4l2_test.h"
57 #include "dev_video.h"
58 #include "video_limits.h"
59 
60 #include "test_VIDIOC_QUERYCAP.h"
61 #include "test_VIDIOC_QUERYSTD.h"
62 #include "test_VIDIOC_QUERYCTRL.h"
63 #include "test_VIDIOC_QUERYMENU.h"
64 #include "test_VIDIOC_CROPCAP.h"
65 #include "test_VIDIOC_G_SLICED_VBI_CAP.h"
66 
67 #include "test_VIDIOC_ENUMAUDIO.h"
68 #include "test_VIDIOC_ENUMAUDOUT.h"
69 #include "test_VIDIOC_ENUMSTD.h"
70 #include "test_VIDIOC_ENUM_FMT.h"
71 #include "test_VIDIOC_ENUMINPUT.h"
72 #include "test_VIDIOC_ENUMOUTPUT.h"
73 #include "test_VIDIOC_ENUM_FRAMESIZES.h"
74 
75 #include "test_VIDIOC_STD.h"
76 #include "test_VIDIOC_INPUT.h"
77 #include "test_VIDIOC_OUTPUT.h"
78 #include "test_VIDIOC_TUNER.h"
79 #include "test_VIDIOC_MODULATOR.h"
80 #include "test_VIDIOC_FREQUENCY.h"
81 #include "test_VIDIOC_PRIORITY.h"
82 #include "test_VIDIOC_AUDIO.h"
83 #include "test_VIDIOC_AUDOUT.h"
84 #include "test_VIDIOC_CROP.h"
85 #include "test_VIDIOC_CTRL.h"
86 #include "test_VIDIOC_EXT_CTRLS.h"
87 #include "test_VIDIOC_PARM.h"
88 #include "test_VIDIOC_FMT.h"
89 #include "test_VIDIOC_JPEGCOMP.h"
90 
91 #include "test_VIDIOC_REQBUFS.h"
92 #include "test_VIDIOC_QUERYBUF.h"
93 
94 #include "test_VIDIOC_LOG_STATUS.h"
95 #include "test_invalid_ioctl.h"
96 
97 static CU_TestInfo suite_querycap[] = {
98 	{"VIDIOC_QUERYCAP", test_VIDIOC_QUERYCAP},
99 
100 	{"VIDIOC_CROPCAP", test_VIDIOC_CROPCAP},
101 	{"VIDIOC_CROPCAP with different inputs",
102 	 test_VIDIOC_CROPCAP_enum_INPUT},
103 
104 	{"VIDIOC_G_SLICED_VBI_CAP", test_VIDIOC_G_SLICED_VBI_CAP},
105 	{"VIDIOC_G_SLICED_VBI_CAP with invalid types",
106 	 test_VIDIOC_G_SLICED_VBI_CAP_invalid},
107 
108 	CU_TEST_INFO_NULL,
109 };
110 
111 static CU_TestInfo suite_enums[] = {
112 	{"VIDIOC_ENUMAUDIO", test_VIDIOC_ENUMAUDIO},
113 	{"VIDIOC_ENUMAUDIO, index=S32_MAX", test_VIDIOC_ENUMAUDIO_S32_MAX},
114 	{"VIDIOC_ENUMAUDIO, index=S32_MAX+1", test_VIDIOC_ENUMAUDIO_S32_MAX_1},
115 	{"VIDIOC_ENUMAUDIO, index=U32_MAX", test_VIDIOC_ENUMAUDIO_U32_MAX},
116 
117 	{"VIDIOC_ENUMAUDOUT", test_VIDIOC_ENUMAUDOUT},
118 	{"VIDIOC_ENUMAUDOUT, index=S32_MAX", test_VIDIOC_ENUMAUDOUT_S32_MAX},
119 	{"VIDIOC_ENUMAUDOUT, index=S32_MAX+1",
120 	 test_VIDIOC_ENUMAUDOUT_S32_MAX_1},
121 	{"VIDIOC_ENUMAUDOUT, index=U32_MAX", test_VIDIOC_ENUMAUDOUT_U32_MAX},
122 
123 	{"VIDIOC_ENUM_FMT", test_VIDIOC_ENUM_FMT},
124 	{"VIDIOC_ENUM_FMT, index=S32_MAX", test_VIDIOC_ENUM_FMT_S32_MAX},
125 	{"VIDIOC_ENUM_FMT, index=S32_MAX+1", test_VIDIOC_ENUM_FMT_S32_MAX_1},
126 	{"VIDIOC_ENUM_FMT, index=U32_MAX", test_VIDIOC_ENUM_FMT_U32_MAX},
127 	{"VIDIOC_ENUM_FMT, invalid type", test_VIDIOC_ENUM_FMT_invalid_type},
128 
129 	{"VIDIOC_ENUMINPUT", test_VIDIOC_ENUMINPUT},
130 	{"VIDIOC_ENUMINPUT, index=S32_MAX", test_VIDIOC_ENUMINPUT_S32_MAX},
131 	{"VIDIOC_ENUMINPUT, index=S32_MAX+1", test_VIDIOC_ENUMINPUT_S32_MAX_1},
132 	{"VIDIOC_ENUMINPUT, index=U32_MAX", test_VIDIOC_ENUMINPUT_U32_MAX},
133 
134 	{"VIDIOC_ENUMOUTPUT", test_VIDIOC_ENUMOUTPUT},
135 	{"VIDIOC_ENUMOUTPUT, index=S32_MAX", test_VIDIOC_ENUMOUTPUT_S32_MAX},
136 	{"VIDIOC_ENUMOUTPUT, index=S32_MAX+1",
137 	 test_VIDIOC_ENUMOUTPUT_S32_MAX_1},
138 	{"VIDIOC_ENUMOUTPUT, index=U32_MAX", test_VIDIOC_ENUMOUTPUT_U32_MAX},
139 
140 	{"VIDIOC_ENUMSTD", test_VIDIOC_ENUMSTD},
141 	{"VIDIOC_ENUMSTD, index=S32_MAX", test_VIDIOC_ENUMSTD_S32_MAX},
142 	{"VIDIOC_ENUMSTD, index=S32_MAX+1", test_VIDIOC_ENUMSTD_S32_MAX_1},
143 	{"VIDIOC_ENUMSTD, index=U32_MAX", test_VIDIOC_ENUMSTD_U32_MAX},
144 
145 	{"VIDIOC_QUERYCTRL", test_VIDIOC_QUERYCTRL},
146 	{"VIDIOC_QUERYCTRL, id=V4L2_CID_BASE-1", test_VIDIOC_QUERYCTRL_BASE_1},
147 	{"VIDIOC_QUERYCTRL, id=V4L2_CID_LASTP1", test_VIDIOC_QUERYCTRL_LASTP1},
148 	{"VIDIOC_QUERYCTRL, id=V4L2_CID_LASTP1+1",
149 	 test_VIDIOC_QUERYCTRL_LASTP1_1},
150 	{"VIDIOC_QUERYCTRL with V4L2_CTRL_FLAG_NEXT_CTRL",
151 	 test_VIDIOC_QUERYCTRL_flag_NEXT_CTRL},
152 	{"VIDIOC_QUERYCTRL, enumerate private controls",
153 	 test_VIDIOC_QUERYCTRL_private},
154 	{"VIDIOC_QUERYCTRL, V4L2_CID_PRIVATE_BASE-1",
155 	 test_VIDIOC_QUERYCTRL_private_base_1},
156 	{"VIDIOC_QUERYCTRL, last private control+1",
157 	 test_VIDIOC_QUERYCTRL_private_last_1},
158 
159 	{"VIDIOC_QUERYMENU", test_VIDIOC_QUERYMENU},
160 	{"VIDIOC_QUERYMENU with invalid id", test_VIDIOC_QUERYMENU_invalid},
161 	{"VIDIOC_QUERYMENU with private controls",
162 	 test_VIDIOC_QUERYMENU_private},
163 	{"VIDIOC_QUERYMENU, last private control+1",
164 	 test_VIDIOC_QUERYMENU_private_last_1},
165 
166 	{"VIDIOC_ENUM_FRAMESIZES", test_VIDIOC_ENUM_FRAMESIZES},
167 	{"VIDIOC_ENUM_FRAMESIZES with invalid index",
168 	 test_VIDIOC_ENUM_FRAMESIZES_invalid_index},
169 	{"VIDIOC_ENUM_FRAMESIZES with invalid pixel_format",
170 	 test_VIDIOC_ENUM_FRAMESIZES_invalid_pixel_format},
171 
172 	CU_TEST_INFO_NULL,
173 };
174 
175 static CU_TestInfo suite_get_set_try[] = {
176 	{"VIDIOC_G_STD", test_VIDIOC_G_STD},
177 	{"VIDIOC_S_STD with the enumerated values",
178 	 test_VIDIOC_S_STD_from_enum},
179 	{"VIDIOC_S_STD", test_VIDIOC_S_STD},
180 	{"VIDIOC_S_STD with invalid standard",
181 	 test_VIDIOC_S_STD_invalid_standard},
182 
183 	{"VIDIOC_G_INPUT", test_VIDIOC_G_INPUT},
184 	{"VIDIOC_S_INPUT from enum", test_VIDIOC_S_INPUT_from_enum},
185 	{"VIDIOC_S_INPUT with invalid inputs",
186 	 test_VIDIOC_S_INPUT_invalid_inputs},
187 
188 	{"VIDIOC_G_OUTPUT", test_VIDIOC_G_OUTPUT},
189 	{"VIDIOC_S_OUTPUT from enum", test_VIDIOC_S_OUTPUT_from_enum},
190 	{"VIDIOC_S_OUTPUT with invalid outputs",
191 	 test_VIDIOC_S_OUTPUT_invalid_outputs},
192 
193 	{"VIDIOC_G_TUNER", test_VIDIOC_G_TUNER},
194 	{"VIDIOC_G_TUNER, index=S32_MAX", test_VIDIOC_G_TUNER_S32_MAX},
195 	{"VIDIOC_G_TUNER, index=S32_MAX+1", test_VIDIOC_G_TUNER_S32_MAX_1},
196 	{"VIDIOC_G_TUNER, index=U32_MAX", test_VIDIOC_G_TUNER_U32_MAX},
197 
198 	{"VIDIOC_S_TUNER", test_VIDIOC_S_TUNER},
199 	{"VIDIOC_S_TUNER with invalid index and audmode parameters",
200 	 test_VIDIOC_S_TUNER_invalid},
201 
202 	{"VIDIOC_G_MODULATOR", test_VIDIOC_G_MODULATOR},
203 	{"VIDIOC_G_MODULATOR, index=S32_MAX", test_VIDIOC_G_MODULATOR_S32_MAX},
204 	{"VIDIOC_G_MODULATOR, index=S32_MAX+1",
205 	 test_VIDIOC_G_MODULATOR_S32_MAX_1},
206 	{"VIDIOC_G_MODULATOR, index=U32_MAX", test_VIDIOC_G_MODULATOR_U32_MAX},
207 
208 	{"VIDIOC_G_FREQUENCY", test_VIDIOC_G_FREQUENCY},
209 	{"VIDIOC_G_FREQUENCY, tuner=S32_MAX", test_VIDIOC_G_FREQUENCY_S32_MAX},
210 	{"VIDIOC_G_FREQUENCY, tuner=S32_MAX+1",
211 	 test_VIDIOC_G_FREQUENCY_S32_MAX_1},
212 	{"VIDIOC_G_FREQUENCY, tuner=U32_MAX", test_VIDIOC_G_FREQUENCY_U32_MAX},
213 
214 	{"VIDIOC_S_FREQUENCY", test_VIDIOC_S_FREQUENCY},
215 	{"VIDIOC_S_FREQUENCY with boundary values",
216 	 test_VIDIOC_S_FREQUENCY_boundaries},
217 	{"VIDIOC_S_FREQUENCY scan all possbile values",
218 	 test_VIDIOC_S_FREQUENCY_scan},
219 
220 	{"VIDIOC_G_PRIORITY", test_VIDIOC_G_PRIORITY},
221 	{"VIDIOC_S_PRIORITY", test_VIDIOC_S_PRIORITY},
222 	{"VIDIOC_S_PRIORITY with invalid values",
223 	 test_VIDIOC_S_PRIORITY_invalid},
224 
225 	{"VIDIOC_G_AUDIO", test_VIDIOC_G_AUDIO},
226 	{"VIDIOC_G_AUDIO, ignore index value",
227 	 test_VIDIOC_G_AUDIO_ignore_index},
228 
229 	{"VIDIOC_S_AUDIO", test_VIDIOC_S_AUDIO},
230 	{"VIDIOC_S_AUDIO, index=S32_MAX", test_VIDIOC_S_AUDIO_S32_MAX},
231 	{"VIDIOC_S_AUDIO, index=S32_MAX+1", test_VIDIOC_S_AUDIO_S32_MAX_1},
232 	{"VIDIOC_S_AUDIO, index=U32_MAX", test_VIDIOC_S_AUDIO_U32_MAX},
233 
234 	{"VIDIOC_G_AUDOUT", test_VIDIOC_G_AUDOUT},
235 	{"VIDIOC_G_AUDOUT, ignore index value",
236 	 test_VIDIOC_G_AUDOUT_ignore_index},
237 
238 	{"VIDIOC_S_AUDOUT", test_VIDIOC_S_AUDOUT},
239 	{"VIDIOC_S_AUDOUT, index=S32_MAX", test_VIDIOC_S_AUDOUT_S32_MAX},
240 	{"VIDIOC_S_AUDOUT, index=S32_MAX+1", test_VIDIOC_S_AUDOUT_S32_MAX_1},
241 	{"VIDIOC_S_AUDOUT, index=U32_MAX", test_VIDIOC_S_AUDOUT_U32_MAX},
242 
243 	{"VIDIOC_G_CROP", test_VIDIOC_G_CROP},
244 	{"VIDIOC_G_CROP with invalid type", test_VIDIOC_G_CROP_invalid},
245 	{"VIDIOC_S_CROP", test_VIDIOC_S_CROP},
246 	{"VIDIOC_S_CROP with invalid type", test_VIDIOC_S_CROP_invalid},
247 
248 	{"VIDIOC_G_CTRL", test_VIDIOC_G_CTRL},
249 
250 	{"VIDIOC_S_CTRL", test_VIDIOC_S_CTRL},
251 	{"VIDIOC_S_CTRL with invalid value parameter",
252 	 test_VIDIOC_S_CTRL_invalid},
253 	{"VIDIOC_S_CTRL, withe balance", test_VIDIOC_S_CTRL_white_balance},
254 	{"VIDIOC_S_CTRL, white balance with invalid value parameter",
255 	 test_VIDIOC_S_CTRL_white_balance_invalid},
256 	{"VIDIOC_S_CTRL, gain control", test_VIDIOC_S_CTRL_gain},
257 	{"VIDIOC_S_CTRL, gain control with invalid value parameter",
258 	 test_VIDIOC_S_CTRL_gain_invalid},
259 
260 	{"VIDIOC_G_EXT_CTRLS with zero items to get",
261 	 test_VIDIOC_G_EXT_CTRLS_zero},
262 	{"VIDIOC_G_EXT_CTRLS with zero items to get, but with invalid count values",
263 	 test_VIDIOC_G_EXT_CTRLS_zero_invalid_count},
264 	{"VIDIOC_G_EXT_CTRLS with only one item to get",
265 	 test_VIDIOC_G_EXT_CTRLS_one},
266 
267 	{"VIDIOC_S_EXT_CTRLS with zero items to set",
268 	 test_VIDIOC_S_EXT_CTRLS_zero},
269 	{"VIDIOC_S_EXT_CTRLS with zero items to set, but with invalid count values",
270 	 test_VIDIOC_S_EXT_CTRLS_zero_invalid_count},
271 
272 	{"VIDIOC_TRY_EXT_CTRLS with zero items to try",
273 	 test_VIDIOC_TRY_EXT_CTRLS_zero},
274 	{"VIDIOC_TRY_EXT_CTRLS with zero items to try, but with invalid count values",
275 	 test_VIDIOC_TRY_EXT_CTRLS_zero_invalid_count},
276 
277 	{"VIDIOC_G_PARM", test_VIDIOC_G_PARM},
278 	{"VIDIOC_G_PARM with invalid type parameter",
279 	 test_VIDIOC_G_PARM_invalid},
280 
281 	{"VIDIOC_G_FMT", test_VIDIOC_G_FMT},
282 	{"VIDIOC_G_FMT with invalid type parameter",
283 	 test_VIDIOC_G_FMT_invalid_type},
284 
285 	{"VIDIOC_S_FMT with enumerated values", test_VIDIOC_S_FMT_enum},
286 	{"VIDIOC_S_FMT with invalid type parameter", test_VIDIOC_S_FMT_type},
287 
288 	{"VIDIOC_G_JPEGCOMP", test_VIDIOC_G_JPEGCOMP},
289 
290 	CU_TEST_INFO_NULL,
291 };
292 
293 static CU_TestInfo suite_querystd[] = {
294 	{"VIDIOC_QUERYSTD", test_VIDIOC_QUERYSTD},
295 
296 	CU_TEST_INFO_NULL,
297 };
298 
299 static CU_TestInfo suite_buffs[] = {
300 	{"VIDIOC_REQBUFS with memory map capture streaming i/o",
301 	 test_VIDIOC_REQBUFS_capture_mmap},
302 	{"VIDIOC_REQBUFS with user pointer capture streaming i/o",
303 	 test_VIDIOC_REQBUFS_capture_userptr},
304 	{"VIDIOC_REQBUFS with memory map output streaming i/o",
305 	 test_VIDIOC_REQBUFS_output_mmap},
306 	{"VIDIOC_REQBUFS with user pointer output streaming i/o",
307 	 test_VIDIOC_REQBUFS_output_userptr},
308 	{"VIDIOC_REQBUFS with invalid memory parameter, capture",
309 	 test_VIDIOC_REQBUFS_invalid_memory_capture},
310 	{"VIDIOC_REQBUFS with invalid memory parameter, output",
311 	 test_VIDIOC_REQBUFS_invalid_memory_output},
312 	{"VIDIOC_REQBUFS with invalid type parameter, memory mapped i/o",
313 	 test_VIDIOC_REQUBUFS_invalid_type_mmap},
314 	{"VIDIOC_REQBUFS with invalid type parameter, user pointer i/o",
315 	 test_VIDIOC_REQUBUFS_invalid_type_userptr},
316 
317 	{"VIDIOC_QUERYBUF with memory map capture streaming i/o",
318 	 test_VIDIOC_QUERYBUF_capture_mmap},
319 	{"VIDIOC_QUERYBUF with user pointer capture streaming i/o",
320 	 test_VIDIOC_QUERYBUF_capture_userptr},
321 	{"VIDIOC_QUERYBUF with memory map output streaming i/o",
322 	 test_VIDIOC_QUERYBUF_output_mmap},
323 	{"VIDIOC_QUERYBUF with user pointer output streaming i/o",
324 	 test_VIDIOC_QUERYBUF_output_userptr},
325 	{"VIDIOC_QUERYBUF with overlay capture (invalid)",
326 	 test_VIDIOC_QUERYBUF_overlay_capture},
327 	{"VIDIOC_QUERYBUF with overlay output (invalid)",
328 	 test_VIDIOC_QUERYBUF_overlay_output},
329 	{"VIDIOC_QUERYBUF with invalid memory parameter, capture",
330 	 test_VIDIOC_QUERYBUF_invalid_memory_capture},
331 	{"VIDIOC_QUERYBUF with invalid memory parameter, output",
332 	 test_VIDIOC_QUERYBUF_invalid_memory_output},
333 	{"VIDIOC_QUERYBUF with invalid type parameter, memory mapped i/o",
334 	 test_VIDIOC_QUERYBUF_invalid_type_mmap},
335 	{"VIDIOC_QUERYBUF with invalid type parameter, user pointer i/o",
336 	 test_VIDIOC_QUERYBUF_invalid_type_userptr},
337 
338 	CU_TEST_INFO_NULL,
339 };
340 
341 static CU_TestInfo suite_null_readonly[] = {
342 	{"VIDIOC_QUERYCAP with NULL parameter", test_VIDIOC_QUERYCAP_NULL},
343 	/* { "VIDIOC_G_FBUF with NULL parameter", }, */
344 	{"VIDIOC_G_STD with NULL parameter", test_VIDIOC_G_STD_NULL},
345 	{"VIDIOC_G_AUDIO with NULL parameter", test_VIDIOC_G_AUDIO_NULL},
346 	{"VIDIOC_G_INPUT with NULL parameter", test_VIDIOC_G_INPUT_NULL},
347 	{"VIDIOC_G_OUTPUT with NULL parameter", test_VIDIOC_G_OUTPUT_NULL},
348 	{"VIDIOC_G_AUDOUT with NULL parameter", test_VIDIOC_G_AUDOUT_NULL},
349 	{"VIDIOC_G_JPEGCOMP with NULL parameter", test_VIDIOC_G_JPEGCOMP_NULL},
350 	{"VIDIOC_QUERYSTD with NULL parameter", test_VIDIOC_QUERYSTD_NULL},
351 	{"VIDIOC_G_PRIORITY with NULL parameter", test_VIDIOC_G_PRIORITY_NULL},
352 	/* { "VIDIOC_G_ENC_INDEX with NULL parameter", }, */
353 
354 	CU_TEST_INFO_NULL,
355 };
356 
357 static CU_TestInfo suite_null_writeonly[] = {
358 	/* { "VIDIOC_S_FBUF with NULL parameter", }, */
359 	/* { "VIDIOC_OVERLAY with NULL parameter", }, */
360 	/* { "VIDIOC_STREAMON with NULL parameter", }, */
361 	/* { "VIDIOC_STREAMOFF with NULL parameter", }, */
362 	{"VIDIOC_S_STD with NULL parameter", test_VIDIOC_S_STD_NULL},
363 	{"VIDIOC_S_TUNER with NULL parameter", test_VIDIOC_S_TUNER_NULL},
364 	{"VIDIOC_S_AUDIO with NULL parameter", test_VIDIOC_S_AUDIO_NULL},
365 	{"VIDIOC_S_AUDOUT with NULL parameter", test_VIDIOC_S_AUDOUT_NULL},
366 	/* { "VIDIOC_S_MODULATOR with NULL parameter", }, */
367 	{"VIDIOC_S_FREQUENCY with NULL parameter",
368 	 test_VIDIOC_S_FREQUENCY_NULL},
369 	{"VIDIOC_S_CROP with NULL parameter", test_VIDIOC_S_CROP_NULL},
370 	/* { "VIDIOC_S_JPEGCOMP with NULL parameter", }, */
371 	{"VIDIOC_S_PRIORITY with NULL parameter", test_VIDIOC_S_PRIORITY_NULL},
372 	/* { "VIDIOC_DBG_S_REGISTER with NULL parameter", }, */
373 	/* { "VIDIOC_S_HW_FREQ_SEEK with NULL parameter", }, */
374 
375 	CU_TEST_INFO_NULL,
376 };
377 
378 static CU_TestInfo suite_null_writeread[] = {
379 	{"VIDIOC_ENUM_FMT with NULL parameter", test_VIDIOC_ENUM_FMT_NULL},
380 	{"VIDIOC_G_FMT with NULL parameter", test_VIDIOC_G_FMT_NULL},
381 	/* { "VIDIOC_S_FMT with NULL parameter", }, */
382 	/* { "VIDIOC_REQBUFS with NULL parameter", } */
383 	/* { "VIDIOC_QUERYBUF with NULL parameter", } */
384 	/* { "VIDIOC_QBUF with NULL parameter", }, */
385 	/* { "VIDIOC_DQBUF with NULL parameter", }, */
386 	{"VIDIOC_G_PARM with NULL parameter", test_VIDIOC_G_PARM_NULL},
387 	/* { "VIDIOC_S_PARM with NULL parameter", }, */
388 	{"VIDIOC_ENUMSTD with NULL parameter", test_VIDIOC_ENUMSTD_NULL},
389 	{"VIDIOC_ENUMINPUT with NULL parameter", test_VIDIOC_ENUMINPUT_NULL},
390 	{"VIDIOC_G_CTRL with NULL parameter", test_VIDIOC_G_CTRL_NULL},
391 	{"VIDIOC_S_CTRL with NULL parameter", test_VIDIOC_S_CTRL_NULL},
392 	{"VIDIOC_G_TUNER with NULL parameter", test_VIDIOC_G_TUNER_NULL},
393 	{"VIDIOC_QUERYCTRL with NULL parameter", test_VIDIOC_QUERYCTRL_NULL},
394 	{"VIDIOC_QUERYMENU with NULL parameter", test_VIDIOC_QUERYMENU_NULL},
395 	{"VIDIOC_S_INPUT with NULL parameter", test_VIDIOC_S_INPUT_NULL},
396 	{"VIDIOC_S_OUTPUT with NULL parameter", test_VIDIOC_S_OUTPUT_NULL},
397 	{"VIDIOC_ENUMOUTPUT with NULL parameter", test_VIDIOC_ENUMOUTPUT_NULL},
398 	{"VIDIOC_G_MODULATOR with NULL parameter",
399 	 test_VIDIOC_G_MODULATOR_NULL},
400 	{"VIDIOC_G_FREQUENCY with NULL parameter",
401 	 test_VIDIOC_G_FREQUENCY_NULL},
402 	{"VIDIOC_CROPCAP with NULL parameter", test_VIDIOC_CROPCAP_NULL},
403 	{"VIDIOC_G_CROP with NULL parameter", test_VIDIOC_G_CROP_NULL},
404 	/* { "VIDIOC_TRY_FMT with NULL parameter", }, */
405 	{"VIDIOC_ENUMAUDIO with NULL parameter", test_VIDIOC_ENUMAUDIO_NULL},
406 	{"VIDIOC_ENUMAUDOUT with NULL parameter", test_VIDIOC_ENUMAUDOUT_NULL},
407 	{"VIDIOC_G_SLICED_VBI_CAP with NULL parameter",
408 	 test_VIDIOC_G_SLICED_VBI_CAP_NULL},
409 	{"VIDIOC_G_EXT_CTRLS with NULL parameter",
410 	 test_VIDIOC_G_EXT_CTRLS_NULL},
411 	{"VIDIOC_S_EXT_CTRLS with NULL parameter",
412 	 test_VIDIOC_S_EXT_CTRLS_NULL},
413 	{"VIDIOC_TRY_EXT_CTRLS with NULL parameter",
414 	 test_VIDIOC_TRY_EXT_CTRLS_NULL},
415 	{"VIDIOC_ENUM_FRAMESIZES with NULL parameter",
416 	 test_VIDIOC_ENUM_FRAMESIZES_NULL},
417 	/* { "VIDIOC_ENUM_FRAMEINTERVALS with NULL parameter", }, */
418 	/* { "VIDIOC_ENCODER_CMD with NULL parameter", }, */
419 	/* { "VIDIOC_TRY_ENCODER_CMD with NULL parameter", }, */
420 	/* { "VIDIOC_DBG_G_REGISTER with NULL parameter", }, */
421 	/* { "VIDIOC_DBG_G_CHIP_IDENT with NULL parameter", }, */
422 
423 	CU_TEST_INFO_NULL,
424 };
425 
426 static CU_TestInfo suite_invalid_ioctl[] = {
427 	{"invalid ioctl _IO(0, 0)", test_invalid_ioctl_1},
428 	{"invalid ioctl _IO(0xFF, 0xFF)", test_invalid_ioctl_2},
429 	{"invalid v4l1 ioctl _IO('v', 0xFF)", test_invalid_ioctl_3},
430 	{"invalid v4l2 ioctl _IO('V', 0xFF)", test_invalid_ioctl_4},
431 
432 	CU_TEST_INFO_NULL,
433 };
434 
435 static CU_TestInfo suite_debug_ioctl[] = {
436 	{"test_VIDIOC_LOG_STATUS", test_VIDIOC_LOG_STATUS},
437 
438 	CU_TEST_INFO_NULL,
439 };
440 
441 static CU_SuiteInfo suites[] = {
442 	{"VIDIOC_QUERYCAP", open_video, close_video, suite_querycap},
443 	{"VIDIOC_ENUM* ioctl calls", open_video, close_video, suite_enums},
444 	{"VIDIOC_G_*, VIDIOC_S_* and VIDIOC_TRY_* ioctl calls", open_video,
445 	 close_video, suite_get_set_try},
446 	{"VIDIOC_QUERYSTD", open_video, close_video, suite_querystd},
447 	{"buffer i/o", open_video, close_video, suite_buffs},
448 	{"read only IOCTLs with NULL parameter", open_video, close_video,
449 	 suite_null_readonly},
450 	{"write only IOCTLs with NULL parameter", open_video, close_video,
451 	 suite_null_writeonly},
452 	{"write and read IOCTLs with NULL parameter", open_video, close_video,
453 	 suite_null_writeread},
454 	{"debug ioctl calls", open_video, close_video, suite_debug_ioctl},
455 	{"invalid ioctl calls", open_video, close_video, suite_invalid_ioctl},
456 	CU_SUITE_INFO_NULL,
457 };
458 
main()459 int main()
460 {
461 	CU_ErrorCode err;
462 
463 	err = CU_initialize_registry();
464 	if (err != CUE_SUCCESS) {
465 		printf("ERROR: cannot initialize CUNIT registry, giving up.\n");
466 		return 1;
467 	}
468 
469 	err = CU_register_suites(suites);
470 	if (err == CUE_SUCCESS) {
471 
472 		//CU_basic_set_mode(CU_BRM_NORMAL);
473 		//CU_basic_set_mode(CU_BRM_SILENT);
474 		CU_basic_set_mode(CU_BRM_VERBOSE);
475 		err = CU_basic_run_tests();
476 		if (err != CUE_SUCCESS) {
477 			printf("CU_basic_run_tests returned %i\n", err);
478 		}
479 
480 	} else {
481 		printf("ERROR: cannot add test suites\n");
482 	}
483 
484 	CU_cleanup_registry();
485 
486 	tst_exit();
487 }
488