[libcamera-devel] [PATCH 1/2] test: libtest: Add path_exists helper
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Thu Jan 3 14:53:57 CET 2019
Hi Kieran,
Thank you for the patch.
On Friday, 21 December 2018 14:37:23 EET Kieran Bingham wrote:
> 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 <kieran.bingham at ideasonboard.com>
> ---
> 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 <sys/stat.h>
> #include "test.h"
>
> Test::Test()
> @@ -29,3 +30,13 @@ int Test::execute()
>
> return ret;
> }
> +
> +bool Test::path_exists(const char *p)
This should be called pathExists(), and should be a static function.
I wonder whether this feature will be useful as part of libcamera, in a File
helper class. I suppose we'll find out later.
> +{
> + struct stat sb;
> +
> + if (stat(p, &sb) == 0)
> + return true;
Should we also check whether the file can be accessed ? Or should that be a
separate function ?
> + 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;
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list