From: "Németh Márton" <nm127@freemail.hu>
To: Subrata Modak <subrata@linux.vnet.ibm.com>
Cc: ltp-list@lists.sourceforge.net
Subject: [LTP] [PATCH] v4l-test 0.16 for LTP
Date: Wed, 08 Jul 2009 08:49:04 +0200 [thread overview]
Message-ID: <4A544160.9030302@freemail.hu> (raw)
[-- Attachment #1: Type: text/plain, Size: 277 bytes --]
Hi,
this is v4l-test 0.16 for LTP.
Changes:
Iterate through all available inputs in VIDIOC_G_STD and
VIDIOC_S_STD test cases
Signed-off-by: Márton Németh <nm127@freemail.hu>
Regards,
Márton Németh
---
v4l-test home page: http://v4l-test.sourceforge.net/
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: v4l-test-0.16_for_ltp.patch --]
[-- Type: text/x-diff; name="v4l-test-0.16_for_ltp.patch", Size: 28628 bytes --]
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/doc/index.html ltp/testcases/kernel/device-drivers/v4l/user_space/doc/index.html
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/doc/index.html 2009-06-04 11:01:16.000000000 +0200
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/doc/index.html 2009-06-03 08:37:14.000000000 +0200
@@ -510,6 +510,18 @@ influence on the V4L2 API functions:</p>
<td>Resume</td>
<td>no</td>
</tr>
+ <tr>
+ <td>Check for memory leak (e.g. analyze /proc/slab_allocators)</td>
+ <td>no</td>
+ </tr>
+ <tr>
+ <td>Opening /dev/video0 multiple times</td>
+ <td>no</td>
+ </tr>
+ <tr>
+ <td>Using /dev/video0 from a multi-threaded or multi-process environment paralell</td>
+ <td>no</td>
+ </tr>
</tbody>
</table>
@@ -555,12 +567,43 @@ The following documents and articles are
writen by <a href="http://moinejf.free.fr/">Jean-François Moine</a>
</li>
</ul>
+<p>
+For USB or V4L loopback testing:
+</p>
+<ul>
+ <li>
+ <a href="http://sourceforge.net/projects/usbip/">USB/IP</a>
+ </li>
+ <li>
+ <a href="http://www.linux-usb.org/gadget/">Linux-USB Gadget API Framework</a>
+ </li>
+ <li>
+ <a href="http://www.lavrsen.dk/twiki/bin/view/Motion/VideoFourLinuxLoopbackDevice">
+ Video4Linux Loopback Device
+ </a>
+ </li>
+</ul>
+<p>
+And what else can we read if we are looking for webcam test ideas:
+</p>
+<ul>
+ <li>
+ <a href="http://www.microsoft.com/whdc/device/media/vidcap-drvtest.mspx">
+ Testing Windows Video Capture Drivers
+ </a>
+ </li>
+ <li>
+ <a href="http://www.microsoft.com/whdc/device/media/WebCam_VidTests.mspx">
+ Webcam Video Fidelity Tests
+ </a>
+</ul>
<h2><a name="feedback">Feedbacks</a></h2>
-<p>Any feedbacks, comments, ideas, etc. are welcome at the author's email address.</p>
+<p>Any feedbacks, comments, ideas, etc. are welcome at the author's email address.
+You can find the email address in the source package in the README file.</p>
<hr style="width: 100%; height: 2px;">
<p>Last changed:
-Mon May 25 08:08:11 CEST 2009
+Wed Jun 3 08:35:10 CEST 2009
</p>
<p>
<a href="http://validator.w3.org/check?uri=referer"><img
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/Makefile ltp/testcases/kernel/device-drivers/v4l/user_space/Makefile
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/Makefile 2009-06-04 11:01:15.000000000 +0200
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/Makefile 2009-07-06 08:34:22.000000000 +0200
@@ -1,6 +1,7 @@
#
# v4l-test: Test environment for Video For Linux Two API
#
+# 5 Jul 2009 0.18 v4l2_foreach.c added
# 19 May 2009 0.17 test_VIDIOC_EXT_CTRLS.c added
# 7 May 2009 0.16 v4l2_show.c added
# 5 May 2009 0.15 test_VIDIOC_QUERYBUF.c added
@@ -38,6 +39,7 @@ LDFLAGS = -lcunit
OBJS = dev_video.o \
v4l2_validator.o \
+ v4l2_foreach.o \
test_VIDIOC_QUERYCAP.o \
test_VIDIOC_ENUMAUDIO.o \
test_VIDIOC_ENUMAUDOUT.o \
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/README ltp/testcases/kernel/device-drivers/v4l/user_space/README
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/README 2009-06-04 11:01:15.000000000 +0200
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/README 2009-07-06 08:37:33.000000000 +0200
@@ -3,6 +3,8 @@
Release History
---------------
+ 6 Jul 2009 0.16 Iterate through all available inputs in VIDIOC_G_STD and
+ VIDIOC_S_STD test cases
25 May 2009 0.15 Test cases added for VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS
and VIDIOC_TRY_EXT_CTRLS
7 May 2009 0.14 Test cases added for VIDIOC_QUERYBUF;
@@ -111,14 +113,9 @@ a USB video device or ask the user if a
See doc/index.html about how much of the specification is covered by the
different test cases.
-Similar projects
-----------------
- - v4ltest: http://www.linuxowl.com/v4ltest.html
- - test cases in dvb-apps repository, under /test directory: http://linuxtv.org/hg/dvb-apps/file
- - test cases in v4l-dvb repository, under /v4l2-apps/test directory:
-http://linuxtv.org/hg/v4l-dvb/file
- - this test environment is also available under Linux Test Project (LTP),
- under directory testcases/kernel/device-drivers/v4l/user_space: http://ltp.sourceforge.net/
+See also
+--------
+See also doc/index.html for further references and recommended readings.
Feedbacks
---------
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_ENUMINPUT.c ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_ENUMINPUT.c
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_ENUMINPUT.c 2009-05-11 08:07:10.000000000 +0200
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_ENUMINPUT.c 2009-07-06 08:34:29.000000000 +0200
@@ -1,6 +1,7 @@
/*
* v4l-test: Test environment for Video For Linux Two API
*
+ * 5 Jul 2009 0.10 show_v4l2_input() introduced
* 20 Apr 2009 0.9 Added string content validation
* 19 Apr 2009 0.8 Also check std field
* 18 Apr 2009 0.7 More strict check for strings
@@ -35,6 +36,7 @@
#include "dev_video.h"
#include "video_limits.h"
#include "v4l2_validator.h"
+#include "v4l2_show.h"
#include "test_VIDIOC_ENUMINPUT.h"
@@ -86,23 +88,7 @@ void test_VIDIOC_ENUMINPUT() {
input2.status = input.status;
CU_ASSERT_EQUAL(memcmp(&input, &input2, sizeof(input)), 0);
- dprintf("\tinput = {.index=%u, .name=\"%s\", "
- ".type=0x%X, .audioset=0x%X, .tuner=0x%X, "
- ".std=%llX, "
- ".status=0x%X, "
- ".reserved[]={ 0x%X, 0x%X, 0x%X, 0x%X } }\n",
- input.index,
- input.name,
- input.type,
- input.audioset,
- input.tuner,
- input.std,
- input.status,
- input.reserved[0],
- input.reserved[1],
- input.reserved[2],
- input.reserved[3]
- );
+ show_v4l2_input(&input);
} else {
CU_ASSERT_EQUAL(ret_enum, -1);
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_STD.c ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_STD.c
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_STD.c 2009-05-11 08:07:10.000000000 +0200
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/test_VIDIOC_STD.c 2009-07-06 08:34:17.000000000 +0200
@@ -1,6 +1,7 @@
/*
* v4l-test: Test environment for Video For Linux Two API
*
+ * 5 Jul 2009 0.9 Iterate through all possible inputs
* 18 Apr 2009 0.8 Typo corrected
* 27 Mar 2009 0.7 Cleanup ret and errno variable names and dprintf() outputs;
* Make VIDIOC_S_STD tests independent from VIDIOC_G_STD
@@ -34,79 +35,153 @@
#include "dev_video.h"
#include "video_limits.h"
#include "v4l2_validator.h"
+#include "v4l2_foreach.h"
#include "test_VIDIOC_STD.h"
-void test_VIDIOC_G_STD() {
- int ret_get, errno_get;
+static void do_test_VIDIOC_G_STD(int ret_input_enum, int errno_input_enum, struct v4l2_input* input) {
v4l2_std_id std_id;
+ int ret_std_get, errno_std_get;
+ int f;
- /* TODO: Iterate trough all inputs and all outputs
- * with VIDIOC_ENUMINPUT and VIDIOC_ENUMOUTPUT.
+ /* Iterate trough all inputs with VIDIOC_ENUMINPUT.
* Also ensure tahat VIDIC_G_STD is called at least
- * once even if VIDIOC_ENUMINPUT and VIDIOC_ENUMOUTPUT
- * always return EINVAL.
+ * once even if VIDIOC_ENUMINPUT always return EINVAL.
*
* V4L2 API specification rev. 0.24, Chapter 1.7.
* "Video Standards" specifies if the std field
- * of v4l2_input and v4l2_output is zero then
- * VIDIOC_G_STD shall always return EINVAL.
+ * of v4l2_input or v4l2_output is zero when
+ * executing VIDIOC_ENUMINPUT or VIDIOC_ENUMOUTPUT,
+ * respectively, then VIDIOC_G_STD shall always
+ * return EINVAL.
+ */
+
+ /* TODO: Iterate trough all outputs VIDIOC_ENUMOUTPUT.
+ * Also ensure tahat VIDIC_G_STD is called at least
+ * once even if VIDIOC_ENUMOUTPUT always return EINVAL.
+ *
+ * TODO: What shall happen when changing output? The
+ * VIDIOC_G_STD only deals with current input.
*/
+ f = get_video_fd();
+
memset(&std_id, 0xff, sizeof(std_id));
- ret_get = ioctl(get_video_fd(), VIDIOC_G_STD, &std_id);
- errno_get = errno;
+ ret_std_get = ioctl(f, VIDIOC_G_STD, &std_id);
+ errno_std_get = errno;
- dprintf("\t%s:%u: VIDIOC_G_STD, ret_get=%i, errno_get=%i, std_id=0x%llX\n",
- __FILE__, __LINE__, ret_get, errno_get, std_id);
+ dprintf("\t%s:%u: VIDIOC_G_STD, ret_std_get=%i, errno_std_get=%i, std_id=0x%llX\n",
+ __FILE__, __LINE__, ret_std_get, errno_std_get, std_id);
- if (ret_get == 0) {
- CU_ASSERT_EQUAL(ret_get, 0);
- CU_ASSERT(valid_v4l2_std_id(std_id));
+ if (ret_input_enum == 0) {
+ CU_ASSERT_EQUAL(ret_input_enum, 0);
+ if (input->std == 0) {
+ CU_ASSERT_EQUAL(ret_std_get, -1);
+ CU_ASSERT_EQUAL(errno_std_get, EINVAL);
+ } else {
+ if (ret_std_get == 0) {
+ CU_ASSERT_EQUAL(ret_std_get, 0);
+ CU_ASSERT(valid_v4l2_std_id(std_id));
+ } else {
+ CU_ASSERT_EQUAL(ret_std_get, -1);
+ CU_ASSERT_EQUAL(errno_std_get, EINVAL);
+ }
+ }
} else {
- CU_ASSERT_EQUAL(ret_get, -1);
- CU_ASSERT_EQUAL(errno_get, EINVAL);
+ CU_ASSERT_EQUAL(ret_input_enum, -1);
+ CU_ASSERT_EQUAL(errno_input_enum, EINVAL);
+ if (ret_std_get == 0) {
+ CU_ASSERT_EQUAL(ret_std_get, 0);
+ CU_ASSERT(valid_v4l2_std_id(std_id));
+ } else {
+ CU_ASSERT_EQUAL(ret_std_get, -1);
+ CU_ASSERT_EQUAL(errno_std_get, EINVAL);
+ }
}
+}
+
+void test_VIDIOC_G_STD() {
+
+ /* Iterate trough all inputs with VIDIOC_ENUMINPUT.
+ * Also ensure tahat VIDIC_G_STD is called at least
+ * once even if VIDIOC_ENUMINPUT always return EINVAL.
+ *
+ * V4L2 API specification rev. 0.24, Chapter 1.7.
+ * "Video Standards" specifies if the std field
+ * of v4l2_input or v4l2_output is zero when
+ * executing VIDIOC_ENUMINPUT or VIDIOC_ENUMOUTPUT,
+ * respectively, then VIDIOC_G_STD shall always
+ * return EINVAL.
+ */
+
+ foreach_input(do_test_VIDIOC_G_STD);
+
+
+ /* TODO: Iterate trough all outputs VIDIOC_ENUMOUTPUT.
+ * Also ensure tahat VIDIC_G_STD is called at least
+ * once even if VIDIOC_ENUMOUTPUT always return EINVAL.
+ *
+ * TODO: What shall happen when changing output? The
+ * VIDIOC_G_STD only deals with current input.
+ */
+
}
-static int do_set_video_standard(int f, v4l2_std_id id) {
- int ret_set, errno_set;
- int ret_get, errno_get;
+static int do_set_video_standard(int f, v4l2_std_id id,
+ int ret_input_enum, int errno_input_enum, struct v4l2_input* input) {
+ int ret_std_set, errno_std_set;
+ int ret_std_get, errno_std_get;
v4l2_std_id std_id;
std_id = id;
- ret_set = ioctl(f, VIDIOC_S_STD, &std_id);
- errno_set = errno;
+ ret_std_set = ioctl(f, VIDIOC_S_STD, &std_id);
+ errno_std_set = errno;
- dprintf("\t%s:%u: ret_set=%i, errno_set=%i, std_id=0x%llX, id=0x%llX\n",
- __FILE__, __LINE__, ret_set, errno_set, std_id, id);
+ dprintf("\t%s:%u: VIDIOC_S_STD: ret_std_set=%i, errno_std_set=%i, std_id=0x%llX, id=0x%llX\n",
+ __FILE__, __LINE__, ret_std_set, errno_std_set, std_id, id);
- if (ret_set == 0) {
- CU_ASSERT_EQUAL(ret_set, 0);
- memset(&std_id, 0xff, sizeof(std_id));
- ret_get = ioctl(f, VIDIOC_G_STD, &std_id);
- errno_get = errno;
+ memset(&std_id, 0xff, sizeof(std_id));
+ ret_std_get = ioctl(f, VIDIOC_G_STD, &std_id);
+ errno_std_get = errno;
- CU_ASSERT_EQUAL(ret_get, 0);
- if (ret_get == 0) {
- CU_ASSERT( (id & std_id) == id);
+ dprintf("\t%s:%u: VIDIOC_G_STD: ret_std_get=%i, errno_std_get=%i, std_id=0x%llX\n",
+ __FILE__, __LINE__, ret_std_get, errno_std_get, std_id);
- if (std_id != id) {
- dprintf("\t%s:%u: ret_get=%i, errno_get=%i, std_id=0x%llX, id=0x%llX\n",
- __FILE__, __LINE__, ret_get, errno_get, std_id, id);
+ if (ret_input_enum == 0) {
+ CU_ASSERT_EQUAL(ret_input_enum, 0);
+ if (input->std == 0) {
+ CU_ASSERT_EQUAL(ret_std_get, -1);
+ CU_ASSERT_EQUAL(errno_std_get, EINVAL);
+ CU_ASSERT_EQUAL(ret_std_set, -1);
+ CU_ASSERT_EQUAL(errno_std_set, EINVAL);
+ } else {
+ if (ret_std_set == 0) {
+ CU_ASSERT_EQUAL(ret_std_set, 0);
+ CU_ASSERT_EQUAL(ret_std_get, 0);
+ CU_ASSERT(valid_v4l2_std_id(std_id));
+ } else {
+ CU_ASSERT_EQUAL(ret_std_set, -1);
+ CU_ASSERT_EQUAL(errno_std_set, EINVAL);
}
-
}
} else {
- CU_ASSERT_EQUAL(ret_set, -1);
- CU_ASSERT_EQUAL(errno_set, EINVAL);
+ CU_ASSERT_EQUAL(ret_input_enum, -1);
+ CU_ASSERT_EQUAL(errno_input_enum, EINVAL);
+ if (ret_std_set == 0) {
+ CU_ASSERT_EQUAL(ret_std_set, 0);
+ CU_ASSERT_EQUAL(ret_std_get, 0);
+ CU_ASSERT(valid_v4l2_std_id(std_id));
+ } else {
+ CU_ASSERT_EQUAL(ret_std_set, -1);
+ CU_ASSERT_EQUAL(errno_std_set, EINVAL);
+ }
}
- return ret_set;
+ return ret_std_set;
}
-void test_VIDIOC_S_STD() {
+static void do_test_VIDIOC_S_STD(int ret_input_enum, int errno_input_enum, struct v4l2_input* input) {
int ret_get, errno_get;
int ret_set, errno_set;
v4l2_std_id std_id_orig;
@@ -121,37 +196,37 @@ void test_VIDIOC_S_STD() {
dprintf("\t%s:%u: VIDIOC_G_STD: ret_get=%i, errno_get=%i, std_id_orig=0x%llX\n",
__FILE__, __LINE__, ret_get, errno_get, std_id_orig);
- ret_set = do_set_video_standard(f, V4L2_STD_PAL_B);
- ret_set = do_set_video_standard(f, V4L2_STD_PAL_B1);
- ret_set = do_set_video_standard(f, V4L2_STD_PAL_G);
- ret_set = do_set_video_standard(f, V4L2_STD_PAL_H);
- ret_set = do_set_video_standard(f, V4L2_STD_PAL_I);
- ret_set = do_set_video_standard(f, V4L2_STD_PAL_D);
- ret_set = do_set_video_standard(f, V4L2_STD_PAL_D1);
- ret_set = do_set_video_standard(f, V4L2_STD_PAL_K);
- ret_set = do_set_video_standard(f, V4L2_STD_PAL_M);
- ret_set = do_set_video_standard(f, V4L2_STD_PAL_N);
- ret_set = do_set_video_standard(f, V4L2_STD_PAL_Nc);
- ret_set = do_set_video_standard(f, V4L2_STD_PAL_60);
- ret_set = do_set_video_standard(f, V4L2_STD_NTSC_M);
- ret_set = do_set_video_standard(f, V4L2_STD_NTSC_M_JP);
- ret_set = do_set_video_standard(f, V4L2_STD_NTSC_443);
- ret_set = do_set_video_standard(f, V4L2_STD_NTSC_M_KR);
- ret_set = do_set_video_standard(f, V4L2_STD_SECAM_B);
- ret_set = do_set_video_standard(f, V4L2_STD_SECAM_D);
- ret_set = do_set_video_standard(f, V4L2_STD_SECAM_G);
- ret_set = do_set_video_standard(f, V4L2_STD_SECAM_H);
- ret_set = do_set_video_standard(f, V4L2_STD_SECAM_K);
- ret_set = do_set_video_standard(f, V4L2_STD_SECAM_K1);
- ret_set = do_set_video_standard(f, V4L2_STD_SECAM_L);
- ret_set = do_set_video_standard(f, V4L2_STD_SECAM_LC);
- ret_set = do_set_video_standard(f, V4L2_STD_ATSC_8_VSB);
- ret_set = do_set_video_standard(f, V4L2_STD_ATSC_16_VSB);
+ ret_set = do_set_video_standard(f, V4L2_STD_PAL_B, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_PAL_B1, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_PAL_G, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_PAL_H, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_PAL_I, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_PAL_D, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_PAL_D1, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_PAL_K, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_PAL_M, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_PAL_N, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_PAL_Nc, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_PAL_60, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_NTSC_M, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_NTSC_M_JP, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_NTSC_443, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_NTSC_M_KR, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_SECAM_B, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_SECAM_D, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_SECAM_G, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_SECAM_H, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_SECAM_K, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_SECAM_K1, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_SECAM_L, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_SECAM_LC, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_ATSC_8_VSB, ret_input_enum, errno_input_enum, input);
+ ret_set = do_set_video_standard(f, V4L2_STD_ATSC_16_VSB, ret_input_enum, errno_input_enum, input);
if (ret_get == 0) {
CU_ASSERT_EQUAL(ret_get, 0);
/* Setting the original std_id should not fail */
- ret_set = do_set_video_standard(f, std_id_orig);
+ ret_set = do_set_video_standard(f, std_id_orig, ret_input_enum, errno_input_enum, input);
errno_set = errno;
CU_ASSERT_EQUAL(ret_set, 0);
@@ -162,7 +237,11 @@ void test_VIDIOC_S_STD() {
}
-void test_VIDIOC_S_STD_from_enum() {
+void test_VIDIOC_S_STD() {
+ foreach_input(do_test_VIDIOC_S_STD);
+}
+
+static void do_test_VIDIOC_S_STD_from_enum(int ret_input_enum, int errno_input_enum, struct v4l2_input* input) {
int ret_get, errno_get;
int ret_enum, errno_enum;
int ret_set, errno_set;
@@ -192,7 +271,7 @@ void test_VIDIOC_S_STD_from_enum() {
__FILE__, __LINE__, i, ret_enum, errno_enum, std.id);
if (ret_enum == 0) {
- ret_set = do_set_video_standard(f, std.id);
+ ret_set = do_set_video_standard(f, std.id, ret_input_enum, errno_input_enum, input);
CU_ASSERT_EQUAL(ret_set, 0);
}
i++;
@@ -202,7 +281,7 @@ void test_VIDIOC_S_STD_from_enum() {
CU_ASSERT_EQUAL(ret_get, 0);
/* Setting the original std_id should not fail */
- ret_set = do_set_video_standard(f, std_id_orig);
+ ret_set = do_set_video_standard(f, std_id_orig, ret_input_enum, errno_input_enum, input);
errno_set = errno;
dprintf("\t%s:%u: VIDIOC_S_STD: ret_set=%i (expected %i), errno=%i\n",
__FILE__, __LINE__, ret_set, 0, errno);
@@ -214,8 +293,11 @@ void test_VIDIOC_S_STD_from_enum() {
}
+void test_VIDIOC_S_STD_from_enum() {
+ foreach_input(do_test_VIDIOC_S_STD_from_enum);
+}
-void test_VIDIOC_S_STD_invalid_standard() {
+static void do_test_VIDIOC_S_STD_invalid_standard(int ret_input_enum, int errno_input_enum, struct v4l2_input* input) {
int ret_get, errno_get;
int ret_set, errno_set;
v4l2_std_id std_id_orig;
@@ -235,7 +317,7 @@ void test_VIDIOC_S_STD_invalid_standard(
std_id = 1;
while (std_id != 0) {
if (!valid_v4l2_std_id(std_id)) {
- ret_set = do_set_video_standard(f, std_id);
+ ret_set = do_set_video_standard(f, std_id, ret_input_enum, errno_input_enum, input);
errno_set = errno;
CU_ASSERT_EQUAL(ret_set, -1);
@@ -250,7 +332,7 @@ void test_VIDIOC_S_STD_invalid_standard(
CU_ASSERT_EQUAL(ret_get, 0);
/* Setting the original std_id should not fail */
- ret_set = do_set_video_standard(f, std_id_orig);
+ ret_set = do_set_video_standard(f, std_id_orig, ret_input_enum, errno_input_enum, input);
errno_set = errno;
dprintf("\t%s:%u: VIDIOC_S_STD: ret_set=%i (expected 0), errno=%i\n",
@@ -262,7 +344,11 @@ void test_VIDIOC_S_STD_invalid_standard(
}
}
-void test_VIDIOC_G_STD_NULL() {
+void test_VIDIOC_S_STD_invalid_standard() {
+ foreach_input(do_test_VIDIOC_S_STD_invalid_standard);
+}
+
+static void do_test_VIDIOC_G_STD_NULL(int ret_input_enum, int errno_input_enum, struct v4l2_input* input) {
int ret_get, errno_get;
int ret_null, errno_null;
v4l2_std_id std_id;
@@ -280,20 +366,49 @@ void test_VIDIOC_G_STD_NULL() {
dprintf("\t%s:%u: VIDIOC_G_STD: ret_null=%i, errno_null=%i\n",
__FILE__, __LINE__, ret_null, errno_null);
- if (ret_get == 0) {
- CU_ASSERT_EQUAL(ret_get, 0);
- CU_ASSERT_EQUAL(ret_null, -1);
- CU_ASSERT_EQUAL(errno_null, EFAULT);
+ if (ret_input_enum == 0) {
+ CU_ASSERT_EQUAL(ret_input_enum, 0);
+ if (input->std == 0) {
+ CU_ASSERT_EQUAL(ret_get, -1);
+ CU_ASSERT_EQUAL(errno_get, EINVAL);
+ CU_ASSERT_EQUAL(ret_null, -1);
+ CU_ASSERT_EQUAL(errno_null, EINVAL);
+ } else {
+ if (ret_get == 0) {
+ CU_ASSERT_EQUAL(ret_get, 0);
+ CU_ASSERT_EQUAL(ret_null, -1);
+ CU_ASSERT_EQUAL(errno_null, EFAULT);
+ } else {
+ CU_ASSERT_EQUAL(ret_get, -1);
+ CU_ASSERT_EQUAL(errno_get, EINVAL);
+ CU_ASSERT_EQUAL(ret_null, -1);
+ CU_ASSERT_EQUAL(errno_null, EINVAL);
+ }
+ }
} else {
- CU_ASSERT_EQUAL(ret_get, -1);
- CU_ASSERT_EQUAL(errno_get, EINVAL);
- CU_ASSERT_EQUAL(ret_null, -1);
- CU_ASSERT_EQUAL(errno_null, EINVAL);
+ CU_ASSERT_EQUAL(ret_input_enum, -1);
+ CU_ASSERT_EQUAL(errno_input_enum, EINVAL);
+ if (ret_get == 0) {
+ CU_ASSERT_EQUAL(ret_get, 0);
+ CU_ASSERT_EQUAL(ret_null, -1);
+ CU_ASSERT_EQUAL(errno_null, EFAULT);
+ } else {
+ CU_ASSERT_EQUAL(ret_get, -1);
+ CU_ASSERT_EQUAL(errno_get, EINVAL);
+ CU_ASSERT_EQUAL(ret_null, -1);
+ CU_ASSERT_EQUAL(errno_null, EINVAL);
+ }
}
+
+
}
-void test_VIDIOC_S_STD_NULL() {
+void test_VIDIOC_G_STD_NULL() {
+ foreach_input(do_test_VIDIOC_G_STD_NULL);
+}
+
+static void do_test_VIDIOC_S_STD_NULL(int ret_input_enum, int errno_input_enum, struct v4l2_input* input) {
int ret_null, errno_null;
/* TODO: check whether VIDIOC_S_STD is supported at all or not */
@@ -304,10 +419,23 @@ void test_VIDIOC_S_STD_NULL() {
dprintf("\t%s:%u: VIDIOC_S_STD: ret_null=%i, errno_null=%i\n",
__FILE__, __LINE__, ret_null, errno_null);
- CU_ASSERT_EQUAL(ret_null, -1);
- CU_ASSERT_EQUAL(errno_null, EFAULT);
-
+ if (ret_input_enum == 0) {
+ CU_ASSERT_EQUAL(ret_input_enum, 0);
+ if (input->std == 0) {
+ CU_ASSERT_EQUAL(ret_null, -1);
+ CU_ASSERT_EQUAL(errno_null, EINVAL);
+ } else {
+ }
+ } else {
+ CU_ASSERT_EQUAL(ret_input_enum, -1);
+ CU_ASSERT_EQUAL(errno_input_enum, EINVAL);
+ CU_ASSERT_EQUAL(ret_null, -1);
+ CU_ASSERT_EQUAL(errno_null, EFAULT);
+ }
}
+void test_VIDIOC_S_STD_NULL() {
+ foreach_input(do_test_VIDIOC_S_STD_NULL);
+}
/* TODO: VIDIOC_S_STD while STREAM_ON */
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/v4l2_foreach.c ltp/testcases/kernel/device-drivers/v4l/user_space/v4l2_foreach.c
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/v4l2_foreach.c 1970-01-01 01:00:00.000000000 +0100
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/v4l2_foreach.c 2009-07-06 08:34:33.000000000 +0200
@@ -0,0 +1,83 @@
+/*
+ * v4l-test: Test environment for Video For Linux Two API
+ *
+ * 5 Jul 2009 0.1 First release
+ *
+ * Written by Márton Németh <nm127@freemail.hu>
+ * Released under GPL
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <string.h>
+
+#include <linux/videodev2.h>
+#include <linux/errno.h>
+
+#include <CUnit/CUnit.h>
+
+#include "v4l2_test.h"
+#include "dev_video.h"
+#include "v4l2_show.h"
+#include "v4l2_foreach.h"
+
+void foreach_input(V4L2InputTestFunc pFunc) {
+ __u32 input_index_orig;
+ struct v4l2_input input;
+ int ret_input_get, errno_input_get;
+ int ret_input_enum, errno_input_enum;
+ int ret_input_set, errno_input_set;
+ __u32 i;
+ int f;
+ char not_yet_called = 1;
+
+ f = get_video_fd();
+
+ memset(&input_index_orig, 0xff, sizeof(input_index_orig));
+ ret_input_get = ioctl(f, VIDIOC_G_INPUT, &input_index_orig);
+ errno_input_get = errno;
+ dprintf("\t%s:%u: VIDIOC_G_INPUT, ret_input_get=%i, errno_input_get=%i, input_index_orig=0x%X\n",
+ __FILE__, __LINE__, ret_input_get, errno_input_get, input_index_orig);
+
+ i = 0;
+ do {
+ memset(&input, 0xff, sizeof(input));
+ input.index = i;
+ ret_input_enum = ioctl(f, VIDIOC_ENUMINPUT, &input);
+ errno_input_enum = errno;
+
+ dprintf("\t%s:%u: VIDIOC_ENUMINPUT: i=%u, ret_input_enum=%i, errno_input_enum=%i\n",
+ __FILE__, __LINE__, i, ret_input_enum, errno_input_enum);
+
+ if (ret_input_enum == 0) {
+ show_v4l2_input(&input);
+ ret_input_set = ioctl(f, VIDIOC_S_INPUT, &input.index);
+ errno_input_set = errno;
+ dprintf("\t%s:%u: VIDIOC_S_INPUT: input.index=0x%X, ret_input_set=%i, errno_input_set=%i\n",
+ __FILE__, __LINE__, input.index, ret_input_set, errno_input_set);
+ CU_ASSERT_EQUAL(ret_input_set, 0);
+ }
+
+ /* Ensure that pFunc() is called at least once even if
+ * everything else returned error before.
+ */
+ if (not_yet_called || ret_input_enum == 0) {
+ pFunc(ret_input_enum, errno_input_enum, &input);
+ not_yet_called = 0;
+ }
+
+ i++;
+ } while (ret_input_enum == 0 && i != 0);
+
+ if (ret_input_get == 0) {
+ /* Setting the original input_id should not fail */
+ ret_input_set = ioctl(f, VIDIOC_S_INPUT, &input_index_orig);
+ errno_input_set = errno;
+ CU_ASSERT_EQUAL(ret_input_set, 0);
+ }
+}
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/v4l2_foreach.h ltp/testcases/kernel/device-drivers/v4l/user_space/v4l2_foreach.h
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/v4l2_foreach.h 1970-01-01 01:00:00.000000000 +0100
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/v4l2_foreach.h 2009-07-06 08:34:41.000000000 +0200
@@ -0,0 +1,14 @@
+/*
+ * v4l-test: Test environment for Video For Linux Two API
+ *
+ * 5 Jul 2009 0.1 First release
+ *
+ * Written by Márton Németh <nm127@freemail.hu>
+ * Released under GPL
+ */
+
+#include <linux/videodev2.h>
+
+typedef void (*V4L2InputTestFunc)(int ret_input_enum, int errno_input_enum, struct v4l2_input* input);
+
+void foreach_input(V4L2InputTestFunc pFunc);
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/v4l2_show.c ltp/testcases/kernel/device-drivers/v4l/user_space/v4l2_show.c
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/v4l2_show.c 2009-05-11 08:10:27.000000000 +0200
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/v4l2_show.c 2009-07-06 08:34:44.000000000 +0200
@@ -1,6 +1,7 @@
/*
* v4l-test: Test environment for Video For Linux Two API
*
+ * 5 Jul 2009 0.2 show_v4l2_input() introduced
* 7 May 2009 0.1 First release
*
* Written by Márton Németh <nm127@freemail.hu>
@@ -114,3 +115,23 @@ void show_v4l2_buffer(struct v4l2_buffer
);
}
+
+void show_v4l2_input(struct v4l2_input *input) {
+ dprintf("\tinput = {.index=%u, .name=\"%s\", "
+ ".type=0x%X, .audioset=0x%X, .tuner=0x%X, "
+ ".std=%llX, "
+ ".status=0x%X, "
+ ".reserved[]={ 0x%X, 0x%X, 0x%X, 0x%X } }\n",
+ input->index,
+ input->name,
+ input->type,
+ input->audioset,
+ input->tuner,
+ input->std,
+ input->status,
+ input->reserved[0],
+ input->reserved[1],
+ input->reserved[2],
+ input->reserved[3]
+ );
+}
diff -uprN ltp.orig/testcases/kernel/device-drivers/v4l/user_space/v4l2_show.h ltp/testcases/kernel/device-drivers/v4l/user_space/v4l2_show.h
--- ltp.orig/testcases/kernel/device-drivers/v4l/user_space/v4l2_show.h 2009-05-11 08:10:27.000000000 +0200
+++ ltp/testcases/kernel/device-drivers/v4l/user_space/v4l2_show.h 2009-07-06 08:34:38.000000000 +0200
@@ -1,6 +1,7 @@
/*
* v4l-test: Test environment for Video For Linux Two API
*
+ * 5 Jul 2009 0.2 show_v4l2_input() introduced
* 7 May 2009 0.1 First release
*
* Written by Márton Németh <nm127@freemail.hu>
@@ -11,3 +12,4 @@
void show_v4l2_requestbuffers(struct v4l2_requestbuffers *reqbuf);
void show_v4l2_buffer(struct v4l2_buffer *buf);
+void show_v4l2_input(struct v4l2_input *input);
[-- Attachment #3: Type: text/plain, Size: 389 bytes --]
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
[-- Attachment #4: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next reply other threads:[~2009-07-08 7:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-08 6:49 Németh Márton [this message]
2009-07-08 18:13 ` [LTP] [PATCH] v4l-test 0.16 for LTP Subrata Modak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A544160.9030302@freemail.hu \
--to=nm127@freemail.hu \
--cc=ltp-list@lists.sourceforge.net \
--cc=subrata@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.