{"id":3806,"url":"https://patchwork.libcamera.org/api/patches/3806/?format=json","web_url":"https://patchwork.libcamera.org/patch/3806/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20200518164804.10088-2-laurent.pinchart@ideasonboard.com>","date":"2020-05-18T16:48:03","name":"[libcamera-devel,2/3] test: file-descriptor: Add \"fd move\" constructor test","commit_ref":"c7463138c666d826de26969bf03819936a8cf664","pull_url":null,"state":"accepted","archived":false,"hash":"94c14a6db04f2a2e129dacfe84192673cb0c5f52","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3806/mbox/","series":[{"id":909,"url":"https://patchwork.libcamera.org/api/series/909/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=909","date":"2020-05-18T16:48:02","name":"[libcamera-devel,1/3] libcamera: file_descriptor: Implement move semantics for constructor","version":1,"mbox":"https://patchwork.libcamera.org/series/909/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3806/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3806/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 50F3F603DA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 May 2020 18:48:18 +0200 (CEST)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 89ADBA1D;\n\tMon, 18 May 2020 18:48:17 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"DKtLNl52\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1589820498;\n\tbh=IlXuCsF606gAAUT1DnoKfLX3xufurPFMCIrVBdSjci4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=DKtLNl52mVELCIH1Bep9z28D+ap5Uapj8d2zQ9RlgKtLx62SN2VPekB8vY3Joktoq\n\tAJpFwA83485jl04rb5RSOUifQJH/+iKJLozo6iHybwhcFneDzFKwMjrt8YUYld3BJF\n\tAuQ6LqzuQVtLAl/tL0a0e7osTv/fIqqJUadXienM=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 18 May 2020 19:48:03 +0300","Message-Id":"<20200518164804.10088-2-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.26.2","In-Reply-To":"<20200518164804.10088-1-laurent.pinchart@ideasonboard.com>","References":"<20200518164804.10088-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/3] test: file-descriptor: Add \"fd move\"\n\tconstructor test","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>","X-List-Received-Date":"Mon, 18 May 2020 16:48:18 -0000"},"content":"Add a test for the newly added \"fd move\" constructor.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/file-descriptor.cpp | 42 ++++++++++++++++++++++++++++++++++++----\n 1 file changed, 38 insertions(+), 4 deletions(-)","diff":"diff --git a/test/file-descriptor.cpp b/test/file-descriptor.cpp\nindex 7477a843531c..aa3c896fb937 100644\n--- a/test/file-descriptor.cpp\n+++ b/test/file-descriptor.cpp\n@@ -56,16 +56,19 @@ protected:\n \t\tdelete desc1_;\n \t\tdesc1_ = nullptr;\n \n-\t\t/* Test creating FileDescriptor from numerical file descriptor. */\n+\t\t/*\n+\t\t * Test creating FileDescriptor by copying numerical file\n+\t\t * descriptor.\n+\t\t */\n \t\tdesc1_ = new FileDescriptor(fd_);\n \t\tif (desc1_->fd() == fd_) {\n-\t\t\tstd::cout << \"Failed fd numerical check (int constructor)\"\n+\t\t\tstd::cout << \"Failed fd numerical check (lvalue ref constructor)\"\n \t\t\t\t  << std::endl;\n \t\t\treturn TestFail;\n \t\t}\n \n \t\tif (!isValidFd(fd_) || !isValidFd(desc1_->fd())) {\n-\t\t\tstd::cout << \"Failed fd validity after construction (int constructor)\"\n+\t\t\tstd::cout << \"Failed fd validity after construction (lvalue ref constructor)\"\n \t\t\t\t  << std::endl;\n \t\t\treturn TestFail;\n \t\t}\n@@ -76,7 +79,38 @@ protected:\n \t\tdesc1_ = nullptr;\n \n \t\tif (!isValidFd(fd_) || isValidFd(fd)) {\n-\t\t\tstd::cout << \"Failed fd validity after destruction (int constructor)\"\n+\t\t\tstd::cout << \"Failed fd validity after destruction (lvalue ref constructor)\"\n+\t\t\t\t  << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Test creating FileDescriptor by taking ownership of\n+\t\t * numerical file descriptor.\n+\t\t */\n+\t\tint dupFd = dup(fd_);\n+\t\tint dupFdCopy = dupFd;\n+\n+\t\tdesc1_ = new FileDescriptor(std::move(dupFd));\n+\t\tif (desc1_->fd() != dupFdCopy) {\n+\t\t\tstd::cout << \"Failed fd numerical check (rvalue ref constructor)\"\n+\t\t\t\t  << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (dupFd != -1 || !isValidFd(fd_) || !isValidFd(desc1_->fd())) {\n+\t\t\tstd::cout << \"Failed fd validity after construction (rvalue ref constructor)\"\n+\t\t\t\t  << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tfd = desc1_->fd();\n+\n+\t\tdelete desc1_;\n+\t\tdesc1_ = nullptr;\n+\n+\t\tif (!isValidFd(fd_) || isValidFd(fd)) {\n+\t\t\tstd::cout << \"Failed fd validity after destruction (rvalue ref constructor)\"\n \t\t\t\t  << std::endl;\n \t\t\treturn TestFail;\n \t\t}\n","prefixes":["libcamera-devel","2/3"]}