[{"id":2436,"web_url":"https://patchwork.libcamera.org/comment/2436/","msgid":"<20190817145534.GM16603@wyvern>","date":"2019-08-17T14:55:34","subject":"Re: [libcamera-devel] [PATCH 09/18] test: Add Object class thread\n\taffinity test","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-12 15:46:33 +0300, Laurent Pinchart wrote:\n> The test verifies thread affinity and thread move notifications.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  test/meson.build |  1 +\n>  test/object.cpp  | 88 ++++++++++++++++++++++++++++++++++++++++++++++++\n>  2 files changed, 89 insertions(+)\n>  create mode 100644 test/object.cpp\n> \n> diff --git a/test/meson.build b/test/meson.build\n> index 7c9abc630230..c6601813db78 100644\n> --- a/test/meson.build\n> +++ b/test/meson.build\n> @@ -24,6 +24,7 @@ public_tests = [\n>  internal_tests = [\n>      ['camera-sensor',                   'camera-sensor.cpp'],\n>      ['message',                         'message.cpp'],\n> +    ['object',                          'object.cpp'],\n>      ['object-invoke',                   'object-invoke.cpp'],\n>      ['signal-threads',                  'signal-threads.cpp'],\n>      ['threads',                         'threads.cpp'],\n> diff --git a/test/object.cpp b/test/object.cpp\n> new file mode 100644\n> index 000000000000..3f1f700d1b39\n> --- /dev/null\n> +++ b/test/object.cpp\n> @@ -0,0 +1,88 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * object.cpp - Object tests\n> + */\n> +\n> +#include <iostream>\n> +\n> +#include <libcamera/object.h>\n> +\n> +#include \"message.h\"\n> +#include \"thread.h\"\n> +\n> +#include \"test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +class InstrumentedObject : public Object\n> +{\n> +public:\n> +\tenum Status {\n> +\t\tNoMessage,\n> +\t\tMessageReceived,\n> +\t};\n> +\n> +\tInstrumentedObject()\n> +\t\t: status_(NoMessage)\n> +\t{\n> +\t}\n> +\n> +\tStatus status() const { return status_; }\n> +\tvoid reset() { status_ = NoMessage; }\n> +\n> +protected:\n> +\tvoid message(Message *msg) override\n> +\t{\n> +\t\tif (msg->type() == Message::ThreadMoveMessage)\n> +\t\t\tstatus_ = MessageReceived;\n> +\n> +\t\tObject::message(msg);\n> +\t}\n> +\n> +private:\n> +\tStatus status_;\n> +};\n> +\n> +class ObjectTest : public Test\n> +{\n> +protected:\n> +\tint init()\n> +\t{\n> +\t\ta_ = new InstrumentedObject();\n> +\t\treturn TestPass;\n> +\t}\n> +\n> +\tint run()\n> +\t{\n> +\t\t/* Verify that moving an object to a different thread succeeds. */\n> +\t\ta_->moveToThread(&thread_);\n> +\n> +\t\tif (a_->thread() != &thread_ || a_->thread() == Thread::current()) {\n> +\t\t\tcout << \"Failed to move object to thread\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/* Verify that objects receive a ThreadMoveMessage when moved. */\n> +\t\tif (a_->status() != InstrumentedObject::MessageReceived) {\n> +\t\t\tcout << \"Moving object didn't deliver ThreadMoveMessage\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +\n> +\tvoid cleanup()\n> +\t{\n> +\t\tdelete a_;\n> +\t}\n> +\n> +private:\n> +\tInstrumentedObject *a_;\n> +\n> +\tThread thread_;\n> +};\n> +\n> +TEST_REGISTER(ObjectTest)\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 0A066600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 17 Aug 2019 16:55:37 +0200 (CEST)","by mail-ed1-x541.google.com with SMTP id g8so7525272edm.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 17 Aug 2019 07:55:37 -0700 (PDT)","from localhost ([185.224.57.161]) by smtp.gmail.com with ESMTPSA id\n\t59sm1686005edg.44.2019.08.17.07.55.35\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 17 Aug 2019 07:55:36 -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=xIWsZN+D0iwEX88Ordd3cBdxMhuRgQ2P8AFFtbeyPYk=;\n\tb=xHlTkfHZShT5atfGnGcn0RINNjiw7z1lNqC5SnnhqCQ2PyjfRuBIbacRCCSYmhtK1M\n\tTXRiVrCWzCSXMpbW75d3GzHhq1jW9Pz5NtmRpboYDkQNxPuX+u32YwVYN4zHkE9IPmGd\n\tCLefCXnD9+Zf0KLlHfTVwSpReOO3i/MKwqGYW3A1Rs3TuJg9wsdHTPVvRLqxCQkNvUty\n\tiBBPW6k58ovBK2n9R+I0gj5z5cVEsNpJSInJBIzPSQ2aGqGB6vmuOdyIltEmpptU5G++\n\tnP/MiOb6ULIthpSP4SZ+AVc1EMajdyWMO3Z2Ul7gYdDfzTVO2sDh1yKPWjl+fWEUa5ky\n\t4TVg==","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=xIWsZN+D0iwEX88Ordd3cBdxMhuRgQ2P8AFFtbeyPYk=;\n\tb=ArDHUmNct2hv263F5bjYibGA8TJ7gBjxRXEG1+NhM0pMC15p2qFahSJc73RNu77Umf\n\ty/+bA+amCkI9y5BW6GWO1p4oZBVTntbXkinTbr5w0SKBJqoUtrvJgAdD7CREBRCEWBw/\n\tALCJPuLfm+ht/OIZWtE2gQH96NCcaQQU6LlJOHn2tuJsdLrtM9oa61aB1n64dtzs15ur\n\tv+k2lUL2nk/gHULmy7P+zkXZnF0EUr1vpKzIuyaJu/erXQzhyZimdaVVueandhDs7JGx\n\thVaTjpeif8D3gat5DNv7HGdWn70xtsJlw9GguzVnVEaOENtCHqYgbluDSJOH54vB+4Pa\n\tcPJA==","X-Gm-Message-State":"APjAAAWmM6xy7IW0iTTa0NiJRCDXX26LtvUE21TiGybGHo+OaFnY2Xka\n\thk1a937KybUfcanTBT3HkZIuCw==","X-Google-Smtp-Source":"APXvYqwJExkGIh6aiBXVpBdoQUe8TopuMxzNmZG1o4iJu9kBKb2mPS1htOFloLj3KHiwPAchmnKVgw==","X-Received":"by 2002:a17:906:b7c9:: with SMTP id\n\tfy9mr13360189ejb.237.1566053736686; \n\tSat, 17 Aug 2019 07:55:36 -0700 (PDT)","Date":"Sat, 17 Aug 2019 16:55:34 +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":"<20190817145534.GM16603@wyvern>","References":"<20190812124642.24287-1-laurent.pinchart@ideasonboard.com>\n\t<20190812124642.24287-10-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":"<20190812124642.24287-10-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.12.1 (2019-06-15)","Subject":"Re: [libcamera-devel] [PATCH 09/18] test: Add Object class thread\n\taffinity test","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 14:55:37 -0000"}}]