{"id":15752,"url":"https://patchwork.libcamera.org/api/1.1/patches/15752/?format=json","web_url":"https://patchwork.libcamera.org/patch/15752/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220429193434.167990-3-kieran.bingham@ideasonboard.com>","date":"2022-04-29T19:34:33","name":"[libcamera-devel,2/3] test: Add Sequence observer tests","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"0f609ac5e8e8f89e4ae79f56e24546231790eddc","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/1.1/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":{"id":11,"url":"https://patchwork.libcamera.org/api/1.1/users/11/?format=json","username":"kbingham","first_name":"Kieran","last_name":"Bingham","email":"kieran.bingham@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/15752/mbox/","series":[{"id":3083,"url":"https://patchwork.libcamera.org/api/1.1/series/3083/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3083","date":"2022-04-29T19:34:31","name":"Sequence Observer","version":1,"mbox":"https://patchwork.libcamera.org/series/3083/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15752/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15752/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 4495DC326C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 29 Apr 2022 19:34:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EB42B6564C;\n\tFri, 29 Apr 2022 21:34:26 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 91C0765640\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 29 Apr 2022 21:34:23 +0200 (CEST)","from Q.ksquared.org.uk.beta.tailscale.net (unknown\n\t[178.237.134.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 15A1745F;\n\tFri, 29 Apr 2022 21:34:23 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1651260866;\n\tbh=MEXKjD8dZehuJXB/0YoKuGf/nuPVIYzzNduzLWMkliI=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=YbJSEBBT2jjULFv1xmZzanTeiFyjc2f8YezpBXXYp2EwaZ09HDQO2T4FZGk1qkxWj\n\tPJXUjxbG09yeFbRmIjbpa9rdFrXUYoKzmJK/7SFs7cKTrBYFWShOpjJuz+kTxgtM/0\n\tD37lhF9/7UtLJj0duLd7O3JwCE2NV7rXzdcyeHauIXjjOItcRMijNSfZLLlRdGRLT/\n\t1Wn8tLAwDBSRgC6fZAeX7qXGB3WvPm/E/uEC+D/aIaNRTZtZyIEAeGc9Ga0tntWNQ+\n\t+K0NnkZLOolHaufoBx6K/7qlTHC+Rgcgl/ZAb3tYjJuNjvTgjbV/0U2eYP8b1YjxHu\n\tjhNJDYkiKMwzA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1651260863;\n\tbh=MEXKjD8dZehuJXB/0YoKuGf/nuPVIYzzNduzLWMkliI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=IVpb/14sbSgzNZXuEvNNaomf/AUYgBQlYIO23Qa3twMkvvr4iBd6GmwkH+ygdDaHF\n\tpj18wL940jpF9UNzt1kkUFCHXPmEsd55ZfT12KmCPUxubcmUoP2//U6Vywqzip1asj\n\t+gO+czxn0oQVmNncDLdtw5WuPV73Sv9pokF0FJH0="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"IVpb/14s\"; dkim-atps=neutral","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Fri, 29 Apr 2022 21:34:33 +0200","Message-Id":"<20220429193434.167990-3-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20220429193434.167990-1-kieran.bingham@ideasonboard.com>","References":"<20220429193434.167990-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/3] test: Add Sequence observer tests","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>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Validate the Sequence object for a set of possible permutations.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n test/meson.build  |  1 +\n test/sequence.cpp | 80 +++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 81 insertions(+)\n create mode 100644 test/sequence.cpp","diff":"diff --git a/test/meson.build b/test/meson.build\nindex fd4c5ca07c15..7c53fe5d0d76 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -47,6 +47,7 @@ internal_tests = [\n     ['object-delete',                   'object-delete.cpp'],\n     ['object-invoke',                   'object-invoke.cpp'],\n     ['pixel-format',                    'pixel-format.cpp'],\n+    ['sequence',                        'sequence.cpp'],\n     ['shared-fd',                       'shared-fd.cpp'],\n     ['signal-threads',                  'signal-threads.cpp'],\n     ['threads',                         'threads.cpp'],\ndiff --git a/test/sequence.cpp b/test/sequence.cpp\nnew file mode 100644\nindex 000000000000..4afb9998527a\n--- /dev/null\n+++ b/test/sequence.cpp\n@@ -0,0 +1,80 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2022, Ideas on Board Oy.\n+ *\n+ * sequence.cpp - Sequence observer tests\n+ */\n+\n+#include <iostream>\n+\n+#include <libcamera/sequence.h>\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class SequenceTest : public Test\n+{\n+private:\n+\tint Fail(std::string m)\n+\t{\n+\t\tcout << m << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+protected:\n+\tint run()\n+\t{\n+\t\tSequence seq;\n+\t\tint diff;\n+\n+\t\t/* Validate non-zero initialization */\n+\t\tdiff = seq.update(10);\n+\t\tif (diff)\n+\t\t\treturn Fail(\"Initialisation test failed\");\n+\n+\t\tdiff = seq.update(11);\n+\t\tif (diff)\n+\t\t\treturn Fail(\"Sequential sequence failure\");\n+\n+\t\t/* Validate 1 drop */\n+\t\tdiff = seq.update(13);\n+\t\tif (diff != 1)\n+\t\t\treturn Fail(\"Sequence gap not detected\");\n+\n+\t\t/* Validate 10 drops - currently expect sequence 14 */\n+\t\tdiff = seq.update(24);\n+\t\tif (diff != 10)\n+\t\t\treturn Fail(\"Large sequence gap not detected\");\n+\n+\t\t/* Validate reset */\n+\t\tseq.reset();\n+\t\tdiff = seq.update(50);\n+\t\tif (diff)\n+\t\t\treturn Fail(\"Reset failed\");\n+\n+\t\t/* Validate reverse sequence detected */\n+\t\tdiff = seq.update(49);\n+\t\tif (diff == 0)\n+\t\t\treturn Fail(\"Reverse sequence detection error\");\n+\n+\t\t/* Validate integer wrap around (Shouldn't ever happen but...) */\n+\t\tseq.reset();\n+\t\tdiff = seq.update(-2);\n+\t\tif (diff)\n+\t\t\treturn Fail(\"Integer wrap test reset failed\");\n+\n+\t\tdiff = seq.update(-1);\n+\t\tif (diff)\n+\t\t\treturn Fail(\"Negative sequence failed\");\n+\n+\t\tdiff = seq.update(0);\n+\t\tif (diff)\n+\t\t\treturn Fail(\"Integer wrap test failed\");\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+TEST_REGISTER(SequenceTest)\n","prefixes":["libcamera-devel","2/3"]}