[{"id":189,"web_url":"https://patchwork.libcamera.org/comment/189/","msgid":"<2017801.Cufg1yGLyQ@avalon>","date":"2019-01-03T13:53:57","subject":"Re: [libcamera-devel] [PATCH 1/2] test: libtest: Add path_exists\n\thelper","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Friday, 21 December 2018 14:37:23 EET Kieran Bingham wrote:\n> We will frequently need to validate the existance of a target for\n> testing. Add a helper to wrap this.\n> \n> This could be extended or replaced to ensure we have access to the path\n> as well as it existing.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  test/libtest/test.cpp | 11 +++++++++++\n>  test/libtest/test.h   |  2 ++\n>  2 files changed, 13 insertions(+)\n> \n> diff --git a/test/libtest/test.cpp b/test/libtest/test.cpp\n> index 9d537ea08698..ff0c9fc02e15 100644\n> --- a/test/libtest/test.cpp\n> +++ b/test/libtest/test.cpp\n> @@ -5,6 +5,7 @@\n>   * test.cpp - libcamera test base class\n>   */\n> \n> +#include <sys/stat.h>\n>  #include \"test.h\"\n> \n>  Test::Test()\n> @@ -29,3 +30,13 @@ int Test::execute()\n> \n>  \treturn ret;\n>  }\n> +\n> +bool Test::path_exists(const char *p)\n\nThis should be called pathExists(), and should be a static function.\n\nI wonder whether this feature will be useful as part of libcamera, in a File \nhelper class. I suppose we'll find out later.\n\n> +{\n> +\tstruct stat sb;\n> +\n> +\tif (stat(p, &sb) == 0)\n> +\t\treturn true;\n\nShould we also check whether the file can be accessed ? Or should that be a \nseparate function ?\n\n> +\treturn false;\n> +}\n> diff --git a/test/libtest/test.h b/test/libtest/test.h\n> index 18b430f428c7..f21cc15e8743 100644\n> --- a/test/libtest/test.h\n> +++ b/test/libtest/test.h\n> @@ -21,6 +21,8 @@ public:\n> \n>  \tint execute();\n> \n> +\tbool path_exists(const char *p);\n> +\n>  protected:\n>  \tvirtual int init() { return 0; }\n>  \tvirtual int run() = 0;","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 C91A660B13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  3 Jan 2019 14:52:54 +0100 (CET)","from avalon.localnet (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 35B6355E;\n\tThu,  3 Jan 2019 14:52:54 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1546523574;\n\tbh=7ud/3hZ+naTql6uh4IZQiSr4d1QnYFU0UR/z9SP9B3w=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=m5feiUcn9TCF83LtAScUi7GdvjIRhsR4UIppCAoVjqNL0p0uhyafOvLPReJ51jyYG\n\tyxc8BgeK71gq632DEzTHvEOTYjBoERNHlPj4kfNsB8lWCM4YhZyGxKdJwsy8kT+KMk\n\tFv32M0oiyU2ElCj9nmEhfi+48AFQvpLXDVS3g14M=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 03 Jan 2019 15:53:57 +0200","Message-ID":"<2017801.Cufg1yGLyQ@avalon>","Organization":"Ideas on Board Oy","In-Reply-To":"<20181221123724.27290-2-kieran.bingham@ideasonboard.com>","References":"<20181221123724.27290-1-kieran.bingham@ideasonboard.com>\n\t<20181221123724.27290-2-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"7Bit","Content-Type":"text/plain; charset=\"us-ascii\"","Subject":"Re: [libcamera-devel] [PATCH 1/2] test: libtest: Add path_exists\n\thelper","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":"Thu, 03 Jan 2019 13:52:55 -0000"}}]