summaryrefslogtreecommitdiff
path: root/test/gstreamer
AgeCommit message (Collapse)Author
3 dayslibcamera: Drop remaining file name from header comment blocksHEADmasterLaurent Pinchart
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>
4 dayslibcamera: Drop file name from header comment blocksLaurent Pinchart
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-01-23test: gstreamer: Use env instead of registry editNicolas Dufresne
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>
2023-12-07test: gstreamer: Remove videoconvert element from pipelineLaurent Pinchart
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-06test: gstreamer: Fix indentation in commentsLaurent Pinchart
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-07-11tests: gstreamer: Fix compiler error with gcc 8.4.0Laurent Pinchart
The provider g_autoptr variable introduced by commit adb1bbb748a1 ("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: adb1bbb748a1 ("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-07meson: Fix space around colon issuesLaurent Pinchart
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-06tests: gstreamer: Test cameras' enumeration from GstDeviceProviderUmang Jain
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>
2022-10-07test: meson: Use dictionaries instead of arrays to store test informationLaurent Pinchart
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-07test: Rename 't' to 'test' in meson.buildLaurent Pinchart
The 't' name is very short and not very explicit. Rename it to 'test' instead. 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-09-12test: gstreamer: gstreamer_test: Remove redundant wordRishikesh Donadkar
Remove redundant "create" in the error message. Signed-off-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com> Reviewed-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
2022-09-12test: gstreamer: Fix failure of gstreamer_multistream_testVedant Paranjape
Multistream test failed with the following logs, to run on Raspberry Pi 4 due to a bug introduced in one of the recent patches refactoring the code that fails to set the camera-name property with a valid camera id string. WARN libcamerasrc gstlibcamerasrc.cpp:347:gst_libcamera_src_open:<libcamera> error: Could not find a camera named ''. WARN libcamerasrc gstlibcamerasrc.cpp:347:gst_libcamera_src_open:<libcamera> error: libcamera::CameraMananger::get() returned nullptr This patch assigns the camera->id() to the variable cameraName_ that is later used to set element property "camera-name" needed to call the specific camera which supports multistreams. Move the code to set element property "camera-name" to base class GstreamerTest. Fixes: 5646849b59fe ("test: gstreamer: Check availability of cameras before running") Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Tested-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com> Reviewed-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
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>
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-11-24test: Convert to pragma onceKieran Bingham
Remove the verbose #ifndef/#define/#endif pattern for maintaining header idempotency, and replace it with a simple #pragma once. This simplifies the headers, and prevents redundant changes when header files get moved. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
2021-10-15test: Remove using namespace in header filesHirokazu Honda
"using namespace" in a header file propagates the namespace to the files including the header file. So it should be avoided. This removes "using namespace" in header files in test. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-10-04test: gstreamer: Remove unnecessary header file includesVedant Paranjape
Remove header files which were not being used in the test code. The following headers were removed from the gstreamer_single_stream_test: - libcamera/base/utils.h - libcamera/internal/source_paths.h Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
2021-09-24test: gstreamer: Add a test for gstreamer multi streamVedant Paranjape
This patch adds a test to test if multi stream using libcamera's gstreamer element works. Test will run only on devices that support multistream capture, eg., devices that use IPU3 and raspberrypi pipeline. This was tested on a Raspberry Pi 4B+. Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-23test: gstreamer: Simplify elements' ownershipsVedant Paranjape
In gstreamer, when elements are created, usually a floating [1] reference is returned which simply means, there is no ownership transfer (yet). Once can simply check for NULL and return through an error path, without bothering to clean up. Hence, g_autoptr is not much of help here. If the NULL checks have been passed successfully, elements are ready to use. However, we must claim ownership/reference it before using them via g_object_ref_sink(). This patch build upon this principle and removes the g_autoptr from gstreamer test base class (gstreamer_test.cpp) whereever necessary to tide up the code. [1] https://gstreamer.freedesktop.org/documentation/additional/design/MT-refcounting.html?gi-language=c#refcounting1 Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-23test: gstreamer: Simplify single stream test using functions from GstUtilsVedant Paranjape
Simplify memory handling and complexity of the test by using gst_parse_bin_from_description_full [1]. [1]: https://gstreamer.freedesktop.org/documentation/gstreamer/gstutils.html?gi-language=c#gst_parse_bin_from_description_full Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-23test: gstreamer_single_stream_test: Fix memory leakVedant Paranjape
The test hold a valid reference to convert0_ and sink0_ but not released. This results in a memory leak and can be checked via valgrind. Drop the references with test cleanup() virtual function. Valgrind log (glib and gst suppression files were used): ==345380== LEAK SUMMARY: ==345380== definitely lost: 1,688 bytes in 2 blocks ==345380== indirectly lost: 7,069 bytes in 42 blocks The patch fixes the leaks reported by valgrind above to: ==348870== LEAK SUMMARY: ==348870== definitely lost: 0 bytes in 0 blocks ==348870== indirectly lost: 0 bytes in 0 blocks Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-09test: gstreamer: Fix the destructor of GstreamerTest base classVedant Paranjape
The destructor tried to check if pipeline_ is a parent of libcameraSrc_. This was needed to be checked as if it is, cleanup of libcameraSrc_ would be handled by pipeline itself. Since, the destructor can be called anytime, even when pipeline_ hasn't been created, the use of pipeline_ to check if libcameraSrc_ has an ancestor as pipeline_ caused a segmentation fault. Fixes: f58768092277 ("test: gstreamer: Fix the destructor of GstreamerTest base class") Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-09-08test: gstreamer: Factor out code into a base classVedant Paranjape
A lot of code used in the single stream test is boiler plate and common across every gstreamer test. Factor out this code into a base class called GstreamerTest. Also update the gstreamer_single_stream_test to use the GstreamerTest base class. Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2021-08-26test: gstreamer: Disable gstreamer registry forksVedant Paranjape
ASan needs to be loaded first before gstreamer is loaded. This was not possible, so verify_asan_link_order was disabled. Better way to tackle this issue was disabling forks on the gstreamer side. verify_asan_link_order=0 disables the check on ASan side which checks if ASan was loaded before any other shared objects. Since, gstreamer spawns a child helper process while building the registry, we needed to disable this check. But with gst_registry_fork_set_enabled() it is possible to disable spawning this child helper process, so this ensures that ASan is loaded before any other shared object is loaded. Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-26test: gstreamer: Clean up memory managementVedant Paranjape
This patch simplifies memory management, i.e., by replacing bare pointers with g_autoptr or g_autofree according to use case. While at it also update time representation of timeout variable with GST_SECOND. Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-08-14test: gstreamer: Add test for gstreamer single streamVedant Paranjape
This patch adds a test to test if single stream using libcamera's gstreamer element works. We need to work around two distinct issues with ASan when enabled in the build: - glib has a known leak at initialization time. This is covered by the suppression file shipped with glib, but it's not clear how to use it automatically. For now, disable leak detection to avoid test failures. - GStreamer spawns a child process to scan plugins. If GStreamer is compiled without ASan (which is likely) but libcamera is, dlopen()ing the libcamera plugin will cause an ASan link order verification failure. Disable the verification child processes to work around the problem. This requires gcc 8 or newer. Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>