diff --git a/test/tools.cpp b/test/tools.cpp index 2013ee222..7d9e18c3e 100644 --- a/test/tools.cpp +++ b/test/tools.cpp @@ -95,7 +95,9 @@ std::unique_ptr makeTempFile(const char* name, const std::string& content) { std::unique_ptr p(new TempFile(name)); - write(p->fd(), &content[0], content.size()); + if (write(p->fd(), &content[0], content.size()) != (ssize_t)content.size()) { + throw std::runtime_error("Error writing temp file " + p->path()); + } p->close(); return p; } diff --git a/test/tools.h b/test/tools.h index f5aa2eb59..e8074282f 100644 --- a/test/tools.h +++ b/test/tools.h @@ -113,7 +113,9 @@ zim::Buffer write_to_buffer(const T& object, const std::string& tail="") TempFile tmpFile("test_temp_file"); const auto tmp_fd = tmpFile.fd(); object.write(tmp_fd); - write(tmp_fd, tail.data(), tail.size()); + if (write(tmp_fd, tail.data(), tail.size()) != (ssize_t)tail.size()) { + throw std::runtime_error("Cannot write to " + tmpFile.path()); + } size_type size = LSEEK(tmp_fd, 0, SEEK_END); auto buf = zim::Buffer::makeBuffer(zim::zsize_t(size));