summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2022-08-03libcamera: v4l2_videodevice: Reintroduce toV4L2PixelFormat()Jacopo Mondi
This is a partial revert of commit 395d43d6d75b ("libcamera: v4l2_videodevice: Drop toV4L2PixelFormat()") The function was removed because it incorrectly maps non-contiguous V4L2 format variants (ie V4L2_PIX_FMT_YUV420M) to the API version supported by the video device (singleplanar API and multiplanar API). It was decided at the time to remove the function and let its users call directly V4L2PixelFormat::fromPixelFormat() which accepts a 'multiplanar' flags. As we aim to associate multiple V4L2PixelFormat to a single libcamera format, the next patches will verify which of them is actually supported by the video device. For now, return the contiguous version unconditionally. Re-introduce V4L2VideoDevice::toV4L2PixelFormat() and convert all the V4L2PixelFormat::fromPixelFormat() users to use it. The V4L2 compatibility layer is the only outlier as it doesn't have a video device to poke, hence it still uses V4L2PixelFormat::fromPixelFormat(). Next patches will implement the device format matching logic and handle the non-contiguous plane issue in V4L2VideoDevice::toV4L2PixelFormat(). Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Paul Elder <paul.elder@ideasonboard.com>
2022-08-01test: yaml-parser: Test YamlObject::get(const T &defaultValue)Laurent Pinchart
When the YamlObject::get() function override that returns a std::optional got introduced, all tests were moved to it, leaving no tests for the override that takes a default value. Reintroduce those tests. Reported-by: Florian Sylvestre <fsylvestre@baylibre.com> 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-07-28libcamera: base: utils: Provide defopt to simplify std::optional::value_or() ↵Laurent Pinchart
usage The std::optional<T>::value_or(U &&default_value) function returns the contained value if available, or default_value if the std::optional has no value. If the desired default value is a default-constructed T, the obvious option is to call std::optional<T>::value_or(T{}). This approach has two drawbacks: - The \a default_value T{} is constructed even if the std::optional instance has a value, which impacts efficiency. - The T{} default constructor needs to be spelled out explicitly in the value_or() call, leading to long lines if the type is complex. Introduce a defopt variable that solves these issues by providing a value that can be passed to std::optional<T>::value_or() and get implicitly converted to a default-constructed T. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-07-28libcamera: yaml_parser: Add getList() functionFlorian Sylvestre
Allow to retrieve a YAML list of any already supported types in a std::vector. Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com> Tested-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-07-28test: yaml-parser: Test dictionary items orderingLaurent Pinchart
While YAML specifies that mappings are unordered, the Raspberry Pi IPA relies on elements being ordered as in the YAML data. To replace the dependency on boost with the YamlParser class, we thus need to guarantee that the order is preserved. Update the corresponding unit test to ensure this. The test currently fails at the YamlParser doesn't correctly preserve the order, this will be fixed by the next commit. This commit should be reverted when the Raspberry Pi IPA updates to a new tuning data format and drops support for the old format. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Naushir Patuck <naush@raspberrypi.com>
2022-07-28libcamera: yaml_parser: Replace ok flag to get() with std::optionalLaurent Pinchart
The YamlObject::get() function takes a default value and an optional bool ok flag to handle parsing errors. This ad-hoc mechanism complicates error handling in callers. A better API is possible by dropping the default value and ok flag and returning an std::optional. Not only does it simplify the calls, it also lets callers handle errors through the standard std::optional class instead of the current ad-hoc mechanism. Provide a get() wrapper around std::optional::value_or() to further simplify callers that don't need any specific error handling. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-07-24test: gstreamer: Check availability of cameras before runningUmang Jain
Move the logic for checking the availability of cameras from multi_stream_test to gstreamer test base class. Since single_stream_class always assumes that a camera is available on the system (which is not always the case for e.g. RPi in CI/CD environments) it makes sense to have the availability check in the base class. If no cameras are available, the behaviour should be to skip instead of a failure. We currently have 2 tests for gstreamer differing based on number of streams supported by the camera. Hence, the camera availability is checked in conjunction with the number of the streams required by the derived class. Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-07-24test: gstreamer: Drop internal header from base classUmang Jain
The internal header isn't needed. The needed function libcameraBuildPath() is exposed by libcamera/base/utils.h header. At the same time, move the utils header to .cpp instead of including it in the base class header itself. Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-07-20test: control_list: Use get() to test for control presenceLaurent Pinchart
Now that the ControlList::get() function returns an std::optional<>, it is the preferred way to test if a control is present in a ControlList. Use it in the test to prepare for removal of ControlList::contains(). 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-07-06test: delayed_controls: Remove sequenceOffsetJacopo Mondi
Commit 6f539a6d2fa9 ("delayed_controls: Remove reduandant firstSequence_") removed support for frame number start offset from the DelayedControls class, as it is now guaranteed that the first sequence number as it comes from the V4L2VideoDevice will always be 0. However the delayed_controls.cpp unit still has two tests that passes a non-zero first sequence number to the DelayedControl class, causing the test to spin forever and consequentially fail. Remove the two tests from the unit to fix this. The first removed test was testing the class against frame start sequence numbers greater than zero and can safely be removed. The second test was instead validating the class against sequence number overflow, which is now not possible to test anymore as the DelayedControls class now assumes 0 as first frame sequence number. Fixes: 6f539a6d2fa9 ("delayed_controls: Remove reduandant firstSequence_") Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-06-20libcamera: yaml_parser: Remove memberNames() functionLaurent Pinchart
Now that YamlObject supports iteration, the memberNames() function isn't useful anymore as it can be implemented using utils::map_keys() if really needed. Drop it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
2022-06-20test: yaml_parser: Extend tests to cover the iterator APILaurent Pinchart
Test iteration over lists and dictionaries to test the YamlObject iterator API. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org>
2022-06-16test: yaml-parser: Use write() instead of fwrite()Laurent Pinchart
There's no point in wrapping a fd into a FILE to then only call fwrite() and fclose(). Use write() and close() directly. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-16libcamera: yaml_parser: Switch from FILE to FileLaurent Pinchart
THe FILE object isn't very user-friendly as it requires manual close. Replace it with File to provide RAII-style resource management in the YamlParser API. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-16libcamera: yaml_parser: Extend YamlObject::size() to dictionariesLaurent Pinchart
Dictionaries have a size too, extend the size() function to support them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2022-06-04py: Merge read_event() and get_ready_requests()Tomi Valkeinen
We always call CameraManager.read_event() and CameraManager.get_ready_requests(), so to simplify the use merge the read_event() into the get_ready_requests(). This has the side effect that get_ready_requests() will now block if there is no event ready. If we ever need to call get_ready_requests() in a polling manner we will need a new function which behaves differently. However, afaics the only sensible way to manage the event loop is to use select/poll on the eventfd and then call get_ready_requests() once, which is the use case what the current merged function supports. 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>
2022-06-01py: unittests: Fix test_select()Tomi Valkeinen
The test_select() currently uses self.assertTrue(len(ready_reqs) > 0) to see that cm.get_ready_requests() returns something. This is not always the case, as there may be two eventfd events queued, and the first call to cm.get_ready_requests() returns all the requests, and thus the second call returns none. Remove the self.assertTrue(len(ready_reqs) > 0) assert. 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>
2022-06-01py: unittests: Fix test_sleep()Tomi Valkeinen
Waiting for 0.5 secs and expecting that the requests have been completed is... bad. Fix the test case by using cam.read_event() as a blocking wait, and wait until we have received all the requests that we queued. 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>
2022-06-01libcamera: Use "..." instead of <...> consistently for internal headersLaurent Pinchart
libcamera uses double quotes for #include directives for internal headers. A few <...> have found their way in the code base over time. Fix them. While at it, move an Android header include to the right location. 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-05-27py: Rename 'efd' to 'event_fd'Tomi Valkeinen
Perhaps it's better to have a more descriptive name here. I also considered just renaming 'efd' to 'fd', but 'event_fd' won. 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>
2022-05-27py: Add CameraManager.read_event()Tomi Valkeinen
Add CameraManager.read_event() so that the user does not need to call os.read(). We use eventfd, and we must always read 8 bytes. Hiding that inside read_event() makes sense. 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>
2022-05-18py: unittests: Make typechecker happyTomi Valkeinen
Add some annotations and self.assertIsNotNone() calls to remove the typechecker warnings. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-18py: unittests: Verify that cam and cm are freedTomi Valkeinen
Add checks to CameraTesterBase to verify that both the Camera and the CameraManager gets freed. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-18py: unittests: Fix selector fd useTomi Valkeinen
pyright complains about passing fileobj to os.read. Indeed, the parameter should be an int, but I guess fileobj gets automatically converted. In any case, using the fd is better. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-10py: Add unittests.pyTomi Valkeinen
Add a simple unittests.py as a base for python unittests. 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> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-05-10meson: Use new project_*_root() functionsTomi Valkeinen
meson.source_root() and meson.build_root() are deprecated. Use meson.project_source_root() and meson.project_build_root() instead. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.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> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-05-10test: Add YamlParser testHan-Lin Chen
Add a unit test to exercise the API of the YamlParser class. Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-05-04libcamera: Replace toString with operator<<() for format classesLaurent Pinchart
Now that format classes implement the stream formatting operator<<(), use it instead of the toString() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-05-04libcamera: Replace toString with operator<<() for geometry classesLaurent Pinchart
Now that geometry classes implement the stream formatting operator<<(), use it instead of the toString() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-04-07test: v4l2_videodevice: Fix format configuration in the vimc pipelineLaurent Pinchart
The V4L2VideoDeviceTest class configures the capture pipeline with parameters that are partly hardcoded, and partly come from the current configuration of the device. In particular, with the vimc pipeline, the sensor subdevice is configured with the size retrieved from the capture video node, and the video node is then reconfigured to 640x480. Relying on the current (and thus possibly random) device configuration can lead to broken pipes when starting streaming. This currently causes failures of the dequeue_watchdog test when run after the formats test. Fix it by explicitly setting the same size for both the vimc subdevs and the video capture device. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-04-07test: v4l2_videodevice: dequeue_watchdog: Check return value of streamOnLaurent Pinchart
If the streamOn() call fails, there is no way the test will then succeed. Catch it and return a failure. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-04-07test: v4l2_videodevice: dequeue_watchdog: Log message on failuresLaurent Pinchart
Failing a test without an error message makes it difficult to debug issues. Add a message when buffer allocation fails. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-04-06test: v4l2_videodevice: Verify the Dequeue WatchdogKieran Bingham
Add a test that captures 5 frames, with a short (5ms) watchdog. The default framerate of the VIMC pipeline should ensure that we never meet this watchdog, and the timeout should activate. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-03-28test: Test V4L2BufferCache::isEmpty() member functionNaushir Patuck
Add a test for V4L2BufferCache::isEmpty() for various levels for cache fullness. Signed-off-by: Naushir Patuck <naush@raspberrypi.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>
2022-03-25libcamera: base: timer: Drop start() overload with int argumentLaurent Pinchart
The start(unsigned int msec) overload is error-prone, as the argument unit can easily be mistaken in callers. Drop it and update all callers to use the start(std::chrono::milliseconds) overload instead. The callers now need to use std::chrono_literals. The using statement could be added to timer.h for convenience, but "using" is discouraged in header files to avoid namespace pollution. Update the callers instead, and while at it, sort the "using" statements alphabetically in tests. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2022-02-04libcamera: base: object: Prevent the same signal being connected more than onceKieran Bingham
Objects are not expected to be connected to the same signal more than once. Doing so likely indicates a bug in the code, and can be highlighted in debug builds with an assert that performs a lookup on the signals_ list. While it is possible to allow the implementation to let objects connect to a specific signal multiple times, there are no expected use cases for this in libcamera and this behaviour is restricted to favour defensive programming by raising an error when this occurs. Remove the support in the test framework which uses multiple Signal connections on the same object, and update the test to use a second Signal. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-01-19test: Ensure CameraTest tests are not run in parallelKieran Bingham
The fence and mapped-buffer tests both use the VIMC test device and must not be run at the same time. Split these tests to a new group to force their isolation from running in parallel. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-01-17test: v4l2_compat: Add --verbose argumentLaurent Pinchart
Add a -v/--verbose argument to the v4l2_compat test to print the output of v4l2-compliance, even when the test passes. This can be useful when debugging. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-12-13test: fence: Signal fence onceJacopo Mondi
The unit test associates a fence with a framebuffer and makes sure the fence is correctly signalled. Once a fence is correctly signalled, it is released by the core, and the underlying file descriptor closed. The unit test however tries to write on the fence file descriptor every time the designated Request is queued, an error which is now visible as the return value of the fence signalling write() is checked. Fix that by associating a fence with a framebuffer only once. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-12-13test: fence: Check write return valueJacopo Mondi
The ::write() function used to signal a framebuffer fence in the unit test is marked with the 'warn_unused_result'. When building in debugoptimized mode not checking for the return value causes issues at build time: /test/fence.cpp:254:2: error: ignoring return value of function declared with 'warn_unused_result' attribute Fix that by checking the ::write() return value and emitting an error message in case the write fails. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reported-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-12-11test: fence: Add test for the Fence classJacopo Mondi
Add a test for the Fence class by testing a Fence failure case, and by testing a successfully signalled fence capture cycle. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-12-04libcamera: base: shared_fd: Rename fd() to get()Laurent Pinchart
For consistency with UniqueFD, rename the fd() function to get(). Renaming UniqueFD::get() to fd() would have been another option, but was rejected to keep as close as possible to the std::shared_ptr<> and std::unique_ptr<> APIs. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-12-04libcamera: base: Rename FileDescriptor to SharedFDLaurent Pinchart
Now that we have a UniqueFD class, the name FileDescriptor is ambiguous. Rename it to SharedFD. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-12-04libcamera: ipc_unixsocket: Use UniqueFD for a file descriptorHirokazu Honda
IPCUnixSocket::create() creates two file descriptors. One of them is stored in IPCUnixSocket and the other is returned to a caller. This clarifies the ownership using UniqueFD. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-12-03test: Add UniqueFD testLaurent Pinchart
Add a unit test to exercise the API of the UniqueFD class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-12-03libcamera: Move file_descriptor.h to base/Laurent Pinchart
The FileDescriptor class is a generic helper that matches the criteria for the base library. Move it there. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-12-01test: gstreamer: Avoid call to deprecated gst_element_get_request_pad()Xavier Roumegue
gst_element_get_request_pad() is being replaced by gst_element_request_simple() since 1.19.1, throwing a warning in case of use until its definitive replacement on 1.20. Hence, prefer using gst_element_request_simple() in case gstreamer version is >= 1.19.1 to avoid the compilation error below (tested on f35): [258/391] Compiling C++ object test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o FAILED: test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o c++ -Itest/gstreamer/multi_stream_test.p -Itest/gstreamer -I../test/gstreamer -Itest/libtest -I../test/libtest -Iinclude -I../include -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -g -Wshadow -include config.h -pthread -DLIBCAMERA_BASE_PRIVATE -MD -MQ test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o -MF test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o.d -o test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o -c ../test/gstreamer/gstreamer_multi_stream_test.cpp ../test/gstreamer/gstreamer_multi_stream_test.cpp: In member function ‘virtual int GstreamerMultiStreamTest::run()’: ../test/gstreamer/gstreamer_multi_stream_test.cpp:90:76: error: ‘GstPad* gst_element_get_request_pad(GstElement*, const gchar*)’ is deprecated: Use 'gst_element_request_pad_simple' instead [-Werror=deprecated-declarations] 90 | g_autoptr(GstPad) request_pad = gst_element_get_request_pad(libcameraSrc_, "src_%u"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/gstreamer-1.0/gst/gstbin.h:27, from /usr/include/gstreamer-1.0/gst/gst.h:35, from ../test/gstreamer/gstreamer_multi_stream_test.cpp:13: /usr/include/gstreamer-1.0/gst/gstelement.h:1042:25: note: declared here 1042 | GstPad* gst_element_get_request_pad (GstElement *element, const gchar *name); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors Signed-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com> Reviewed-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>
2021-12-01test: Replace "/proc/self/exe" with path to test binaryLaurent Pinchart
When tests are run under valgrind, /proc/self/exe points to valgrind, not to the test binary. This results in failures for tests that need to fork processes. Fix it by replacing "/proc/self/exe" with the path to the test binary. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-12-01test: Store path to the test executable in Test classLaurent Pinchart
Store the path to the test executable, found in argv[0], in the Test instance. This can be useful for tests that need to fork processes. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-11-29test: camera: Fix trivial spelling mistakeJacopo Mondi
The error message should be: "Failed to associate buffer with request" Fix that. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>