2 * video_device_test - Video Device Test
4 * Copyright (c) 2016 Shuah Khan <shuahkh@osg.samsung.com>
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
7 * This file is released under the GPLv2.
11 * This file adds a test for Video Device. This test should not be included
12 * in the Kselftest run. This test should be run when hardware and driver
13 * that makes use of V4L2 API is present.
15 * This test opens user specified Video Device and calls video ioctls in a
16 * loop once every 10 seconds.
19 * sudo ./video_device_test -d /dev/videoX
21 * While test is running, remove the device or unbind the driver and
22 * ensure there are no use after free errors and other Oops in the
24 * When possible, enable KaSan kernel config option for use-after-free
34 #include <sys/ioctl.h>
37 #include <linux/videodev2.h>
39 int main(int argc, char **argv)
44 struct v4l2_tuner vtuner;
45 struct v4l2_capability vcap;
50 printf("Usage: %s [-d </dev/videoX>]\n", argv[0]);
54 /* Process arguments */
55 while ((opt = getopt(argc, argv, "d:")) != -1) {
58 strncpy(video_dev, optarg, sizeof(video_dev) - 1);
59 video_dev[sizeof(video_dev)-1] = '\0';
62 printf("Usage: %s [-d </dev/videoX>]\n", argv[0]);
67 /* Generate random number of interations */
68 srand((unsigned int) time(NULL));
71 /* Open Video device and keep it open */
72 fd = open(video_dev, O_RDWR);
74 printf("Video Device open errno %s\n", strerror(errno));
79 "While test is running, remove the device or unbind\n"
80 "driver and ensure there are no use after free errors\n"
81 "and other Oops in the dmesg. When possible, enable KaSan\n"
82 "kernel config option for use-after-free error detection.\n\n");
85 ret = ioctl(fd, VIDIOC_QUERYCAP, &vcap);
87 printf("VIDIOC_QUERYCAP errno %s\n", strerror(errno));
89 printf("Video device driver %s\n", vcap.driver);
91 ret = ioctl(fd, VIDIOC_G_TUNER, &vtuner);
93 printf("VIDIOC_G_TUNER, errno %s\n", strerror(errno));
95 printf("type %d rangelow %d rangehigh %d\n",
96 vtuner.type, vtuner.rangelow, vtuner.rangehigh);