Contents |
V4L2 API is a kernel interface for analog radio and video capture and output drivers.
Blts-v4l2 package (0.3.8) is meant to test V4L2 functionality. The blts-v4l2 package tests camera driver functionality by checking e.g. capabilities and controls. There is also tests that stream frames (using XVideo) and take snapshots (saved as JPG pictures) using different resolutions. Some of these test cases also measure FPS rates. The audio part of the V4L2 API is not in the scope.
The test cases are:
Current IOCTL coverage for v4l2 tests:
At the moment test cases are configured to test main and front cameras. The audio functionality of the test device is excluded.
The test environment must have following packages installed:
The v4l2 test package comes with a packaging script that can be used to build tarball out of the sources, RPM package or Debian package. To build RPM package, in the root directory execute command:
./pack.sh -r
To get packaging script help, execute command:
./pack.sh -h
The building environment requires the following RPM packages installed:
The blts-v4l2-tests package is dependent on blts-v4l2-tests-config configuration file package. The packaging script pack.sh creates RPM package blts-v4l2-tests-config-example_{version}.rpm and it must be installed first. The configuration file /etc/blts/blts-v4l2-tests.cnf is copied in the test device during RPM installation.
The configuration file package can be installed in the device with a command:
rpm -ivh blts-v4l2-tests-config-example_{version}.rpm
The test package can be installed in the device with a command:
rpm -ivh blts-v4l2-tests_{version}.rpm
The control setting test cases support external image verification tool.
Image verification
The standard and extended control tests support verification of the camera snapshot image using an external tool. Image verification is enabled by specifying values for the image_save_path and image_verify_tool global configuration parameters, and by giving the -i command line flag when running the test. Once a camera snapshot has been saved for a certain control setting, the tool given in image_verify_tool is run with a command line like this:
verify_tool <snapshot image name> <control name> <V4L2 control id> <control value>
The verification tool should return zero when the image is verified successfully, and a non-zero value when the verification fails. The output of the tool is appended to the log file of the test.
Control value limits and test values
The minimum and maximum values reported by the V4L2 driver can be compared with values specified in the configuration file. The test succeeds if the values match exactly, and fails otherwise. The minimum and maximum values are specified as global configuration parameters, with a special naming format:
dev<number of device>_<escaped control name>_min = <minimum value>
dev<number of device>_<escaped control name>_max = <maximum value>
As the global configuration value identifiers cannot contain spaces or any of the /()[] characters, which may be present in the name of a V4L2 control, the control name must be escaped by replacing spaces with underscores, and by removing any prohibited characters from the name. For example, values for the control named Exposure Time (us) on the device /dev/video0 could be provided like this:
dev0_Exposure_Time_us_min = 1000
dev0_Exposure_Time_us_max = 100000
By default, the control tests use the minimum and maximum values reported by the V4L2 driver to test a control. Additional test values can be provided as global configuration parameters in the configuration file, using a format similar to the min/max format:
dev<number of device>_<escaped control name>_testvalues = "<space-delimited list of values>"
For example:
dev0_Exposure_Time_us_testvalues = "25000 50000 75000"
Arguments:
| Switch | Function |
|---|---|
| -l | Used log file, Used log file, default blts_v4l2_log.txt |
| -e | Execute single or multiple selected tests, for example -e 1,4,5. |
| -en | Execute test by name, for example -en "My test X" |
| -s | Show list of all tests |
| -C | Used configuration file and path, for example /etc/blts/blts-v4l2-tests.cnf |
| -? | Help message |
| -xml, -axml | Create result XML. -axml appends results to an existing XML file. |
| -auto | Silent logging for test automation. Only the results are printed to stdout. |
| -v | Verbose logging (default) |
| -vv | Even more verbose logging |
| Optional switch | Function |
| -p | Print ioctl profiling data |
| -i | Save camera snapshot images to disk in control settings tests, and optionally verify them. Image save path and the verification tool are specified by the image_save_path and image_verify_tool configuration parameters.
|
Test cases must be run with root privileges.
Test case execution notices:
| Case name | Notice |
|---|---|
| Core-Camera-Open device | |
| Core-Camera-Read device | |
| Core-Camera-Check device controls | |
| Core-Camera-Check device capabilites | |
| Core-Camera-Check device formats | |
| Core-Camera-Measure device stepping down resolution | |
| Core-Camera-Stream from device to screen | |
| Core-Camera-Measure device FPS with defined resolution | |
| Core-Camera-Take picture as JPEG with device | |
| Core-Camera-Device enumeration | |
| Core-Camera-Stream from device and crop corners | |
| Core-Camera-Read from device using poll | |
| Core-Camera-Test standard control settings | supports external image verification tool |
| Core-Camera-Test extended control settings | supports external image verification tool |
| Core-Camera-Check device FD priority | |
| Core-Camera-Stream from device and vary frame rate | |
| Core-Camera-Get stream quality setting | |
| Core-Camera-Set stream quality setting to high | |
| Core-Camera-Check debug capability | not necessary supported by driver |
| Core-Camera-Select output and stream | |
| Core-Camera-Select input and stream | |
| Core-Camera-Test input device standards |
Test case descriptions and execution commands:
$ blts-v4l2-tests -en "Core-Camera-Open device"
$ blts-v4l2-tests -en "Core-Camera-Read device"
$ blts-v4l2-tests -en "Core-Camera-Check device controls"
$ blts-v4l2-tests -en "Core-Camera-Check device capabilites"
$ blts-v4l2-tests -en "Core-Camera-Check device formats"
$ blts-v4l2-tests -en "Core-Camera-Measure device stepping down resolution"
$ blts-v4l2-tests -en "Core-Camera-Stream from device to screen"
$ blts-v4l2-tests -en "Core-Camera-Measure device FPS with defined resolution"
$ blts-v4l2-tests -en "Core-Camera-Take picture as JPEG with device"
$ blts-v4l2-tests -en "Core-Camera-Device enumeration"
$ blts-v4l2-tests -en "Core-Camera-Stream from device and crop corners"
$ blts-v4l2-tests -en "Core-Camera-Read from device using poll"
$ blts-v4l2-tests -en "Core-Camera-Test standard control settings"
$ blts-v4l2-tests -en "Core-Camera-Test extended control settings"
$ blts-v4l2-tests -en "Core-Camera-Check device FD priority"
$ blts-v4l2-tests -en "Core-Camera-Stream from device and vary frame rate"
$ blts-v4l2-tests -en "Core-Camera-Get stream quality setting"
$ blts-v4l2-tests -en "Core-Camera-Set stream quality setting to high"
$ blts-v4l2-tests -en "Core-Camera-Check debug capability"
$ blts-v4l2-tests -en "Core-Camera-Select input and stream"
$ blts-v4l2-tests -en "Core-Camera-Select output and stream"
$ blts-v4l2-tests -en "Core-Camera-Test input device standards"
To run test case with variable data you need to specify where configuration file is located or if no configuration file is given, test driver tries to use default /etc/blts/blts-v4l2-tests.cnf
Edit the configuration file yourself if necessary.
To run "Core-Camera-Stream from device to screen" case you can use:
blts-v4l2-tests -l /var/log/tests/Core-Camera-Stream_from_device_to_screen.log -en "Core-Camera-Stream from device to screen" -C example-blts-v4l2.cnf
Example of Stream case variation (example-blts-v4l2.cnf):
# Valid video devices for HW. [parameter] name video_device const "/dev/video0" "/dev/video1" [end_parameter] [parameter] name io_method_stream const "MMAP" "userptr" [end_parameter] # Pixel formats (fourcc, as kernel v4l2 entries) [parameter] name camera_pixel_format const "YUYV" [end_parameter] [parameter] name camera_resolution_stream_all const "4016x3016" "2400x1812" "848x480" "640x480" "320x240" [end_parameter] [test] name "Core-Camera-Stream from device to screen" params video_device camera_pixel_format io_method_stream camera_resolution_stream_all [end_test]
| linux.bytesex.org | video4linux website |
| www.linuxtv.org | The LinuxTV project website |
| blts-v4l2 | blts-v4l2 tests |
| Version | Date | Handled By | Status | Comments |
|---|---|---|---|---|
| 0.1 | 22-sep-2010 | Iekku Huttunen | Draft | Page created |
| 0.2 | 8-Dec-2010 | Aki Nyman | Draft | Documentation updated to refer blts-v4l2 test package 0.3.8 |