summaryrefslogtreecommitdiff
path: root/test/ipa/ipa_interface_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/ipa/ipa_interface_test.cpp')
-rw-r--r--test/ipa/ipa_interface_test.cpp109
1 files changed, 75 insertions, 34 deletions
diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp
index cafc249b..b8178366 100644
--- a/test/ipa/ipa_interface_test.cpp
+++ b/test/ipa/ipa_interface_test.cpp
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * ipa_interface_test.cpp - Test the IPA interface
+ * Test the IPA interface
*/
#include <fcntl.h>
@@ -12,44 +12,52 @@
#include <sys/types.h>
#include <unistd.h>
-#include <libcamera/event_dispatcher.h>
-#include <libcamera/event_notifier.h>
-#include <libcamera/timer.h>
+#include <libcamera/ipa/vimc_ipa_proxy.h>
-#include <ipa/ipa_vimc.h>
+#include <libcamera/base/event_dispatcher.h>
+#include <libcamera/base/event_notifier.h>
+#include <libcamera/base/object.h>
+#include <libcamera/base/thread.h>
+#include <libcamera/base/timer.h>
+
+#include "libcamera/internal/camera_manager.h"
+#include "libcamera/internal/device_enumerator.h"
+#include "libcamera/internal/ipa_manager.h"
+#include "libcamera/internal/ipa_module.h"
+#include "libcamera/internal/pipeline_handler.h"
-#include "device_enumerator.h"
-#include "ipa_manager.h"
-#include "ipa_module.h"
-#include "pipeline_handler.h"
#include "test.h"
-#include "thread.h"
-using namespace std;
using namespace libcamera;
+using namespace std;
+using namespace std::chrono_literals;
class IPAInterfaceTest : public Test, public Object
{
public:
IPAInterfaceTest()
- : trace_(IPAOperationNone), notifier_(nullptr), fd_(-1)
+ : trace_(ipa::vimc::IPAOperationNone), notifier_(nullptr), fd_(-1)
{
}
~IPAInterfaceTest()
{
delete notifier_;
+ ipa_.reset();
+ cameraManager_.reset();
}
protected:
int init() override
{
+ cameraManager_ = make_unique<CameraManager>();
+
/* Create a pipeline handler for vimc. */
- std::vector<PipelineHandlerFactory *> &factories =
- PipelineHandlerFactory::factories();
- for (PipelineHandlerFactory *factory : factories) {
- if (factory->name() == "PipelineHandlerVimc") {
- pipe_ = factory->create(nullptr);
+ const std::vector<PipelineHandlerFactoryBase *> &factories =
+ PipelineHandlerFactoryBase::factories();
+ for (const PipelineHandlerFactoryBase *factory : factories) {
+ if (factory->name() == "vimc") {
+ pipe_ = factory->create(cameraManager_.get());
break;
}
}
@@ -60,22 +68,22 @@ protected:
}
/* Create and open the communication FIFO. */
- int ret = mkfifo(VIMC_IPA_FIFO_PATH, S_IRUSR | S_IWUSR);
+ int ret = mkfifo(ipa::vimc::VimcIPAFIFOPath.c_str(), S_IRUSR | S_IWUSR);
if (ret) {
ret = errno;
cerr << "Failed to create IPA test FIFO at '"
- << VIMC_IPA_FIFO_PATH << "': " << strerror(ret)
+ << ipa::vimc::VimcIPAFIFOPath << "': " << strerror(ret)
<< endl;
return TestFail;
}
- ret = open(VIMC_IPA_FIFO_PATH, O_RDONLY | O_NONBLOCK);
+ ret = open(ipa::vimc::VimcIPAFIFOPath.c_str(), O_RDONLY | O_NONBLOCK);
if (ret < 0) {
ret = errno;
cerr << "Failed to open IPA test FIFO at '"
- << VIMC_IPA_FIFO_PATH << "': " << strerror(ret)
+ << ipa::vimc::VimcIPAFIFOPath << "': " << strerror(ret)
<< endl;
- unlink(VIMC_IPA_FIFO_PATH);
+ unlink(ipa::vimc::VimcIPAFIFOPath.c_str());
return TestFail;
}
fd_ = ret;
@@ -91,49 +99,82 @@ protected:
EventDispatcher *dispatcher = thread()->eventDispatcher();
Timer timer;
- ipa_ = IPAManager::instance()->createIPA(pipe_.get(), 0, 0);
+ ipa_ = IPAManager::createIPA<ipa::vimc::IPAProxyVimc>(pipe_.get(), 0, 0);
if (!ipa_) {
cerr << "Failed to create VIMC IPA interface" << endl;
return TestFail;
}
/* Test initialization of IPA module. */
- ipa_->init();
- timer.start(1000);
- while (timer.isRunning() && trace_ != IPAOperationInit)
+ std::string conf = ipa_->configurationFile("vimc.conf");
+ Flags<ipa::vimc::TestFlag> inFlags;
+ Flags<ipa::vimc::TestFlag> outFlags;
+ int ret = ipa_->init(IPASettings{ conf, "vimc" },
+ ipa::vimc::IPAOperationInit,
+ inFlags, &outFlags);
+ if (ret < 0) {
+ cerr << "IPA interface init() failed" << endl;
+ return TestFail;
+ }
+
+ timer.start(1000ms);
+ while (timer.isRunning() && trace_ != ipa::vimc::IPAOperationInit)
dispatcher->processEvents();
- if (trace_ != IPAOperationInit) {
+ if (trace_ != ipa::vimc::IPAOperationInit) {
cerr << "Failed to test IPA initialization sequence"
<< endl;
return TestFail;
}
+ /* Test start of IPA module. */
+ ipa_->start();
+ timer.start(1000ms);
+ while (timer.isRunning() && trace_ != ipa::vimc::IPAOperationStart)
+ dispatcher->processEvents();
+
+ if (trace_ != ipa::vimc::IPAOperationStart) {
+ cerr << "Failed to test IPA start sequence" << endl;
+ return TestFail;
+ }
+
+ /* Test stop of IPA module. */
+ ipa_->stop();
+ timer.start(1000ms);
+ while (timer.isRunning() && trace_ != ipa::vimc::IPAOperationStop)
+ dispatcher->processEvents();
+
+ if (trace_ != ipa::vimc::IPAOperationStop) {
+ cerr << "Failed to test IPA stop sequence" << endl;
+ return TestFail;
+ }
+
return TestPass;
}
void cleanup() override
{
close(fd_);
- unlink(VIMC_IPA_FIFO_PATH);
+ unlink(ipa::vimc::VimcIPAFIFOPath.c_str());
}
private:
- void readTrace(EventNotifier *notifier)
+ void readTrace()
{
- ssize_t s = read(notifier->fd(), &trace_, sizeof(trace_));
+ ssize_t s = read(notifier_->fd(), &trace_, sizeof(trace_));
if (s < 0) {
int ret = errno;
cerr << "Failed to read from IPA test FIFO at '"
- << VIMC_IPA_FIFO_PATH << "': " << strerror(ret)
+ << ipa::vimc::VimcIPAFIFOPath << "': " << strerror(ret)
<< endl;
- trace_ = IPAOperationNone;
+ trace_ = ipa::vimc::IPAOperationNone;
}
}
std::shared_ptr<PipelineHandler> pipe_;
- std::unique_ptr<IPAInterface> ipa_;
- enum IPAOperationCode trace_;
+ std::unique_ptr<ipa::vimc::IPAProxyVimc> ipa_;
+ std::unique_ptr<CameraManager> cameraManager_;
+ enum ipa::vimc::IPAOperationCode trace_;
EventNotifier *notifier_;
int fd_;
};