From patchwork Fri Dec 21 12:37:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 74 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A393F60B2C for ; Fri, 21 Dec 2018 13:37:29 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2255E565; Fri, 21 Dec 2018 13:37:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1545395849; bh=8xEsQc8ihblPTAYPmXBim7y8o7afV9hgZiRsnkMRTlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vzlxinuxlmnVU1P3OL2AUIK3dmztcqCtsnPPrdzEkPPZ2LqCp4g/1WRrvubLZmEHr 9DsoYKTy33kzvdtnuT1/K367QcpeKcfF23HoqwfwfobyWrvKdoOLjtvaAti93dWLJW 2qP0ElFQnYiT5Nfa9Ju/F2oc3Jt6IHQWIlhxzfb8= From: Kieran Bingham To: LibCamera Devel Date: Fri, 21 Dec 2018 12:37:23 +0000 Message-Id: <20181221123724.27290-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181221123724.27290-1-kieran.bingham@ideasonboard.com> References: <20181221123724.27290-1-kieran.bingham@ideasonboard.com> Subject: [libcamera-devel] [PATCH 1/2] test: libtest: Add path_exists helper X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Dec 2018 12:37:36 -0000 We will frequently need to validate the existance of a target for testing. Add a helper to wrap this. This could be extended or replaced to ensure we have access to the path as well as it existing. Signed-off-by: Kieran Bingham --- test/libtest/test.cpp | 11 +++++++++++ test/libtest/test.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/test/libtest/test.cpp b/test/libtest/test.cpp index 9d537ea08698..ff0c9fc02e15 100644 --- a/test/libtest/test.cpp +++ b/test/libtest/test.cpp @@ -5,6 +5,7 @@ * test.cpp - libcamera test base class */ +#include #include "test.h" Test::Test() @@ -29,3 +30,13 @@ int Test::execute() return ret; } + +bool Test::path_exists(const char *p) +{ + struct stat sb; + + if (stat(p, &sb) == 0) + return true; + + return false; +} diff --git a/test/libtest/test.h b/test/libtest/test.h index 18b430f428c7..f21cc15e8743 100644 --- a/test/libtest/test.h +++ b/test/libtest/test.h @@ -21,6 +21,8 @@ public: int execute(); + bool path_exists(const char *p); + protected: virtual int init() { return 0; } virtual int run() = 0;