libcamera/test/libtest/test.h
Laurent Pinchart b24d9c4413 test: Store path to the test executable in Test class
Store the path to the test executable, found in argv[0], in the Test
instance. This can be useful for tests that need to fork processes.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-12-01 08:54:12 +02:00

45 lines
717 B
C++

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (C) 2018, Google Inc.
*
* test.h - libcamera test base class
*/
#pragma once
#include <sstream>
#include <string>
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(); \
}