diff --git a/test/file.cpp b/test/file.cpp
index 6262a6f..85eacb5 100644
--- a/test/file.cpp
+++ b/test/file.cpp
@@ -27,10 +27,15 @@ protected:
 	{
 		fileName_ = "/tmp/libcamera.test.XXXXXX";
 		int fd = mkstemp(&fileName_.front());
+		ssize_t ret;
+
 		if (fd == -1)
 			return TestFail;
 
-		write(fd, "libcamera", 9);
+		ret = write(fd, "libcamera", 9);
+		if(ret == -1)
+			return TestFail;
+
 		close(fd);
 
 		return TestPass;
