[{"id":2443,"web_url":"https://patchwork.libcamera.org/comment/2443/","msgid":"<20190817151434.GS16603@wyvern>","date":"2019-08-17T15:14:34","subject":"Re: [libcamera-devel] [PATCH 17/18] test: object: Extend object\n\ttest to verify parent-child relationships","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:41 +0300, Laurent Pinchart wrote:\n> The test verifies correct behaviour of parent-child relationships in\n> relation to thread affinity.\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/object.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++----\n>  1 file changed, 76 insertions(+), 6 deletions(-)\n> \n> diff --git a/test/object.cpp b/test/object.cpp\n> index 3f1f700d1b39..16118971c755 100644\n> --- a/test/object.cpp\n> +++ b/test/object.cpp\n> @@ -25,8 +25,8 @@ public:\n>  \t\tMessageReceived,\n>  \t};\n>  \n> -\tInstrumentedObject()\n> -\t\t: status_(NoMessage)\n> +\tInstrumentedObject(Object *parent = nullptr)\n> +\t\t: Object(parent), status_(NoMessage)\n>  \t{\n>  \t}\n>  \n> @@ -51,22 +51,82 @@ class ObjectTest : public Test\n>  protected:\n>  \tint init()\n>  \t{\n> +\t\t/*\n> +\t\t * Create a hierarchy of objects:\n> +\t\t * A -> B -> C\n> +\t\t *   \\->D\n> +\t\t * E\n> +\t\t */\n>  \t\ta_ = new InstrumentedObject();\n> +\t\tb_ = new InstrumentedObject(a_);\n> +\t\tc_ = new InstrumentedObject(b_);\n> +\t\td_ = new InstrumentedObject(a_);\n> +\t\te_ = new InstrumentedObject();\n> +\t\tf_ = nullptr;\n> +\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> +\t\t/* Verify the parent-child relationships. */\n> +\t\tif (a_->parent() != nullptr || b_->parent() != a_ ||\n> +\t\t    c_->parent() != b_ || d_->parent() != a_ ||\n> +\t\t    e_->parent() != nullptr) {\n> +\t\t\tcout << \"Incorrect parent-child relationships\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n>  \n> -\t\tif (a_->thread() != &thread_ || a_->thread() == Thread::current()) {\n> +\t\t/*\n> +\t\t * Verify that moving an object with no parent to a different\n> +\t\t * thread succeeds.\n> +\t\t */\n> +\t\te_->moveToThread(&thread_);\n> +\n> +\t\tif (e_->thread() != &thread_ || e_->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/*\n> +\t\t * Verify that moving an object with a parent to a different\n> +\t\t * thread fails. This results in an undefined behaviour, the\n> +\t\t * test thus depends on the internal implementation returning\n> +\t\t * without performing any change.\n> +\t\t */\n> +\t\tb_->moveToThread(&thread_);\n> +\n> +\t\tif (b_->thread() != Thread::current()) {\n> +\t\t\tcout << \"Moving object with parent to thread shouldn't succeed\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Verify that moving an object with children to a different\n> +\t\t * thread moves all the children.\n> +\t\t */\n> +\t\ta_->moveToThread(&thread_);\n> +\n> +\t\tif (a_->thread() != &thread_ || b_->thread() != &thread_ ||\n> +\t\t    c_->thread() != &thread_ || d_->thread() != &thread_) {\n> +\t\t\tcout << \"Failed to move children to thread\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/* Verify that objects are bound to the thread of their parent. */\n> +\t\tf_ = new InstrumentedObject(d_);\n> +\n> +\t\tif (f_->thread() != &thread_) {\n> +\t\t\tcout << \"Failed to bind child to parent 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\tif (a_->status() != InstrumentedObject::MessageReceived ||\n> +\t\t    b_->status() != InstrumentedObject::MessageReceived ||\n> +\t\t    c_->status() != InstrumentedObject::MessageReceived ||\n> +\t\t    d_->status() != InstrumentedObject::MessageReceived ||\n> +\t\t    e_->status() != InstrumentedObject::MessageReceived) {\n>  \t\t\tcout << \"Moving object didn't deliver ThreadMoveMessage\" << endl;\n>  \t\t\treturn TestFail;\n>  \t\t}\n> @@ -77,10 +137,20 @@ protected:\n>  \tvoid cleanup()\n>  \t{\n>  \t\tdelete a_;\n> +\t\tdelete b_;\n> +\t\tdelete c_;\n> +\t\tdelete d_;\n> +\t\tdelete e_;\n> +\t\tdelete f_;\n>  \t}\n>  \n>  private:\n>  \tInstrumentedObject *a_;\n> +\tInstrumentedObject *b_;\n> +\tInstrumentedObject *c_;\n> +\tInstrumentedObject *d_;\n> +\tInstrumentedObject *e_;\n> +\tInstrumentedObject *f_;\n>  \n>  \tThread thread_;\n>  };\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-x544.google.com (mail-ed1-x544.google.com\n\t[IPv6:2a00:1450:4864:20::544])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E12CE600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 17 Aug 2019 17:14:36 +0200 (CEST)","by mail-ed1-x544.google.com with SMTP id a21so7537456edt.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 17 Aug 2019 08:14:36 -0700 (PDT)","from localhost ([185.224.57.161]) by smtp.gmail.com with ESMTPSA id\n\tc1sm1693626edn.62.2019.08.17.08.14.35\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 17 Aug 2019 08:14: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=UrTa8IKMA6x/+SRZqK1ayUrIZVRV+Whtvlf8p8rC5pQ=;\n\tb=tap5my2VHcRXIRGRBAJjbkJyI0FrzG2UM20nSC7kBHPaIh73Tsx5Lu/ZtJfrFSDYNK\n\tWG2ClGRI503g8tWz1DgR+4V7BcWxS1nCQlAkDjRTwJ6e6CX+beHlZpbKa3fimrVHix3d\n\tSr9iBkFZn0gjR9ehFOVdqhuIoNqZ9XcbqneGxDlbT2akRvVODfGMr9sn6tcT4HewIn83\n\tkDl0G520/k6YWQPxPQVS73nBM2f4UMiys7rqORCElbHXeNKONg65aYKbBin30v+q91oU\n\tJ+HcjwVf2Sh3+6aZz+AkLyMXUygMU90XfQAZyp+gXGqU6fhbCFPtxPzpXOivKhNn8cIG\n\t+nbQ==","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=UrTa8IKMA6x/+SRZqK1ayUrIZVRV+Whtvlf8p8rC5pQ=;\n\tb=ft6K13cg/lztdr08Ynl7UCcylaJWJMFyQeX/xmRqEzAk8iGVoefI8LWkYOPgxln5pb\n\tRSWbnemvMa6jAaiqsqXEISAFox76kkJklLEjksV3EX4PaBXq+CPa1IeM141TyQsud5Sp\n\tsFzrxCh8j8eoS7wjvLKimCTmyc2fVsUn+qCBTM9J1GQk2tqZopIEDHFkzYiNh0nO3wAO\n\tILRyqbIvCVjmGY9d1Ya/TKGYfP/HGlmDgalL1vWQEp4QgbXoWyYneL+4enTkDhDsMa6x\n\tn3b1v1v8s3aZs+x+uJax4eGJg97IZ7X0/2UYoIdY5r2LmPMA66zIx3uFkPnfr8kq8sYG\n\tXpzQ==","X-Gm-Message-State":"APjAAAXHlwezF7HdgVA5OC0b6gLEoojIXfSBNrhX1t2Vtc5ToZdv6PuW\n\tuE9uJ7WCQ0I2mdscMjyJZNFg1M7famw=","X-Google-Smtp-Source":"APXvYqxnEjTlf3ErR5amis9SW7+IKLGFeVbLlOaR7JACQ1VmQk7gBJ45eT/opHhHz/luPpTP7h3dsg==","X-Received":"by 2002:a50:90c5:: with SMTP id d5mr16808988eda.28.1566054876628;\n\tSat, 17 Aug 2019 08:14:36 -0700 (PDT)","Date":"Sat, 17 Aug 2019 17:14: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":"<20190817151434.GS16603@wyvern>","References":"<20190812124642.24287-1-laurent.pinchart@ideasonboard.com>\n\t<20190812124642.24287-18-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-18-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.12.1 (2019-06-15)","Subject":"Re: [libcamera-devel] [PATCH 17/18] test: object: Extend object\n\ttest to verify parent-child relationships","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:14:37 -0000"}}]