{"id":1835,"url":"https://patchwork.libcamera.org/api/1.1/patches/1835/?format=json","web_url":"https://patchwork.libcamera.org/patch/1835/","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":"<20190817152104.10834-18-laurent.pinchart@ideasonboard.com>","date":"2019-08-17T15:21:03","name":"[libcamera-devel,v2,17/18] test: object: Extend object test to verify parent-child relationships","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"4ca436fa19734b104e02d24513fce8f1749f5682","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1835/mbox/","series":[{"id":463,"url":"https://patchwork.libcamera.org/api/1.1/series/463/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=463","date":"2019-08-17T15:20:46","name":"Object & Thread enhancements","version":2,"mbox":"https://patchwork.libcamera.org/series/463/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1835/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1835/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["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 0FF6A61936\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 17 Aug 2019 17:21:19 +0200 (CEST)","from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A1A43556\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 17 Aug 2019 17:21:18 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1566055278;\n\tbh=dLylKzqflPNpJuG/m2k/mjzkBGECXSMJgQYkxMJKZ/8=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=sgCpm02AmszFbWYDsOd6fVKe7lte2Yh4UiZ+KqYHAJn/TbSLr4s2adom3s/RM+nVK\n\tyIT8zQd0EUSIqonPHYba8nS70XlpQv1NKYrKL/0feXlLr4p2++fw+y5xoUo8FHvcQQ\n\tdVoGQU+v8k11IP6PPjm9LwCyB6R+GY7mqbS80Vm0=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 17 Aug 2019 18:21:03 +0300","Message-Id":"<20190817152104.10834-18-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190817152104.10834-1-laurent.pinchart@ideasonboard.com>","References":"<20190817152104.10834-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 17/18] test: object: Extend object test\n\tto 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:21:20 -0000"},"content":"The test verifies correct behaviour of parent-child relationships in\nrelation to thread affinity.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n test/object.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++----\n 1 file changed, 76 insertions(+), 6 deletions(-)","diff":"diff --git a/test/object.cpp b/test/object.cpp\nindex 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","prefixes":["libcamera-devel","v2","17/18"]}