[{"id":2449,"web_url":"https://patchwork.libcamera.org/comment/2449/","msgid":"<20190817154020.GC21683@wyvern>","date":"2019-08-17T15:40:20","subject":"Re: [libcamera-devel] [PATCH v2 14/18] test: Add Timer thread move\n\ttest","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2019-08-17 18:21:00 +0300, Laurent Pinchart wrote:\n> The test verifies correct behaviour of a running timer moved to a\n> different thread.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  test/meson.build      |  1 +\n>  test/timer-thread.cpp | 78 +++++++++++++++++++++++++++++++++++++++++++\n>  2 files changed, 79 insertions(+)\n>  create mode 100644 test/timer-thread.cpp\n> \n> diff --git a/test/meson.build b/test/meson.build\n> index f695ffd7be44..05265b7d4976 100644\n> --- a/test/meson.build\n> +++ b/test/meson.build\n> @@ -29,6 +29,7 @@ internal_tests = [\n>      ['object-invoke',                   'object-invoke.cpp'],\n>      ['signal-threads',                  'signal-threads.cpp'],\n>      ['threads',                         'threads.cpp'],\n> +    ['timer-thread',                    'timer-thread.cpp'],\n>  ]\n>  \n>  foreach t : public_tests\n> diff --git a/test/timer-thread.cpp b/test/timer-thread.cpp\n> new file mode 100644\n> index 000000000000..b9373050068c\n> --- /dev/null\n> +++ b/test/timer-thread.cpp\n> @@ -0,0 +1,78 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * timer-thread.cpp - Threaded timer test\n> + */\n> +\n> +#include <chrono>\n> +#include <iostream>\n> +\n> +#include <libcamera/timer.h>\n> +\n> +#include \"test.h\"\n> +#include \"thread.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +class TimeoutHandler : public Object\n> +{\n> +public:\n> +\tTimeoutHandler()\n> +\t\t: timeout_(false)\n> +\t{\n> +\t\ttimer_.timeout.connect(this, &TimeoutHandler::timeoutHandler);\n> +\t\ttimer_.start(100);\n> +\t}\n> +\n> +\tbool timeout() const\n> +\t{\n> +\t\treturn timeout_;\n> +\t}\n> +\n> +\tvoid moveToThread(Thread *thread)\n> +\t{\n> +\t\tObject::moveToThread(thread);\n> +\t\ttimer_.moveToThread(thread);\n> +\t}\n> +\n> +private:\n> +\tvoid timeoutHandler(Timer *timer)\n> +\t{\n> +\t\ttimeout_ = true;\n> +\t}\n> +\n> +\tTimer timer_;\n> +\tbool timeout_;\n> +};\n> +\n> +class TimerThreadTest : public Test\n> +{\n> +protected:\n> +\tint run()\n> +\t{\n> +\t\tThread thread;\n> +\t\tthread.start();\n> +\n> +\t\tTimeoutHandler timeout;\n> +\t\ttimeout.moveToThread(&thread);\n> +\n> +\t\tthis_thread::sleep_for(chrono::milliseconds(100));\n> +\n> +\t\t/* Must stop thread before destroying timeout. */\n> +\t\tthread.exit(0);\n> +\t\tthread.wait();\n> +\n> +\t\tif (!timeout.timeout()) {\n> +\t\t\tcout << \"Timer expiration test failed\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +\n> +private:\n> +};\n> +\n> +TEST_REGISTER(TimerThreadTest)\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-ed1-x541.google.com (mail-ed1-x541.google.com\n\t[IPv6:2a00:1450:4864:20::541])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E17D8600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 17 Aug 2019 17:40:22 +0200 (CEST)","by mail-ed1-x541.google.com with SMTP id z51so7559579edz.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 17 Aug 2019 08:40:22 -0700 (PDT)","from localhost ([185.224.57.161]) by smtp.gmail.com with ESMTPSA id\n\tz9sm1690853edr.54.2019.08.17.08.40.21\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 17 Aug 2019 08:40:22 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=ta99L1t5bHW1tjU2EQy9OB9/I6MKYLuU1o9b7/oQjTw=;\n\tb=xPIA6gPMhn92ITrZaV784zcQuYIgJERJ3SyQQO70RrU8RLs6vtsj6+f/M9ciz2Qqe0\n\tZLdLJf+F4gwk096XPRt1MDcaeOQoJh6QdFoPNZz1PiD/2yLjUTHx6PprdlnQC6CJk4Oy\n\tcVwYq6fNkBR8br0vWRoVer8oqbfHqAf/t/dh9u6DSr7/Dq5MCsyBzMJkxAvdBng6eoQe\n\tSJhSAeGl8snd0w8bUV9BZasDzqHfcKwbCHdUKsOfN+omfvxAOxbCEWuFCch16CHrGlRw\n\tpWNPHe+A+92I8noCGW3SwVWKObzf9lhstatGC9EBe3FPwAChpuCssyH2OsTANivMpSVi\n\tHCcw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=ta99L1t5bHW1tjU2EQy9OB9/I6MKYLuU1o9b7/oQjTw=;\n\tb=TtzzVQ53KG5LdyubrPLyHCnGvcFeBotwq8mCdXHafsQIBjFYtIVqib1gADai7lHZOA\n\thFykgZBkVtfK3mVckWbsKiOD8mcW9qXkoK9C9Z712kCYew61uVcx3krAvnEXJDk3LoQb\n\tjJKoh6GkUmqWGw+I7FrZS5aKreUETTBfhadwub7EC8aVoHtN82Y81N8ZM8NukyLJwzP2\n\tYLmK8fB7EplYbUWSQFwVZ4WwxZ89fmjlMQYJ6EPaRAmsLyYvo01bW9+IQckRX5jMUG8r\n\tMDwPLX0wWmxbThsYeLM2oshFhdt43ZRoCelnbIcIdkvJNmQMqwgpeI4OlON8tBVj+tXg\n\tyiAg==","X-Gm-Message-State":"APjAAAUMOjzCTEnxTCT6rCZFFDWlhlroyoPPwdKocn5aHzFuJySfDSNk\n\ttSg8yVRbfUqdmNDkG0+Js1y5jV7+m18=","X-Google-Smtp-Source":"APXvYqxBJmdkGi8/be5K7goftkzeV8ElvG38/4ZAqJC55F6WnN3+rOSrAsXObS0Wbyr2sM5A5ClE3Q==","X-Received":"by 2002:a17:906:198e:: with SMTP id\n\tg14mr13688026ejd.158.1566056422566; \n\tSat, 17 Aug 2019 08:40:22 -0700 (PDT)","Date":"Sat, 17 Aug 2019 17:40:20 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190817154020.GC21683@wyvern>","References":"<20190817152104.10834-1-laurent.pinchart@ideasonboard.com>\n\t<20190817152104.10834-15-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190817152104.10834-15-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.12.1 (2019-06-15)","Subject":"Re: [libcamera-devel] [PATCH v2 14/18] test: Add Timer thread move\n\ttest","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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":"Sat, 17 Aug 2019 15:40:23 -0000"}}]