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;
 
