diff options
Diffstat (limited to 'test/libtest')
-rw-r--r-- | test/libtest/buffer_source.cpp | 9 | ||||
-rw-r--r-- | test/libtest/buffer_source.h | 22 | ||||
-rw-r--r-- | test/libtest/camera_test.cpp | 5 | ||||
-rw-r--r-- | test/libtest/camera_test.h | 19 | ||||
-rw-r--r-- | test/libtest/meson.build | 5 | ||||
-rw-r--r-- | test/libtest/test.cpp | 7 | ||||
-rw-r--r-- | test/libtest/test.h | 21 |
7 files changed, 50 insertions, 38 deletions
diff --git a/test/libtest/buffer_source.cpp b/test/libtest/buffer_source.cpp index dae3cb9f..dde11f36 100644 --- a/test/libtest/buffer_source.cpp +++ b/test/libtest/buffer_source.cpp @@ -10,10 +10,12 @@ #include <iostream> #include <memory> -#include "device_enumerator.h" +#include "libcamera/internal/device_enumerator.h" #include "test.h" +using namespace libcamera; + BufferSource::BufferSource() { } @@ -50,7 +52,7 @@ int BufferSource::allocate(const StreamConfiguration &config) return TestSkip; } - std::unique_ptr<V4L2VideoDevice> video{ V4L2VideoDevice::fromEntityName(media_.get(), videoDeviceName) }; + std::unique_ptr<V4L2VideoDevice> video = V4L2VideoDevice::fromEntityName(media_.get(), videoDeviceName); if (!video) { std::cout << "Failed to get video device from entity " << videoDeviceName << std::endl; @@ -70,8 +72,7 @@ int BufferSource::allocate(const StreamConfiguration &config) } format.size = config.size; - format.fourcc = V4L2VideoDevice::toV4L2PixelFormat(config.pixelFormat, - false); + format.fourcc = video->toV4L2PixelFormat(config.pixelFormat); if (video->setFormat(&format)) { std::cout << "Failed to set format on output device" << std::endl; return TestFail; diff --git a/test/libtest/buffer_source.h b/test/libtest/buffer_source.h index ae0879c9..495da8a9 100644 --- a/test/libtest/buffer_source.h +++ b/test/libtest/buffer_source.h @@ -2,17 +2,15 @@ /* * Copyright (C) 2020, Google Inc. * - * buffer_source.h - libcamera camera test helper to create FrameBuffers + * libcamera camera test helper to create FrameBuffers */ -#ifndef __LIBCAMERA_BUFFER_SOURCE_TEST_H__ -#define __LIBCAMERA_BUFFER_SOURCE_TEST_H__ -#include <libcamera/libcamera.h> +#pragma once -#include "media_device.h" -#include "v4l2_videodevice.h" +#include <libcamera/stream.h> -using namespace libcamera; +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/v4l2_videodevice.h" class BufferSource { @@ -20,12 +18,10 @@ public: BufferSource(); ~BufferSource(); - int allocate(const StreamConfiguration &config); - const std::vector<std::unique_ptr<FrameBuffer>> &buffers(); + int allocate(const libcamera::StreamConfiguration &config); + const std::vector<std::unique_ptr<libcamera::FrameBuffer>> &buffers(); private: - std::shared_ptr<MediaDevice> media_; - std::vector<std::unique_ptr<FrameBuffer>> buffers_; + std::shared_ptr<libcamera::MediaDevice> media_; + std::vector<std::unique_ptr<libcamera::FrameBuffer>> buffers_; }; - -#endif /* __LIBCAMERA_BUFFER_SOURCE_TEST_H__ */ diff --git a/test/libtest/camera_test.cpp b/test/libtest/camera_test.cpp index 2ae4d677..fe13d6ac 100644 --- a/test/libtest/camera_test.cpp +++ b/test/libtest/camera_test.cpp @@ -13,10 +13,13 @@ using namespace libcamera; using namespace std; -CameraTest::CameraTest(const char *name) +CameraTest::CameraTest(const char *name, bool isolate) { cm_ = new CameraManager(); + if (isolate) + setenv("LIBCAMERA_IPA_FORCE_ISOLATION", "1", 1); + if (cm_->start()) { cerr << "Failed to start camera manager" << endl; status_ = TestFail; diff --git a/test/libtest/camera_test.h b/test/libtest/camera_test.h index 0b6bad05..713b503f 100644 --- a/test/libtest/camera_test.h +++ b/test/libtest/camera_test.h @@ -2,25 +2,24 @@ /* * Copyright (C) 2019, Google Inc. * - * camera_test.h - libcamera camera test base class + * libcamera camera test base class */ -#ifndef __LIBCAMERA_CAMERA_TEST_H__ -#define __LIBCAMERA_CAMERA_TEST_H__ -#include <libcamera/libcamera.h> +#pragma once -using namespace libcamera; +#include <memory> + +#include <libcamera/camera.h> +#include <libcamera/camera_manager.h> class CameraTest { public: - CameraTest(const char *name); + CameraTest(const char *name, bool isolate = false); ~CameraTest(); protected: - CameraManager *cm_; - std::shared_ptr<Camera> camera_; + libcamera::CameraManager *cm_; + std::shared_ptr<libcamera::Camera> camera_; int status_; }; - -#endif /* __LIBCAMERA_CAMERA_TEST_H__ */ diff --git a/test/libtest/meson.build b/test/libtest/meson.build index 33565e0e..351629f3 100644 --- a/test/libtest/meson.build +++ b/test/libtest/meson.build @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: CC0-1.0 + libtest_sources = files([ 'buffer_source.cpp', 'camera_test.cpp', @@ -13,11 +15,10 @@ test_includes_public = [ test_includes_internal = [ test_includes_public, - libcamera_internal_includes, ] libtest = static_library('libtest', libtest_sources, - dependencies : libcamera_dep, + dependencies : libcamera_private, include_directories : test_includes_internal) test_libraries = [libtest] diff --git a/test/libtest/test.cpp b/test/libtest/test.cpp index fd9f3d74..4e03def9 100644 --- a/test/libtest/test.cpp +++ b/test/libtest/test.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2018, Google Inc. * - * test.cpp - libcamera test base class + * libcamera test base class */ #include <stdlib.h> @@ -17,6 +17,11 @@ Test::~Test() { } +void Test::setArgs([[maybe_unused]] int argc, char *argv[]) +{ + self_ = argv[0]; +} + int Test::execute() { int ret; diff --git a/test/libtest/test.h b/test/libtest/test.h index 26d4b94b..3a90885d 100644 --- a/test/libtest/test.h +++ b/test/libtest/test.h @@ -2,12 +2,13 @@ /* * Copyright (C) 2018, Google Inc. * - * test.h - libcamera test base class + * libcamera test base class */ -#ifndef __TEST_TEST_H__ -#define __TEST_TEST_H__ + +#pragma once #include <sstream> +#include <string> enum TestStatus { TestPass = 0, @@ -21,18 +22,24 @@ public: Test(); virtual ~Test(); + void setArgs(int argc, char *argv[]); int execute(); + const std::string &self() const { return self_; } + protected: virtual int init() { return 0; } virtual int run() = 0; virtual void cleanup() {} + +private: + std::string self_; }; -#define TEST_REGISTER(klass) \ +#define TEST_REGISTER(Klass) \ int main(int argc, char *argv[]) \ { \ - return klass().execute(); \ + Klass klass; \ + klass.setArgs(argc, argv); \ + return klass.execute(); \ } - -#endif /* __TEST_TEST_H__ */ |