From patchwork Fri May 17 23:06:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1226 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 D3CCD61871 for ; Sat, 18 May 2019 01:06:45 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 791C72F3 for ; Sat, 18 May 2019 01:06:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1558134405; bh=HphyvmR2Cy2YpaC/bCTqAnP7Pvc/m4VmT/fUHHIOzl0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qk66SYVtHHYfJaFz3G6GIGWPQGBqYly5JlmEop0/YInamgt0SGOrogEkdNXG9KLHE mmh4+rWSJ/suUOMSJtkB8atg8fOYrpFA6SFHK/pWxPS3v21w9HefZrWtal2UmY6fun 79oj9Yla6Myk8YD6XKGkhE1v1j3mmuLsp5LV6PEU= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 18 May 2019 02:06:18 +0300 Message-Id: <20190517230621.24668-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190517230621.24668-1-laurent.pinchart@ideasonboard.com> References: <20190517230621.24668-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH/RFC 09/12] test: stream: Add test for StreamFormat 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: Fri, 17 May 2019 23:06:48 -0000 From: Niklas Söderlund Test that both discrete and range based stream format descriptions result in good discrete frame sizes. The range based stream formats needs to be fitted with a table of resolutions inside libcamera so if that table is update this test might need to be updated. Signed-off-by: Niklas Söderlund --- test/meson.build | 1 + test/stream/meson.build | 10 +++ test/stream/stream_formats.cpp | 112 +++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 test/stream/meson.build create mode 100644 test/stream/stream_formats.cpp diff --git a/test/meson.build b/test/meson.build index d501f2beaf96..a25e203bcfed 100644 --- a/test/meson.build +++ b/test/meson.build @@ -3,6 +3,7 @@ subdir('libtest') subdir('camera') subdir('media_device') subdir('pipeline') +subdir('stream') subdir('v4l2_device') subdir('v4l2_subdevice') diff --git a/test/stream/meson.build b/test/stream/meson.build new file mode 100644 index 000000000000..1d5a4a97aec4 --- /dev/null +++ b/test/stream/meson.build @@ -0,0 +1,10 @@ +stream_tests = [ + [ 'stream_formats', 'stream_formats.cpp' ], +] + +foreach t : stream_tests + exe = executable(t[0], t[1], + link_with : test_libraries, + include_directories : test_includes_internal) + test(t[0], exe, suite: 'stream', is_parallel: false) +endforeach diff --git a/test/stream/stream_formats.cpp b/test/stream/stream_formats.cpp new file mode 100644 index 000000000000..2ee02840d4d7 --- /dev/null +++ b/test/stream/stream_formats.cpp @@ -0,0 +1,112 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * stream_formats.cpp - StreamFormats test + */ + +#include + +#include +#include + +#include "test.h" + +using namespace std; +using namespace libcamera; + +class StreamFormatsTest : public Test +{ +protected: + int init() + { + return 0; + } + + int testSizes(std::string name, std::vector test, std::vector valid) + { + bool pass = false; + + for (Size &size : test) { + pass = false; + + for (Size &validSize : valid) { + if (size == validSize) { + pass = true; + break; + } + } + + if (!pass) + break; + } + + if (!pass) { + cout << "Failed " << name << endl; + cout << "Sizes to test:" << endl; + for (Size &size : test) + cout << size.toString() << endl; + cout << "Valid sizes:" << endl; + for (Size &size : valid) + cout << size.toString() << endl; + + return TestFail; + } + + return TestPass; + } + + int run() + { + /* Test discrete sizes */ + StreamFormats discrete({ + { 1, { { Size(100, 100), Size(200, 200) } } }, + { 2, { { Size(300, 300), Size(400, 400) } } }, + }); + + if (testSizes("discrete 1", discrete.sizes(1), + { Size(100, 100), Size(200, 200) })) + return TestFail; + + if (testSizes("discrete 2", discrete.sizes(2), + { Size(300, 300), Size(400, 400) })) + return TestFail; + + /* Test range sizes */ + StreamFormats range({ + { 1, { Size(640, 480), Size(640, 480), 1, 1 } }, + { 2, { Size(640, 480), Size(800, 600), 8, 8 } }, + { 3, { Size(640, 480), Size(800, 600), 16, 16 } }, + { 4, { Size(1, 1), Size(4096, 4096), 128, 128 } }, + }); + + if (testSizes("range 1", range.sizes(1), { Size(640, 480) })) + return TestFail; + + if (testSizes("range 2", range.sizes(2), { + Size(640, 480), Size(720, 480), + Size(720, 576), Size(768, 480), + Size(800, 600) })) + return TestFail; + + + if (testSizes("range 3", range.sizes(3), { + Size(640, 480), Size(720, 480), + Size(720, 576), Size(768, 480) })) + return TestFail; + + if (testSizes("range 4", range.sizes(4), { + Size(1024, 768), Size(1280, 1024), + Size(2048, 1152), Size(2048, 1536), + Size(2560, 2048), Size(3200, 2048), })) + return TestFail; + + return TestPass; + } + + void cleanup() + { + } +}; + +TEST_REGISTER(StreamFormatsTest)