summaryrefslogtreecommitdiff
path: root/test/camera
diff options
context:
space:
mode:
Diffstat (limited to 'test/camera')
-rw-r--r--test/camera/buffer_import.cpp14
-rw-r--r--test/camera/camera_test.cpp48
-rw-r--r--test/camera/camera_test.h30
-rw-r--r--test/camera/capture.cpp15
-rw-r--r--test/camera/configuration_default.cpp16
-rw-r--r--test/camera/configuration_set.cpp15
-rw-r--r--test/camera/meson.build2
-rw-r--r--test/camera/statemachine.cpp15
8 files changed, 51 insertions, 104 deletions
diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp
index bbc5a25c..3efe0270 100644
--- a/test/camera/buffer_import.cpp
+++ b/test/camera/buffer_import.cpp
@@ -18,6 +18,7 @@
#include "v4l2_videodevice.h"
#include "camera_test.h"
+#include "test.h"
using namespace libcamera;
@@ -254,11 +255,11 @@ private:
bool done_;
};
-class BufferImportTest : public CameraTest
+class BufferImportTest : public CameraTest, public Test
{
public:
BufferImportTest()
- : CameraTest()
+ : CameraTest("VIMC Sensor B")
{
}
@@ -350,11 +351,10 @@ protected:
int init()
{
- int ret = CameraTest::init();
- if (ret)
- return ret;
+ if (status_ != TestPass)
+ return status_;
- ret = sink_.init();
+ int ret = sink_.init();
if (ret != TestPass) {
cleanup();
return ret;
@@ -422,8 +422,6 @@ protected:
camera_->stop();
camera_->freeBuffers();
-
- CameraTest::cleanup();
}
private:
diff --git a/test/camera/camera_test.cpp b/test/camera/camera_test.cpp
deleted file mode 100644
index 101e31fb..00000000
--- a/test/camera/camera_test.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2019, Google Inc.
- *
- * libcamera Camera API tests
- */
-
-#include <iostream>
-
-#include "camera_test.h"
-
-using namespace libcamera;
-using namespace std;
-
-int CameraTest::init()
-{
- cm_ = new CameraManager();
-
- if (cm_->start()) {
- cout << "Failed to start camera manager" << endl;
- return TestFail;
- }
-
- camera_ = cm_->get("VIMC Sensor B");
- if (!camera_) {
- cout << "Can not find VIMC camera" << endl;
- return TestSkip;
- }
-
- /* Sanity check that the camera has streams. */
- if (camera_->streams().empty()) {
- cout << "Camera has no stream" << endl;
- return TestFail;
- }
-
- return TestPass;
-}
-
-void CameraTest::cleanup()
-{
- if (camera_) {
- camera_->release();
- camera_.reset();
- }
-
- cm_->stop();
- delete cm_;
-}
diff --git a/test/camera/camera_test.h b/test/camera/camera_test.h
deleted file mode 100644
index e57b05eb..00000000
--- a/test/camera/camera_test.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2019, Google Inc.
- *
- * camera_test.h - libcamera camera test base class
- */
-#ifndef __LIBCAMERA_CAMERA_TEST_H__
-#define __LIBCAMERA_CAMERA_TEST_H__
-
-#include <libcamera/libcamera.h>
-
-#include "test.h"
-
-using namespace libcamera;
-
-class CameraTest : public Test
-{
-public:
- CameraTest()
- : cm_(nullptr) {}
-
-protected:
- int init();
- void cleanup();
-
- CameraManager *cm_;
- std::shared_ptr<Camera> camera_;
-};
-
-#endif /* __LIBCAMERA_CAMERA_TEST_H__ */
diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp
index 83f97474..7cb76038 100644
--- a/test/camera/capture.cpp
+++ b/test/camera/capture.cpp
@@ -8,13 +8,20 @@
#include <iostream>
#include "camera_test.h"
+#include "test.h"
using namespace std;
namespace {
-class Capture : public CameraTest
+class Capture : public CameraTest, public Test
{
+public:
+ Capture()
+ : CameraTest("VIMC Sensor B")
+ {
+ }
+
protected:
unsigned int completeBuffersCount_;
unsigned int completeRequestsCount_;
@@ -48,14 +55,12 @@ protected:
int init() override
{
- int ret = CameraTest::init();
- if (ret)
- return ret;
+ if (status_ != TestPass)
+ return status_;
config_ = camera_->generateConfiguration({ StreamRole::VideoRecording });
if (!config_ || config_->size() != 1) {
cout << "Failed to generate default configuration" << endl;
- CameraTest::cleanup();
return TestFail;
}
diff --git a/test/camera/configuration_default.cpp b/test/camera/configuration_default.cpp
index ce2ec5d0..31c908d2 100644
--- a/test/camera/configuration_default.cpp
+++ b/test/camera/configuration_default.cpp
@@ -8,15 +8,27 @@
#include <iostream>
#include "camera_test.h"
+#include "test.h"
using namespace std;
namespace {
-class ConfigurationDefault : public CameraTest
+class ConfigurationDefault : public CameraTest, public Test
{
+public:
+ ConfigurationDefault()
+ : CameraTest("VIMC Sensor B")
+ {
+ }
+
protected:
- int run()
+ int init() override
+ {
+ return status_;
+ }
+
+ int run() override
{
std::unique_ptr<CameraConfiguration> config;
diff --git a/test/camera/configuration_set.cpp b/test/camera/configuration_set.cpp
index f88da96c..b4b59681 100644
--- a/test/camera/configuration_set.cpp
+++ b/test/camera/configuration_set.cpp
@@ -8,24 +8,29 @@
#include <iostream>
#include "camera_test.h"
+#include "test.h"
using namespace std;
namespace {
-class ConfigurationSet : public CameraTest
+class ConfigurationSet : public CameraTest, public Test
{
+public:
+ ConfigurationSet()
+ : CameraTest("VIMC Sensor B")
+ {
+ }
+
protected:
int init() override
{
- int ret = CameraTest::init();
- if (ret)
- return ret;
+ if (status_ != TestPass)
+ return status_;
config_ = camera_->generateConfiguration({ StreamRole::VideoRecording });
if (!config_ || config_->size() != 1) {
cout << "Failed to generate default configuration" << endl;
- CameraTest::cleanup();
return TestFail;
}
diff --git a/test/camera/meson.build b/test/camera/meson.build
index d6fd66b8..e2a6660a 100644
--- a/test/camera/meson.build
+++ b/test/camera/meson.build
@@ -9,7 +9,7 @@ camera_tests = [
]
foreach t : camera_tests
- exe = executable(t[0], [t[1], 'camera_test.cpp'],
+ exe = executable(t[0], t[1],
dependencies : libcamera_dep,
link_with : test_libraries,
include_directories : test_includes_internal)
diff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp
index 12d5e0e1..afa13ba7 100644
--- a/test/camera/statemachine.cpp
+++ b/test/camera/statemachine.cpp
@@ -8,13 +8,20 @@
#include <iostream>
#include "camera_test.h"
+#include "test.h"
using namespace std;
namespace {
-class Statemachine : public CameraTest
+class Statemachine : public CameraTest, public Test
{
+public:
+ Statemachine()
+ : CameraTest("VIMC Sensor B")
+ {
+ }
+
protected:
int testAvailable()
{
@@ -233,14 +240,12 @@ protected:
int init() override
{
- int ret = CameraTest::init();
- if (ret)
- return ret;
+ if (status_ != TestPass)
+ return status_;
defconf_ = camera_->generateConfiguration({ StreamRole::VideoRecording });
if (!defconf_) {
cout << "Failed to generate default configuration" << endl;
- CameraTest::cleanup();
return TestFail;
}