test: ipa: ipa_interface: Replace FIFO with pipe
The ipa_interface unit test uses a FIFO to communicate with the vimc IPA module. FIFOs are named pipes, created in the file system. The path to the FIFO is hardcoded so that both the unit test and IPA module know where to locate the file. If the ipa_interface crashes for any reason, the FIFO will not be removed, and subsequent usage of the vimc IPA module will hang when trying to write to the FIFO in the IPA module. Fix this by replacing the FIFO with a pipe. Pipes are unidirectional data channels that are represented by a pair of file descriptors, without any presence in the file system. The write end of the pipe is passed to the vimc IPA module init() function, and then used the same way as the FIFO. While at it, use a std::unique_ptr to manage the notifier in the unit test instead of manually allocating and deleting the object. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
This commit is contained in:
+7
-26
@@ -33,6 +33,7 @@ public:
|
||||
~IPAVimc();
|
||||
|
||||
int init(const IPASettings &settings,
|
||||
const SharedFD &traceFd,
|
||||
const ipa::vimc::IPAOperationCode code,
|
||||
const Flags<ipa::vimc::TestFlag> inFlags,
|
||||
Flags<ipa::vimc::TestFlag> *outFlags) override;
|
||||
@@ -51,30 +52,28 @@ public:
|
||||
void computeParams(uint32_t frame, uint32_t bufferId) override;
|
||||
|
||||
private:
|
||||
void initTrace();
|
||||
void trace(enum ipa::vimc::IPAOperationCode operation);
|
||||
|
||||
int fd_;
|
||||
SharedFD fd_;
|
||||
std::map<unsigned int, MappedFrameBuffer> buffers_;
|
||||
};
|
||||
|
||||
IPAVimc::IPAVimc()
|
||||
: fd_(-1)
|
||||
{
|
||||
initTrace();
|
||||
}
|
||||
|
||||
IPAVimc::~IPAVimc()
|
||||
{
|
||||
if (fd_ != -1)
|
||||
::close(fd_);
|
||||
}
|
||||
|
||||
int IPAVimc::init(const IPASettings &settings,
|
||||
const SharedFD &traceFd,
|
||||
const ipa::vimc::IPAOperationCode code,
|
||||
const Flags<ipa::vimc::TestFlag> inFlags,
|
||||
Flags<ipa::vimc::TestFlag> *outFlags)
|
||||
{
|
||||
fd_ = traceFd;
|
||||
|
||||
trace(ipa::vimc::IPAOperationInit);
|
||||
|
||||
LOG(IPAVimc, Debug)
|
||||
@@ -162,30 +161,12 @@ void IPAVimc::computeParams([[maybe_unused]] uint32_t frame, uint32_t bufferId)
|
||||
paramsComputed.emit(bufferId, flags);
|
||||
}
|
||||
|
||||
void IPAVimc::initTrace()
|
||||
{
|
||||
struct stat fifoStat;
|
||||
int ret = stat(ipa::vimc::VimcIPAFIFOPath.c_str(), &fifoStat);
|
||||
if (ret)
|
||||
return;
|
||||
|
||||
ret = ::open(ipa::vimc::VimcIPAFIFOPath.c_str(), O_WRONLY | O_CLOEXEC);
|
||||
if (ret < 0) {
|
||||
ret = errno;
|
||||
LOG(IPAVimc, Error) << "Failed to open vimc IPA test FIFO: "
|
||||
<< strerror(ret);
|
||||
return;
|
||||
}
|
||||
|
||||
fd_ = ret;
|
||||
}
|
||||
|
||||
void IPAVimc::trace(enum ipa::vimc::IPAOperationCode operation)
|
||||
{
|
||||
if (fd_ < 0)
|
||||
if (!fd_.isValid())
|
||||
return;
|
||||
|
||||
int ret = ::write(fd_, &operation, sizeof(operation));
|
||||
int ret = ::write(fd_.get(), &operation, sizeof(operation));
|
||||
if (ret < 0) {
|
||||
ret = errno;
|
||||
LOG(IPAVimc, Error) << "Failed to write to vimc IPA test FIFO: "
|
||||
|
||||
Reference in New Issue
Block a user