From patchwork Wed Dec 19 09:48:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 61 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7964060B1F for ; Wed, 19 Dec 2018 10:47:40 +0100 (CET) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 003F8549 for ; Wed, 19 Dec 2018 10:47:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1545212860; bh=znrcJG14A0XJiFjXlz1qm6QHVnkIhvUTbF5gaFFo84o=; h=From:To:Subject:Date:From; b=mYVZPtUiVtqh4OVxar0UhbDZOqYD1EqvKG7XL7Pba0FS33Lyq/o2N4NKUww3UpPeJ vCUmZ6M1Nrba8RmbAdGC+YkPGQ7PtEFJYjHYtxENbW+KuSXXSYJUlT9HFZI7QOqioo wPcZTB1xzlivFvLXt/h2kw72X4qg4f3PYw9SD+PI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 19 Dec 2018 11:48:30 +0200 Message-Id: <20181219094830.7226-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] tests: Add a base Test class X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Dec 2018 09:47:40 -0000 The base Test class is meant to provide infrastructure common to all tests. It is very limited for now, and should be extended with at least logging and assertion handling. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- test/meson.build | 6 ++++++ test/test.cpp | 28 ++++++++++++++++++++++++++++ test/test.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 test/test.cpp create mode 100644 test/test.h diff --git a/test/meson.build b/test/meson.build index 24d1927f977c..fc9c124927d2 100644 --- a/test/meson.build +++ b/test/meson.build @@ -1,3 +1,9 @@ +libtest_sources = files([ + 'test.cpp', +]) + +libtest = static_library('libtest', libtest_sources) + test_init = executable('test_init', 'init.cpp', link_with : libcamera, include_directories : libcamera_includes) diff --git a/test/test.cpp b/test/test.cpp new file mode 100644 index 000000000000..4e7779e750d5 --- /dev/null +++ b/test/test.cpp @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2018, Google Inc. + * + * test.cpp - libcamera test base class + */ + +#include "test.h" + +Test::Test() +{ +} + +Test::~Test() +{ + cleanup(); +} + +int Test::execute() +{ + int ret; + + ret = init(); + if (ret < 0) + return ret; + + return run(); +} diff --git a/test/test.h b/test/test.h new file mode 100644 index 000000000000..2464fc5cb607 --- /dev/null +++ b/test/test.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2018, Google Inc. + * + * test.h - libcamera test base class + */ + +#include + +class Test +{ +public: + Test(); + virtual ~Test(); + + int execute(); + +protected: + virtual int init() { return 0; } + virtual int run() = 0; + virtual void cleanup() { } +}; + +#define TEST_REGISTER(klass) \ +int main(int argc, char *argv[]) \ +{ \ + return klass().execute(); \ +}