[libcamera-devel] [PATCH 1/2] test: file: Check that directories are not treated as files

Kieran Bingham kieran.bingham at ideasonboard.com
Tue Dec 22 14:58:48 CET 2020


Directories can not be opened as a file, so the exists() check should
not return true for a path which points to a directory.

Directories are not handled by the File class.

Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
 test/file.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/test/file.cpp b/test/file.cpp
index f458f355ccad..b80667ae5b2f 100644
--- a/test/file.cpp
+++ b/test/file.cpp
@@ -49,6 +49,11 @@ protected:
 			return TestFail;
 		}
 
+		if (File::exists("/dev")) {
+			cerr << "Directories should not be treated as files" << endl;
+			return TestFail;
+		}
+
 		/* Test unnamed file. */
 		File file;
 
-- 
2.25.1



More information about the libcamera-devel mailing list