summaryrefslogtreecommitdiff
path: root/test/timer-thread.cpp
AgeCommit message (Collapse)Author
2020-08-25meson: Remove -Wno-unused-parameterLaurent Pinchart
We build libcamera with -Wno-unused-parameter and this doesn't cause much issue internally. However, it prevents catching unused parameters in inline functions defined in public headers. This can lead to compilation warnings for applications compiled without -Wno-unused-parameter. To catch those issues, remove -Wno-unused-parameter and fix all the related warnings with [[maybe_unused]]. 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>
2020-05-16libcamera: Move internal headers to include/libcamera/internal/Laurent Pinchart
The libcamera internal headers are located in src/libcamera/include/. The directory is added to the compiler headers search path with a meson include_directories() directive, and internal headers are included with (e.g. for the internal semaphore.h header) #include "semaphore.h" All was well, until libcxx decided to implement the C++20 synchronization library. The __threading_support header gained a #include <semaphore.h> to include the pthread's semaphore support. As include_directories() adds src/libcamera/include/ to the compiler search path with -I, the internal semaphore.h is included instead of the pthread version. Needless to say, the compiler isn't happy. Three options have been considered to fix this issue: - Use -iquote instead of -I. The -iquote option instructs gcc to only consider the header search path for headers included with the "" version. Meson unfortunately doesn't support this option. - Rename the internal semaphore.h header. This was deemed to be the beginning of a long whack-a-mole game, where namespace clashes with system libraries would appear over time (possibly dependent on particular system configurations) and would need to be constantly fixed. - Move the internal headers to another directory to create a unique namespace through path components. This causes lots of churn in all the existing source files through the all project. The first option would be best, but isn't available to us due to missing support in meson. Even if -iquote support was added, we would need to fix the problem before a new version of meson containing the required support would be released. The third option is thus the only practical solution available. Bite the bullet, and do it, moving headers to include/libcamera/internal/. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org>
2019-10-07test: timer-thread: Test starting a timer from another threadLaurent Pinchart
Timers can't be started from another thread. Ensure that attempting to do so fails. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-08-17test: Simplify tests with parent-child relationshipsLaurent Pinchart
Create object instances with a parent to avoid the need for reparenting objects manually. 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-17test: Add Timer thread move testLaurent Pinchart
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>
ss="hl ppc"> #include "media_device.h" #include "media_object.h" #include "test.h" using namespace std; using namespace libcamera; /* * Verify that the Intel IPU3 pipeline handler gets matched and cameras * are enumerated correctly. * * The test is supposed to be run on an IPU3 platform, otherwise it gets * skipped. * * The test lists all cameras registered in the system, if any camera is * available at all. */ class IPU3PipelineTest : public Test { protected: int init(); int run(); void cleanup(); private: CameraManager *cameraManager_; unsigned int sensors_; }; int IPU3PipelineTest::init() { unique_ptr<DeviceEnumerator> enumerator = DeviceEnumerator::create(); if (!enumerator) { cerr << "Failed to create device enumerator" << endl; return TestFail; } if (enumerator->enumerate()) { cerr << "Failed to enumerate media devices" << endl; return TestFail; } DeviceMatch imgu_dm("ipu3-imgu"); DeviceMatch cio2_dm("ipu3-cio2"); if (!enumerator->search(imgu_dm)) { cerr << "Failed to find IPU3 IMGU: test skip" << endl; return TestSkip; } std::shared_ptr<MediaDevice> cio2 = enumerator->search(cio2_dm); if (!cio2) { cerr << "Failed to find IPU3 CIO2: test skip" << endl; return TestSkip; } /* * Camera sensor are connected to the CIO2 unit. * Count how many sensors are connected in the system * and later verify this matches the number of registered * cameras. */ int ret = cio2->populate(); if (ret) { cerr << "Failed to populate media device " << cio2->deviceNode() << endl; return TestFail; } sensors_ = 0; const vector<MediaEntity *> &entities = cio2->entities(); for (MediaEntity *entity : entities) { if (entity->function() == MEDIA_ENT_F_CAM_SENSOR) sensors_++; } enumerator.reset(nullptr); cameraManager_ = new CameraManager(); ret = cameraManager_->start(); if (ret) { cerr << "Failed to start the CameraManager" << endl; return TestFail; } return 0; } int IPU3PipelineTest::run() { auto cameras = cameraManager_->cameras(); for (const std::shared_ptr<Camera> &cam : cameras) cout << "Found camera '" << cam->name() << "'" << endl; if (cameras.size() != sensors_) { cerr << cameras.size() << " cameras registered, but " << sensors_ << " were expected" << endl; return TestFail; } return TestPass; } void IPU3PipelineTest::cleanup() { cameraManager_->stop(); delete cameraManager_; } TEST_REGISTER(IPU3PipelineTest)