Patch Detail
Show a patch.
GET /api/1.1/patches/2297/?format=api
{ "id": 2297, "url": "https://patchwork.libcamera.org/api/1.1/patches/2297/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2297/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20191108205409.18845-2-laurent.pinchart@ideasonboard.com>", "date": "2019-11-08T20:53:46", "name": "[libcamera-devel,v2,01/24] test: Extract CameraTest class out of camera tests to libtest", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "a77eca97953ac68b3ffc49df46fa43a4e4e30f53", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2297/mbox/", "series": [ { "id": 568, "url": "https://patchwork.libcamera.org/api/1.1/series/568/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=568", "date": "2019-11-08T20:53:45", "name": "Control serialization and IPA C API", "version": 2, "mbox": "https://patchwork.libcamera.org/series/568/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2297/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2297/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 03AFD60180\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 8 Nov 2019 21:54:23 +0100 (CET)", "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7E8BF31D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 8 Nov 2019 21:54:22 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1573246462;\n\tbh=G3EWCu0Cg+17Po+3IP+/CM6lTboTDnDa5wMsYjgM3yc=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=F5VwNyfpVfQZA3yvbjiVx8tO85fSCpYOgzbmdHBbU2MujSfmIKRpe9Ai+RUB++wTt\n\tNLZuyG8g7+foiAH8z4jlcqQGS7RLGAeqNdn3QBnzbPIsQb6uHDnoD9JgUKt+ClI8X/\n\tTmHTfgnmRf2gfvcSUlaOJHrNZfy4QFu9XoikqsDY=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 8 Nov 2019 22:53:46 +0200", "Message-Id": "<20191108205409.18845-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.23.0", "In-Reply-To": "<20191108205409.18845-1-laurent.pinchart@ideasonboard.com>", "References": "<20191108205409.18845-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 01/24] test: Extract CameraTest class\n\tout of camera tests to libtest", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "X-List-Received-Date": "Fri, 08 Nov 2019 20:54:23 -0000" }, "content": "Many tests other than the camera/ tests use a camera. To increase code\nsharing, move the base CameraTest class to the test library. The class\nbecomes a helper that doesn't inherit from Test anymore (to avoid\ndiamond inheritance issues when more such helpers will exist).\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/camera/buffer_import.cpp | 14 ++++-----\n test/camera/capture.cpp | 15 ++++++---\n test/camera/configuration_default.cpp | 16 ++++++++--\n test/camera/configuration_set.cpp | 15 ++++++---\n test/camera/meson.build | 2 +-\n test/camera/statemachine.cpp | 15 ++++++---\n test/controls/control_list.cpp | 39 +++++-------------------\n test/{camera => libtest}/camera_test.cpp | 24 +++++++++------\n test/{camera => libtest}/camera_test.h | 12 +++-----\n test/libtest/meson.build | 1 +\n 10 files changed, 77 insertions(+), 76 deletions(-)\n rename test/{camera => libtest}/camera_test.cpp (55%)\n rename test/{camera => libtest}/camera_test.h (77%)", "diff": "diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\nindex bbc5a25c4019..3efe02704c02 100644\n--- a/test/camera/buffer_import.cpp\n+++ b/test/camera/buffer_import.cpp\n@@ -18,6 +18,7 @@\n #include \"v4l2_videodevice.h\"\n \n #include \"camera_test.h\"\n+#include \"test.h\"\n \n using namespace libcamera;\n \n@@ -254,11 +255,11 @@ private:\n \tbool done_;\n };\n \n-class BufferImportTest : public CameraTest\n+class BufferImportTest : public CameraTest, public Test\n {\n public:\n \tBufferImportTest()\n-\t\t: CameraTest()\n+\t\t: CameraTest(\"VIMC Sensor B\")\n \t{\n \t}\n \n@@ -350,11 +351,10 @@ protected:\n \n \tint init()\n \t{\n-\t\tint ret = CameraTest::init();\n-\t\tif (ret)\n-\t\t\treturn ret;\n+\t\tif (status_ != TestPass)\n+\t\t\treturn status_;\n \n-\t\tret = sink_.init();\n+\t\tint ret = sink_.init();\n \t\tif (ret != TestPass) {\n \t\t\tcleanup();\n \t\t\treturn ret;\n@@ -422,8 +422,6 @@ protected:\n \n \t\tcamera_->stop();\n \t\tcamera_->freeBuffers();\n-\n-\t\tCameraTest::cleanup();\n \t}\n \n private:\ndiff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\nindex 791ccad15f70..08cce9c7cbaf 100644\n--- a/test/camera/capture.cpp\n+++ b/test/camera/capture.cpp\n@@ -8,13 +8,20 @@\n #include <iostream>\n \n #include \"camera_test.h\"\n+#include \"test.h\"\n \n using namespace std;\n \n namespace {\n \n-class Capture : public CameraTest\n+class Capture : public CameraTest, public Test\n {\n+public:\n+\tCapture()\n+\t\t: CameraTest(\"VIMC Sensor B\")\n+\t{\n+\t}\n+\n protected:\n \tunsigned int completeBuffersCount_;\n \tunsigned int completeRequestsCount_;\n@@ -46,14 +53,12 @@ protected:\n \n \tint init() override\n \t{\n-\t\tint ret = CameraTest::init();\n-\t\tif (ret)\n-\t\t\treturn ret;\n+\t\tif (status_ != TestPass)\n+\t\t\treturn status_;\n \n \t\tconfig_ = camera_->generateConfiguration({ StreamRole::VideoRecording });\n \t\tif (!config_ || config_->size() != 1) {\n \t\t\tcout << \"Failed to generate default configuration\" << endl;\n-\t\t\tCameraTest::cleanup();\n \t\t\treturn TestFail;\n \t\t}\n \ndiff --git a/test/camera/configuration_default.cpp b/test/camera/configuration_default.cpp\nindex ce2ec5d02e7b..31c908d2449e 100644\n--- a/test/camera/configuration_default.cpp\n+++ b/test/camera/configuration_default.cpp\n@@ -8,15 +8,27 @@\n #include <iostream>\n \n #include \"camera_test.h\"\n+#include \"test.h\"\n \n using namespace std;\n \n namespace {\n \n-class ConfigurationDefault : public CameraTest\n+class ConfigurationDefault : public CameraTest, public Test\n {\n+public:\n+\tConfigurationDefault()\n+\t\t: CameraTest(\"VIMC Sensor B\")\n+\t{\n+\t}\n+\n protected:\n-\tint run()\n+\tint init() override\n+\t{\n+\t\treturn status_;\n+\t}\n+\n+\tint run() override\n \t{\n \t\tstd::unique_ptr<CameraConfiguration> config;\n \ndiff --git a/test/camera/configuration_set.cpp b/test/camera/configuration_set.cpp\nindex f88da96ca2b7..b4b5968115e8 100644\n--- a/test/camera/configuration_set.cpp\n+++ b/test/camera/configuration_set.cpp\n@@ -8,24 +8,29 @@\n #include <iostream>\n \n #include \"camera_test.h\"\n+#include \"test.h\"\n \n using namespace std;\n \n namespace {\n \n-class ConfigurationSet : public CameraTest\n+class ConfigurationSet : public CameraTest, public Test\n {\n+public:\n+\tConfigurationSet()\n+\t\t: CameraTest(\"VIMC Sensor B\")\n+\t{\n+\t}\n+\n protected:\n \tint init() override\n \t{\n-\t\tint ret = CameraTest::init();\n-\t\tif (ret)\n-\t\t\treturn ret;\n+\t\tif (status_ != TestPass)\n+\t\t\treturn status_;\n \n \t\tconfig_ = camera_->generateConfiguration({ StreamRole::VideoRecording });\n \t\tif (!config_ || config_->size() != 1) {\n \t\t\tcout << \"Failed to generate default configuration\" << endl;\n-\t\t\tCameraTest::cleanup();\n \t\t\treturn TestFail;\n \t\t}\n \ndiff --git a/test/camera/meson.build b/test/camera/meson.build\nindex d6fd66b8f89e..e2a6660a7a92 100644\n--- a/test/camera/meson.build\n+++ b/test/camera/meson.build\n@@ -9,7 +9,7 @@ camera_tests = [\n ]\n \n foreach t : camera_tests\n- exe = executable(t[0], [t[1], 'camera_test.cpp'],\n+ exe = executable(t[0], t[1],\n dependencies : libcamera_dep,\n link_with : test_libraries,\n include_directories : test_includes_internal)\ndiff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp\nindex 12d5e0e1d534..afa13ba77b0b 100644\n--- a/test/camera/statemachine.cpp\n+++ b/test/camera/statemachine.cpp\n@@ -8,13 +8,20 @@\n #include <iostream>\n \n #include \"camera_test.h\"\n+#include \"test.h\"\n \n using namespace std;\n \n namespace {\n \n-class Statemachine : public CameraTest\n+class Statemachine : public CameraTest, public Test\n {\n+public:\n+\tStatemachine()\n+\t\t: CameraTest(\"VIMC Sensor B\")\n+\t{\n+\t}\n+\n protected:\n \tint testAvailable()\n \t{\n@@ -233,14 +240,12 @@ protected:\n \n \tint init() override\n \t{\n-\t\tint ret = CameraTest::init();\n-\t\tif (ret)\n-\t\t\treturn ret;\n+\t\tif (status_ != TestPass)\n+\t\t\treturn status_;\n \n \t\tdefconf_ = camera_->generateConfiguration({ StreamRole::VideoRecording });\n \t\tif (!defconf_) {\n \t\t\tcout << \"Failed to generate default configuration\" << endl;\n-\t\t\tCameraTest::cleanup();\n \t\t\treturn TestFail;\n \t\t}\n \ndiff --git a/test/controls/control_list.cpp b/test/controls/control_list.cpp\nindex 5af53f64bb6c..4d212abd09e6 100644\n--- a/test/controls/control_list.cpp\n+++ b/test/controls/control_list.cpp\n@@ -13,32 +13,22 @@\n #include <libcamera/controls.h>\n \n #include \"camera_controls.h\"\n+\n+#include \"camera_test.h\"\n #include \"test.h\"\n \n using namespace std;\n using namespace libcamera;\n \n-class ControlListTest : public Test\n+class ControlListTest : public CameraTest, public Test\n {\n-protected:\n-\tint init()\n+public:\n+\tControlListTest()\n+\t\t: CameraTest(\"VIMC Sensor B\")\n \t{\n-\t\tcm_ = new CameraManager();\n-\n-\t\tif (cm_->start()) {\n-\t\t\tcout << \"Failed to start camera manager\" << endl;\n-\t\t\treturn TestFail;\n-\t\t}\n-\n-\t\tcamera_ = cm_->get(\"VIMC Sensor B\");\n-\t\tif (!camera_) {\n-\t\t\tcout << \"Can not find VIMC camera\" << endl;\n-\t\t\treturn TestSkip;\n-\t\t}\n-\n-\t\treturn TestPass;\n \t}\n \n+protected:\n \tint run()\n \t{\n \t\tCameraControlValidator validator(camera_.get());\n@@ -156,21 +146,6 @@ protected:\n \n \t\treturn TestPass;\n \t}\n-\n-\tvoid cleanup()\n-\t{\n-\t\tif (camera_) {\n-\t\t\tcamera_->release();\n-\t\t\tcamera_.reset();\n-\t\t}\n-\n-\t\tcm_->stop();\n-\t\tdelete cm_;\n-\t}\n-\n-private:\n-\tCameraManager *cm_;\n-\tstd::shared_ptr<Camera> camera_;\n };\n \n TEST_REGISTER(ControlListTest)\ndiff --git a/test/camera/camera_test.cpp b/test/libtest/camera_test.cpp\nsimilarity index 55%\nrename from test/camera/camera_test.cpp\nrename to test/libtest/camera_test.cpp\nindex 101e31fbce79..2ae4d6776f2e 100644\n--- a/test/camera/camera_test.cpp\n+++ b/test/libtest/camera_test.cpp\n@@ -8,35 +8,39 @@\n #include <iostream>\n \n #include \"camera_test.h\"\n+#include \"test.h\"\n \n using namespace libcamera;\n using namespace std;\n \n-int CameraTest::init()\n+CameraTest::CameraTest(const char *name)\n {\n \tcm_ = new CameraManager();\n \n \tif (cm_->start()) {\n-\t\tcout << \"Failed to start camera manager\" << endl;\n-\t\treturn TestFail;\n+\t\tcerr << \"Failed to start camera manager\" << endl;\n+\t\tstatus_ = TestFail;\n+\t\treturn;\n \t}\n \n-\tcamera_ = cm_->get(\"VIMC Sensor B\");\n+\tcamera_ = cm_->get(name);\n \tif (!camera_) {\n-\t\tcout << \"Can not find VIMC camera\" << endl;\n-\t\treturn TestSkip;\n+\t\tcerr << \"Can not find '\" << name << \"' camera\" << endl;\n+\t\tstatus_ = TestSkip;\n+\t\treturn;\n \t}\n \n \t/* Sanity check that the camera has streams. */\n \tif (camera_->streams().empty()) {\n-\t\tcout << \"Camera has no stream\" << endl;\n-\t\treturn TestFail;\n+\t\tcerr << \"Camera has no stream\" << endl;\n+\t\tstatus_ = TestFail;\n+\t\treturn;\n \t}\n \n-\treturn TestPass;\n+\tstatus_ = TestPass;\n }\n \n-void CameraTest::cleanup()\n+CameraTest::~CameraTest()\n {\n \tif (camera_) {\n \t\tcamera_->release();\ndiff --git a/test/camera/camera_test.h b/test/libtest/camera_test.h\nsimilarity index 77%\nrename from test/camera/camera_test.h\nrename to test/libtest/camera_test.h\nindex e57b05eb28a9..0b6bad05e37c 100644\n--- a/test/camera/camera_test.h\n+++ b/test/libtest/camera_test.h\n@@ -9,22 +9,18 @@\n \n #include <libcamera/libcamera.h>\n \n-#include \"test.h\"\n-\n using namespace libcamera;\n \n-class CameraTest : public Test\n+class CameraTest\n {\n public:\n-\tCameraTest()\n-\t\t: cm_(nullptr) {}\n+\tCameraTest(const char *name);\n+\t~CameraTest();\n \n protected:\n-\tint init();\n-\tvoid cleanup();\n-\n \tCameraManager *cm_;\n \tstd::shared_ptr<Camera> camera_;\n+\tint status_;\n };\n \n #endif /* __LIBCAMERA_CAMERA_TEST_H__ */\ndiff --git a/test/libtest/meson.build b/test/libtest/meson.build\nindex ca762b4421c2..3e798ef3810e 100644\n--- a/test/libtest/meson.build\n+++ b/test/libtest/meson.build\n@@ -1,4 +1,5 @@\n libtest_sources = files([\n+ 'camera_test.cpp',\n 'test.cpp',\n ])\n \n", "prefixes": [ "libcamera-devel", "v2", "01/24" ] }