Commit graph

489 commits

Author SHA1 Message Date
Laurent Pinchart
0554a55427 test: camera: Increase timeout for vimc capture tests
On slower machines, a 1s timeout to capture frames with vimc can be too
short and cause test failures. Make the timeout proportional to the
number of frames expected to be captured, using a conservative low
estimate of the frame rate at 2fps.

By itself, that change could increase the test time quite substantially
on fast platforms, so break from the capture loop as soon as we capture
enough frames. To do so, interrupt the dispatcher at every request
completion, or it will only get interrupted after the timer times out.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-06-03 11:53:01 +03:00
Paul Elder
9b29eba7a2 test: ipa: rkisp1-utils: Fix capitalization of hex numbers
Fix capitalization of the hexdecimal numbers in the test for conversion
between floating point and fixed point numbers.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-05-31 23:29:41 +09:00
Paul Elder
9d152e9c66 ipa: rkisp1: Add a helper to convert floating-point to fixed-point
Add helper functions for converting between floating point and fixed
point numbers. Also add tests for them.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-05-31 17:12:48 +09:00
Julien Vuillaumier
5ed35fca68 libcamera: pipeline: Rename pipelines to a shorter name
The PipelineHandlerFactoryBase class has a name that is propagated to
the PipelineHandler instance it creates.

In present implementation, this name comes from the
REGISTER_PIPELINE_HANDLER registration macro. It corresponds to the
stringified name of the PipelineHandler derived class. Therefore,
PipelineHandler factories and instances names can be quite long such as
"PipelineHandlerRkISP1".

A libcamera user may have to explicitly refer to a PipelineHandler name
for configuration purpose: one usage of the name can be to define a
pipeline handlers match list and their priorities. It is desired, for
user convenience, to use a short name to designate a pipeline handler.
Reusing the short pipeline names already defined in the meson option
files is an existing and consistent way of naming pipelines.

This change adds an explicit name parameter to the
REGISTER_PIPELINE_HANDLER registration macro. That parameter is used to
define the name of a pipeline handler factory, instead of the current
pipeline handler class name.

Each pipeline registration is updated accordingly. The short name
assigned corresponds to the pipeline directory name in the source tree.
It is consistent with pipelines names used in meson.

Changing the pipeline name has an impact on the IPA modules: each module
defines a IPAModuleInfo structure. This structure has a pipelineName
member defining the pipeline handler name it shall match with.
Therefore, each internal IPA module definition has to be changed to have
its IPAModuleInfo pipelineName name updated with the short pipeline
handler name.

In addition to this pipelineName member, the IPAModuleInfo structure
also has a name member, associated to the IPA module name. Having
renamed the pipelines to a short name, the pipeline name and the IPA
module names of the IPAModuleInfo structure are the same: for in-tree
IPA, they correspond to the respective pipeline and IPA subdirectories
in the source tree.  However the IPA name could be different, for
instance with a close source IPA implementation built out-of-tree. Thus,
it makes sense to keep the IPA name in that structure, as the 2
definitions may not always be redundant.

Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
[Kieran: Adjust for clang-format style fix, reformat commitmsg]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-05-14 23:20:29 +01:00
Nicolas Dufresne
a2a61121eb test: gstreamer: Simplify single stream test
The single stream test for the GStreamer component has a simple pipeline
construction using only a fakesink.

The implementation currently supports connecting to a more complex
stream construction defined by the streamDescription, but this is over
engineered for the simple need to start a stream to capture and discard
the frames.

Convert the use of gst_parse_bin_from_description_full() which uses only
a single element 'fakesink' to construct the fakesink directly and link
it to the libcamerasrc.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
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>
2024-05-13 16:33:43 +03:00
Laurent Pinchart
3cb20bc230 libcamera: Drop remaining file name from header comment blocks
Source files in libcamera start by a comment block header, which
includes the file name and a one-line description of the file contents.
While the latter is useful to get a quick overview of the file contents
at a glance, the former is mostly a source of inconvenience. The name in
the comments can easily get out of sync with the file name when files
are renamed, and copy & paste during development have often lead to
incorrect names being used to start with.

Readers of the source code are expected to know which file they're
looking it. Drop the file name from the header comment blocks in all
remaining locations that were not caught by the automated script as they
are out of sync with the file name.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-05-09 23:31:15 +03:00
Laurent Pinchart
626172a16b libcamera: Drop file name from header comment blocks
Source files in libcamera start by a comment block header, which
includes the file name and a one-line description of the file contents.
While the latter is useful to get a quick overview of the file contents
at a glance, the former is mostly a source of inconvenience. The name in
the comments can easily get out of sync with the file name when files
are renamed, and copy & paste during development have often lead to
incorrect names being used to start with.

Readers of the source code are expected to know which file they're
looking it. Drop the file name from the header comment block.

The change was generated with the following script:

----------------------------------------

dirs="include/libcamera src test utils"

declare -rA patterns=(
	['c']=' \* '
	['cpp']=' \* '
	['h']=' \* '
	['py']='# '
	['sh']='# '
)

for ext in ${!patterns[@]} ; do
	files=$(for dir in $dirs ; do find $dir -name "*.${ext}" ; done)
	pattern=${patterns[${ext}]}

	for file in $files ; do
		name=$(basename ${file})
		sed -i "s/^\(${pattern}\)${name} - /\1/" "$file"
	done
done
----------------------------------------

This misses several files that are out of sync with the comment block
header. Those will be addressed separately and manually.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2024-05-08 22:39:50 +03:00
Laurent Pinchart
6cd8491258 test: Don't add current build directory to include path
Meson adds the current source and build directory to the include path by
default. This causes a namespace clash in tests when using C++20, as the
Span class test is compiled into a binary named 'span', which then gets
included by source code through indirect '#include <span>' directives.
Unsurprisingly, the compiler doesn't react happily when fed binary data.

We could work around the problem by renaming the test executable, but
disabling the implicit inclusion of the local directory is a more
generic solution that will avoid similar issues in the future.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-05-07 19:35:43 +03:00
Laurent Pinchart
d41e0585e9 libcamera: v4l2_subdevice: Rename V4L2SubdeviceFormat::mbus_code to code
The V4L2SubdeviceFormat::mbus_code member doesn't follow the libcamera
coding style as it should use camelCase. Fix it by renaming it to just
'code', to shorten lines in addition to fixing the coding style.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-15 12:55:03 +02:00
Stefan Klug
d54abd32af libcamera: controls: Add policy parameter to ControlList::merge()
This is useful in many cases although not included in the stl.

Note: This is an ABI incompatible change.

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
2024-03-12 17:04:28 +01:00
Laurent Pinchart
fdcea5ad79 test: timer-thread: Destroy Object from correct thread context
The TimeoutHandler used in the test is destroyed from the main thread,
which is invalid for a thread-bound object bound to a different thread.
Fix it by destroying it with deleteLater().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-01-25 02:39:20 +02:00
Laurent Pinchart
4f76beae86 test: timer-thread: Move timer start from wrong thread to separate test
Starting a timer from the wrong thread is expected to fail, and we test
this in the timer-thread unit test. This is however not something that a
caller is allowed to do, and libcamera will get assertion failures to
catch this invalid usage. The unit test will then fail.

To prepare for this, split the unit test in two, with a test that is
expected by meson to succeed, and one that is expected to fail. The
assertion will then cause an expected failure, making the test suite
succeed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-01-25 02:39:15 +02:00
Laurent Pinchart
dfe81fd702 test: signal-threads: Destroy Object from correct thread context
The SignalReceiver used in the test is destroyed from the main thread,
which is invalid for a thread-bound object bound to a different thread.
Fix it by destroying it with deleteLater().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-01-25 02:39:14 +02:00
Laurent Pinchart
edbcdebba7 test: message: Destroy Object from correct thread context
The MessageReceiver and RecursiveMessageReceiver used in the test are
destroyed from the main thread, which is invalid for a thread-bound
object bound to a different thread. Fix it by destroying them with
deleteLater().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-01-25 02:39:12 +02:00
Laurent Pinchart
652b47249a test: message: Remove incorrect slow receiver test
The slow receiver test verifies there's no race condition between
concurrent message delivery and object deletion. This is not a valid use
case in the first place, as objects are not allowed to be deleted from a
different thread than the one they are bound to. Remove the incorrect
test.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-01-25 02:39:10 +02:00
Laurent Pinchart
1f5d485bfb test: event-thread: Destroy Object from correct thread context
The EventHandler used in the test is destroyed from the main thread,
which is invalid for a thread-bound object bound to a different thread.
Fix it by destroying it with deleteLater().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-01-25 02:39:08 +02:00
Laurent Pinchart
d47fa37c2e test: object-delete: Test deferred delete just before thread stops
The Object::deleteLater() function is expected to not race with stopping
the thread the object is bound to. Add a test for this.

The test currently fails, demonstrating a bug in libcamera.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-01-25 02:39:02 +02:00
Laurent Pinchart
d5c9b726bd libcamera: signal: Replace object.h inclusion with forward declatation
The signal.h header doesn't need to include object.h. Replace it with a
forward declaration, and instead include object.h in source files that
require it. It can speed up compilation a little bit, but more
importantly avoids unintended dependencies from the Signal class to the
Object class to be added later as the compiler will catch them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-01-25 02:38:59 +02:00
Nicolas Dufresne
484c86ac65 test: gstreamer: Use env instead of registry edit
Instead of editing the registry, use gst_env variable provided by the plugin and
already used as part of the devenv shell. This reduces the complexity of the
C++ test code.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-23 02:21:39 +02:00
Laurent Pinchart
17d8b89deb test: gstreamer: Remove videoconvert element from pipeline
The GStreamer single stream test uses the following pipeline:

	libcamerasrc ! videoconvert ! fakesink

The videoconvert element isn't useful as the data is thrown away by the
fakesink anyway. We can shorten the pipeline to

	libcamerasrc ! fakesink

to save CPU time and to avoid depending on the gstreamer1.0-plugins-base
package to run the unit tests.

The test could be further simplified by replacing
gst_parse_bin_from_description_full() with gst_element_factory_make(),
now that we only add one element to the bin. The extra cost incurred by
the bin only impacts initialization time, and using a bin will make it
easier to add other elements in the future if needed. Keep the bin, and
only drop the videoconvert element.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-12-07 18:59:42 +02:00
Laurent Pinchart
efcda47985 test: ipc: unixsocket: Increase process exit timeout
When running tests on slower devices, 200ms is too low to wait for the
process to exit. Increase the timeout to 2s.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-12-07 18:59:42 +02:00
Laurent Pinchart
9dc2642d2c test: log: log_process: Increase process exit timeout
When running tests on slower devices, 200ms is too low to wait for the
process to exit. Increase the timeout to 2s.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-12-07 18:59:42 +02:00
Laurent Pinchart
2d12e6088e test: log: log_process: Improve debugging on process exit failures
When the process fails to run and exit normally, the test prints an
error message that provides little information:

	process did not exit normally

Expand the error message to print the exit status to make debugging
easier.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-12-07 18:59:42 +02:00
Laurent Pinchart
db31477433 test: log: log_process: Fix uninitialized variable on process exit failure
If the process fails to exit before the timeout, the
LogProcessTest::exitStatus_ variable gets used uninitialized. Fix it by
initializating to Process::NotExited.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-12-07 18:59:42 +02:00
Laurent Pinchart
030fe617ef test: log: log_process: Log an error when failing due to incorrect message
One of the error paths in the test returns without logging a message,
which makes failures difficult to debug. Fix it by adding an error
message.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-12-07 18:59:42 +02:00
Laurent Pinchart
d61104fa7b test: gstreamer: Fix indentation in comments
A couple of comments are mis-indented in the gstreamer unit test. Fix
them, and reflow the text while at it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-12-06 02:51:35 +02:00
Jacopo Mondi
69b2dc16a0 test: Add unit test for Transform and Orientation
Add a unit test for Transform and Orientation to validate the
implementation of the operations between the two types.

In particular, test that:

	o1 / o2 = t
	o2 * t = o1

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-10-23 16:06:05 +03:00
Laurent Pinchart
03526e58d1 tests: gstreamer: Fix compiler error with gcc 8.4.0
The provider g_autoptr variable introduced by commit adb1bbb748
("tests: gstreamer: Test cameras' enumeration from GstDeviceProvider")
is left uninitialized when declared. The cleanup function could thus get
called on an unitialized variable if the scope was exited before the
variable gets initialized. This can't occur here, but gcc 8.4.0 still
complains about it:

/usr/include/glib-2.0/glib/gmacros.h: In member function ‘virtual int GstreamerDeviceProviderTest::run()’:
/usr/include/glib-2.0/glib/gmacros.h:1049:27: error: ‘provider’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     { if (_ptr) (cleanup) ((ParentName *) _ptr); }                                                              \
                           ^
../test/gstreamer/gstreamer_device_provider_test.cpp:37:32: note: ‘provider’ was declared here
   g_autoptr(GstDeviceProvider) provider;

Silence the error by initializing the variable to NULL at declaration
time. This is a good practice in any case, as later refactoring could
otherwise introduce a scope exit before initialization.

Fixes: adb1bbb748 ("tests: gstreamer: Test cameras' enumeration from GstDeviceProvider")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-07-11 15:58:06 +01:00
Laurent Pinchart
ca437b4a0c meson: Fix space around colon issues
The meson style, which libcamera follows, recommends a space before
colons in function parameters. Fix the style violations through the
project.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2023-07-07 11:39:19 +03:00
Umang Jain
adb1bbb748 tests: gstreamer: Test cameras' enumeration from GstDeviceProvider
Test the enumeration of the cameras through GstDeviceProvider against
the libcamera camera manager.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
2023-07-06 10:05:27 +02:00
Tomi Valkeinen
f44df6f4fa py: unittests.py: Fix type checker warnings
Fix type checker warnings by dropping unused imports and using _ for
variable names that are not used.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-06-04 16:10:51 +03:00
Tomi Valkeinen
51dc505d63 py: unittests.py: Add weakref helpers and use del
Add helpers to check if a weakref or a list of weakrefs is alive or
dead.

Also use 'del' for local variables instead of setting the variable to
None. This makes debugging the test easier as the locals will be gone
from locals() dict.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-05-30 18:29:10 +03:00
Tomi Valkeinen
1fb31ac4f4 py: Use exceptions instead of returning error codes
We have multiple methods which return an error code, mimicking the C++
API. Using exceptions is more natural in the Python API, so change all
those methods to raise an Exception instead.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-05-30 18:29:09 +03:00
Tomi Valkeinen
9506da142b py: Fix CameraManager.version property
The current CameraManager.version doesn't work at all (raises a
TypeError), as that's not how you use expose C++ static methods as
Python class methods.

Fix it.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-05-30 18:29:08 +03:00
Mattijs Korpershoek
683c6da83f test: controls: control_info_map: Test default constructor
ControlInfoMap can be default-constructed. In that case, some of its
members (like idmap_) can be a nullptr, and ControlInfoMap.find() will segfault.

Add a test with a default constructed ControlInfoMap to cover this.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-04-20 10:54:12 +01:00
Laurent Pinchart
c00a3a8f52 test: Drop pipeline test
The two pipeline test (for ipu3 and rkisp1) are meant to perform very
basic validation of the corresponding pipeline handlers, limited to
verifying camera enumeration. They are not unit tests as such, they are
superseded by the lc-compliance tool, and they are never used in
practice (and always skipped). Drop them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-12-24 03:29:49 +02:00
Laurent Pinchart
d48e15d571 test: py: Fix test failure when ASan is enabled
When the address sanitizer is enabled, the Python unit tests fail due to
the link order runtime check as the Python interpreter is (generally)
not linked to ASan. Fix this by LD_PRELOAD'ing the ASan runtime. We have
to disable the leak detector as the Python interpreter itself leaks
memory, which would result in test failures.

To LD_PRELOAD the ASan runtime, the path to the binary needs to be
known. gcc gives us a generic way to get the path, but that doesn't work
with clang as the ASan runtime file name depends on the clang version
and target architecture. We thus have to keep the Python test disabled
when ASan is enabled and libcamera is compiled with clang.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-12-24 03:29:47 +02:00
Laurent Pinchart
121b5de329 test: v4l2_compat: Enable test with ASan
When libcamera is compiled with the address sanitizer enabled, the
v4l2_compat test generates failures in the link order runtime check, as
the host v4l2-ctl and v4l2-compliance tools are not (generally) linked
to ASan. For this reason, the test is disabled, which sadly shrinks test
coverage.

Fix this by loading the ASan runtime using LD_PRELOAD. This needs to be
done from within the v4l2_compat_test.py Python script, as the Python
interpreter itself leaks memory and would cause test failures if run
with ASan.

To LD_PRELOAD the ASan runtime, the path to the binary needs to be
known. gcc gives us a generic way to get the path, but that doesn't work
with clang as the ASan runtime file name depends on the clang version
and target architecture. We thus have to keep the v4l2_compat test
disabled when ASan is enabled and libcamera is compiled with clang.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-12-24 03:29:43 +02:00
Laurent Pinchart
9f06cd50cc test: v4l2_compat: Reduce indentation
Return early with subdir_done() to reduce indentation in case the
v4l2_compat layer is not enabled. This matches our usual code patterns
in meson.build files, and prepares for enabling the v4l2_compat test
with ASan.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-12-24 03:29:41 +02:00
Laurent Pinchart
b5ef421e03 test: controls: control_info: Test default def() values
Extend the ControlInfo test to verify the behaviour of the default 'def'
argument to the ControlInfo constructor.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-12-16 19:39:13 +02:00
Yunke Cao
3d612720fb libcamera: Test sensor's ability to discover ancillary devices
Use vimc lens to test sensor's ability to discover ancillary lens.

Tested with the recent kernel patch for vimc lens:
https://lore.kernel.org/linux-media/20220415023855.2568366-1-yunkec@google.com/

Signed-off-by: Yunke Cao <yunkec@google.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-11-24 14:52:00 +00:00
Laurent Pinchart
bc0d9a6f5d test: camera_reconfigure: Qualify move() with std:: namespace
clang-15 warns about unqualified std cast calls:

../../test/camera/camera_reconfigure.cpp:101:24: error: unqualified call to 'std::move' [-Werror,-Wunqualified-std-cast-call]
                        requests_.push_back(move(request));
                                            ^
                                            std::

Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2022-11-08 17:51:02 +02:00
Paul Elder
3b54b56a2d ipa: vimc: Add Flags to parameters
For the purpose of testing serializing/deserializing Flags in function
parameters, add an enum class TestFlags and Flags<TestFlags> to some
function parameters, both for input and output and Signals.

While at it, update the ipa_interface_test.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-18 18:52:52 +09:00
Paul Elder
23fd404690 ipa: vimc: Add IPAOperationCode to init() parameter list
For the purpose of testing serializing/deserializing enums in function
parameters, add IPAOperationCode to the parameter list of init().

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-10-18 18:52:51 +09:00
Paul Elder
deaf13de9b test: generated_serializer: Test Flags that is struct member
Add fields to the test struct to test serialization/deserialization of
scoped enums and flags that are struct members.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-10-18 18:52:42 +09:00
Paul Elder
44eb16fb18 test: generated_serializer: Test enum that is struct member
Add an enum field to the test struct member to test
serialization/deserialization of enums that are struct members.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-10-18 18:51:17 +09:00
Laurent Pinchart
e0e54965df libcamera: base: utils: Drop defopt
utils::defopt causes compilation issues on gcc 8.0.0 to gcc 8.3.0,
likely due to bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86521
that was fixed in gcc 8.4.0. gcc 8.3.0 may be considered old (libcamera
requires gcc-8 or newer), but it is shipped by Debian 10 that has LTS
support until mid-2024.

As no workaround has been found to fix compilation on gcc 8.3.0 while
still retaining the functionality of utils::defopt, remove it from the
libcamera base library. This change could be reverted once support for
gcc-8 will be dropped.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-10-10 17:04:29 +03:00
Laurent Pinchart
0bc9286eb9 libcamera: pipeline_handler: Implement factories through class templates
The REGISTER_PIPELINE_HANDLER() macro defines a class type that inherits
from the PipelineHandlerFactory class, and implements a constructor and
a createInstance() function. Replace the code generation through macro
with the C++ equivalent, a class template, as done in libipa with the
Algorithm and CameraSensorHelper factories.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-10-07 18:10:38 +03:00
Laurent Pinchart
ba3a1adc13 libcamera: pipeline_handler: Return unique_ptr from createInstance
Avoid naked pointer with memory allocation by returning a unique_ptr
from PipelineHandlerFactory::createInstance(), in order to increase
memory allocation safety.

This allows iterating over factories in the CameraManager and unit tests
using const pointers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-10-07 18:10:31 +03:00
Laurent Pinchart
8abcce31ee test: meson: Use dictionaries instead of arrays to store test information
Tests are listed in meson.build using arrays that contain the test name
and source files at fixed positions. This isn't very readable, leading
to code using test[0], test[1] and test[2]. Replace the arrays with
dictionaries to improve readability.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2022-10-07 17:05:42 +03:00