`O_TMPFILE` requires file system support, which may not be available in certain environments, usually containerized ones. So do not use it. A new function is added for tests to be able to create unnamed temporary files using `libcamera::MemFd` as the implementation. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
54 lines
826 B
C++
54 lines
826 B
C++
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Copyright (C) 2018, Google Inc.
|
|
*
|
|
* libcamera test base class
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
#include <libcamera/base/unique_fd.h>
|
|
|
|
enum TestStatus {
|
|
TestPass = 0,
|
|
TestFail = -1,
|
|
TestSkip = 77,
|
|
};
|
|
|
|
class Test
|
|
{
|
|
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) \
|
|
int main(int argc, char *argv[]) \
|
|
{ \
|
|
Klass klass; \
|
|
klass.setArgs(argc, argv); \
|
|
return klass.execute(); \
|
|
}
|
|
|
|
namespace test {
|
|
|
|
[[nodiscard]] libcamera::UniqueFD createTemporaryFile();
|
|
|
|
}
|