Commit graph

56 commits

Author SHA1 Message Date
Niklas Söderlund
5023ad293d test: delayed_controls: Add test case for DelayedControls
Add a test case for DelayedControls that exercises the setting of
controls and reading back what controls were used for a particular
frame. Also exercise corner cases such as a V4L2 device that does not
reset its sequence number to 0 at stream on and sequence number wrapping
around the uint32_t value space.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-29 15:35:28 +01:00
Kieran Bingham
bf68e72276 meson: test: Simplify top level meson
Utilise the subdir_done() functionality as is used with other optional
components to simplify the top level meson file.

Suggested-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-12-30 15:31:45 +00:00
Kieran Bingham
e5b829ee53 test: mapped-buffers: Provide MappedBuffer test
Provide initial testing framework for the MappedBuffer component.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-06 15:44:00 +01:00
Umang Jain
9c5f821396 tests: Add a test case for the Object::deleteLater() API, to verify
- the object is deleted from the correct thread
- multiple deleteLater() calls delete the object once only

Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-07-31 23:33:35 +03:00
Laurent Pinchart
624f6d54ff test: Remove list-cameras test
The list-cameras test case is the very first test case that has been
added to libcamera. It has served to start the development of the unit
tests infrastructure. Since then, libcamera has grown several tests that
cover the same API, and more. It's time for list-cameras to retire.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <email@uajain.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-07-28 01:27:30 +03:00
Paul Elder
e37e72c61c tests: v4l2_compat: Add test for v4l2_compat
Test the V4L2 compatibility layer by running v4l2-compliance -s on every
/dev/video* device.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-07-10 16:11:53 +09:00
Kaaira Gupta
2129117df9 libcamera: pixel_format: Replace hex with format names
Print format names defined in formats namespace instead of the hex
values in toString() as they are easier to comprehend. For this add
a property of 'name' in PixelFormatInfo' so as to map the formats
with their names. Print fourcc for formats which are not used in
libcamera.

Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-06-25 06:47:48 +03:00
Umang Jain
8960ef9715 tests: Introduce hotplug hot-unplug unit test
This test checks the code-paths for camera's hotplugged and
unplugged support. It is based on bind/unbind of a UVC device
from sysfs. Hence, this test requires root permissions to run
and should have at least one already bound UVC device present
in the system.

Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-06-17 00:27:59 +03:00
Laurent Pinchart
7a653369cb licenses: License all meson files under CC0-1.0
In an attempt to clarify the license terms of all files in the libcamera
project, the build system files deserve particular attention. While they
describe how the binaries are created, they are not themselves
transformed into any part of binary distributions of the software, and
thus don't influence the copyright on the binary packages. They are
however subject to copyright, and thus influence the distribution terms
of the source packages.

Most of the meson.build files would not meet the threshold of
originality criteria required for copyright protection. Some of the more
complex meson.build files may be eligible for copyright protection. To
avoid any ambiguity and uncertainty, state our intent to not assert
copyrights on the build system files by putting them in the public
domain with the CC0-1.0 license.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Acked-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Acked-by: Naushir Patuck <naush@raspberrypi.com>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Acked-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Acked-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Show Liu <show.liu@linaro.org>
2020-05-13 16:46:24 +03:00
Laurent Pinchart
b9b54fd1b4 test: Add File class tests
Add tests for the File class API.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-04-14 02:03:18 +03:00
Laurent Pinchart
996db4c23d test: Add Span test
Add a compile-only test that exercises the whole Span API, as template
functions are not fully compile-tested when the file is parsed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-03-06 18:10:02 +02:00
Niklas Söderlund
5f316d0035 test: file_descriptor: Add test
Add a test which exercises the whole FileDescriptor interface.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-01-12 16:10:37 +01:00
Jacopo Mondi
c0b437fd6c test: Add control serialization test
Add a test that exercises the ControlSerializer to serialize and
deserialize ControlInfoMap and ControlList.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-11-20 21:47:54 +02:00
Laurent Pinchart
56c9a978d6 test: Add ByteStreamBuffer test
The test exercises the API of the ByteStreamBuffer class in both read
and write modes, including carve out buffers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-11-20 21:47:50 +02:00
Laurent Pinchart
f391048a7b libcamera: utils: Add hex stream output helper
Add a utils::hex() function that simplifies writing hexadecimal values
to an ostream. The function handles the '0x' prefix, the field width and
the fill character automatically. Use it through the libcamera code
base, and add a test.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-10-15 16:49:55 +03:00
Laurent Pinchart
fd0087b5d8 test: Get event dispatcher from current thread
For all tests that don't otherwise require access to the camera manager,
get the event dispatcher from the current thread instead of the camera
manager. This prepares for the removal of CameraManager::instance().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-19 19:06:37 +03:00
Laurent Pinchart
4d9f1a0efc test: Add Timer thread move test
The test verifies correct behaviour of a running timer moved to a
different thread.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-08-17 18:47:17 +03:00
Laurent Pinchart
92b4af98cd test: Add EventNotifier thread move test
The test verifies correct behaviour of an enabled event notifier moved
to a different thread.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-08-17 18:46:54 +03:00
Laurent Pinchart
980d1ee0c0 test: Add Object class thread affinity test
The test verifies thread affinity and thread move notifications.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-08-17 18:32:37 +03:00
Laurent Pinchart
a991d5aac0 test: Add Object::invokeMethod() test
The test verifies correct behaviour of asynchronous method invocation
for Object instances.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-08-17 18:32:36 +03:00
Paul Elder
36d62298b2 test: logging: move logging tests to a subdirectory
Since there are two logging tests now, move them to their own
subdirectory. Update meson as necessary.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-17 14:36:35 +09:00
Paul Elder
4cdabcddc5 test: logging: add logging process test
Add a test to test that logging works in isolated child processes.
Only logSetFile is tested, because stdout and stderr are closed for
isolated child processes, and syslog and the none logging destinations
are expected to be the same as non-isolated processes.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-17 14:36:35 +09:00
Paul Elder
3d20beca66 libcamera: Add Process and ProcessManager classes
Add a Process class to abstract a process, and a ProcessManager singleton
to monitor and manage the processes.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-12 16:32:29 +09:00
Paul Elder
a25c937f8a test: add logging API test
Test that setting the log file and log levels works from an application
point of view. The test uses the internal logging mechanism as well,
just to write to the log file.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-12 13:46:48 +09:00
Laurent Pinchart
a1b1551446 test: Add test case for signal delivery across threads
The test case creates a receiver inheriting from Object, connects a
signal to one of its slot, moves the receiver to a different thread,
emits the signal and verifies that it gets delivered in the correct
thread with the expected value.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-11 11:57:37 +03:00
Laurent Pinchart
851eaeb9cd test: Add Message test case
The Message class test creates a receiver inheriting from Object, moves
it to a different thread, sends a message to the receiver and verifies
that the message is delivered in the correct thread.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-11 11:57:37 +03:00
Laurent Pinchart
a7fb1db1fa test: Add Thread test cases
The Thread test case verifies that

- a Thread instance is created for the main thread
- a new Thread can be created, started, and stopped

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-11 11:57:37 +03:00
Kieran Bingham
4cbf83da40 libcamera: test: Add ControlValue test
Add initial basic testing for the new ControlValue class.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-02 16:59:46 +03:00
Niklas Söderlund
a00fdabacd test: ipc: unix: Add test for IPCUnixSocket
Test that the IPC supports sending data and file descriptors over the
IPC medium. To be able to execute the test two parts are needed, one
to drive the test and act as the libcamera (master) and a one to act as
the IPA (slave).

The master drives the testing posting requests to the slave to process
and sometimes respond to. A few different tests are performed.

- Master sends an array to the slave which responds with a reversed copy
  of the array. The master verifies that a reversed array is returned.

- Master tries to send an empty message making sure that the send call
  fails.

- Master sends a list of file descriptors and ask the slave to calculate
  and respond with the sum of the size of the files. The master verifies
  that the calculated size is correct.

- Master sends a pre-computed size and a list of file descriptors and
  asks the slave to verify that the pre-computed size matches the sum of
  the size of the file descriptors.

- Master sends two file descriptors and asks the slave to join the file
  contents in a new file and respond with its file descriptor. The
  master then verifies that the content of the returned file descriptor
  matches the order of the original two files.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-02 02:25:59 +03:00
Jacopo Mondi
3a6c4bd146 libcamera: Rename V4L2Device to V4L2VideoDevice
In preparation of creating a new V4L2Device base class, rename
V4L2Device to V4L2VideoDevice.

This is a project wide rename without any intended functional change.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-06-19 15:46:44 +02:00
Niklas Söderlund
5ed3a89480 test: stream: Add test for StreamFormat
Test that both discrete and range based stream format descriptions
result in good discrete frame sizes. The range based stream formats
needs to be fitted with a table of resolutions inside libcamera so if
that table is updated this test might need to be updated.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-06-19 12:25:12 +02:00
Laurent Pinchart
b2b3599b5b tests: Add CameraSensor class test
Add a test to verify media bus codes, sizes and resolution retrieval
through the CameraSensor API based on the Sensor A in the vimc pipeline.
Also check that the getFormat() method returns the expected media bus
code and size.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-06-12 15:10:38 +03:00
Laurent Pinchart
3fac104158 meson: Create and use a dependency for libcamera and its headers
Instead of manually adding the libcamera library and include path to
every target that requires it, declare a dependency that groups the
headers as source, the library and the include path, and use it through
the project. This simplifies handling of the dependency.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-05-23 13:56:33 +03:00
Paul Elder
d8de003a04 test: ipa: add IPAModule tests
Add tests to test the the IPAModule class, for loading the IPA module
info from IPA module .so shared objects, with modules written in both C
and C++.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-05-21 18:35:11 -04:00
Laurent Pinchart
2059b857e1 test: geometry: Add tests for Size class comparison operators
Add a test that exercises all the comparison operators for the Size
class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-18 18:13:10 +03:00
Niklas Söderlund
86a1900657 test: camera: Add read default configuration test
Add a test to verify reading the default configuration from a camera
works.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-03-14 15:59:00 +01:00
Jacopo Mondi
7f4ce94ad9 test: v4l2_subdevice: Add format handling test
Add test for video format get and set operations on V4L2Subdevice class.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-03-01 12:33:17 +01:00
Laurent Pinchart
83c73c39c5 tests: Test event dispatcher interruption by signal
Add a test to verify that the event dispatcher correctly restarts event
processing when interrupted by a signal. The test currently fails as
this feature isn't implemented.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-23 18:51:56 +02:00
Jacopo Mondi
e410062003 test: pipeline: IPU3: Add IPU3 pipeline test
Add test for the Intel IPU3 pipeline that lists all the cameras
registered in the system and verifies the result matches the expected.

This test is meant to be run on IPU3 platforms, it gets skipped
otherwise.

Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-22 11:16:28 +01:00
Kieran Bingham
479264dfca test: v4l2_device: Add test suite and initial test
Provide a base class to construct a v4l2_device object for further tests
and an initial test which validates the FD handle can not be leaked.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-17 21:55:27 +00:00
Laurent Pinchart
aed8c7823e test: Add event notifier test
The test covers read notification and notifier enable/disable.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-08 16:23:16 +02:00
Laurent Pinchart
034ea86802 test: Add timer test
The test covers timer start, timeout, restart after completion, restart
before completion and multiple timers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-08 16:23:16 +02:00
Laurent Pinchart
f151895c3f test: Add signal/slot test
The test covers signal connection, disconnection through all the
provided methods, emission, parameters, and connection of a signal to
multiple slots.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-08 16:23:16 +02:00
Laurent Pinchart
03815afdc8 test: Rename list test to list-cameras
The list test generates a list binary in the test directory, which
conflicts with the C++ std::list header of the same name. The binary
gets included instead of the header file, breaking compilation.

Rename the test to avoid this.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-08 16:23:16 +02:00
Kieran Bingham
b403cb4550 test: Move include definitions to libtest
With the libtest functionality moved to its own library folder, the
definitions for test includes should reasonably live there too.

The libtest subdir should always remain the first entry in the
test/meson.build file.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-02 11:08:20 +02:00
Kieran Bingham
5802259b3c test: Use foreach iterators to simplify definitions
Create two arrays, to contain public and internal test targets, and use
the foreach iterators to automatically generate test output targets for
each entry in each array.

The public tests array is linked only against public libcamera headers,
while tests declared in the internal_tests will have access to
non-public API headers from within the libcamera sources.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-02 11:07:27 +02:00
Kieran Bingham
a9fe3adc4f test: media_device: Move test definition
The test definition for the media_device_test executable should be
located with the exectuable definition.

Move it to the meson.build of that test suite subdir.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-02 11:05:26 +02:00
Laurent Pinchart
7e9e508093 libcamera: Remove libcamera class
The class was just a placeholder, now that we have other objects
defined, remove it along with the associated test.

The libcamera/libcamera.h header is kept as a shortcut to include the
whole libcamera public API.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-02 03:28:19 +02:00
Kieran Bingham
3900b0771e test: Move test objects to libtest
Create a subdirectory to contain the libtest helper library.

Define two variables to clarify when tests are aimed at public or
internal components.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-01 18:24:22 +02:00
Jacopo Mondi
b43f56c46d test: Add media device test
Add media device test infrastructure and an intial test that
print out the media devices available in the system.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2018-12-31 19:01:35 +01:00