diff options
author | Dan Albert <danalbert@google.com> | 2015-03-20 03:50:36 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-03-20 03:50:36 +0000 |
commit | a16b0f4c3a7b6546690cbdbd3d63b5cdd2da4149 (patch) | |
tree | e895a9612ee9f8fb06770dfd3c0cf5249dc3cb30 | |
parent | 28f07697eb6f4039daae6c9c5efee67a4d85cc92 (diff) | |
parent | 08f66bc771ac798d89451a9b68a1c6722352d683 (diff) | |
download | system_core-a16b0f4c3a7b6546690cbdbd3d63b5cdd2da4149.zip system_core-a16b0f4c3a7b6546690cbdbd3d63b5cdd2da4149.tar.gz system_core-a16b0f4c3a7b6546690cbdbd3d63b5cdd2da4149.tar.bz2 |
Merge "The generic failure case disappeared..."
-rw-r--r-- | adb/adb_io.cpp | 2 | ||||
-rw-r--r-- | adb/adb_io_test.cpp | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/adb/adb_io.cpp b/adb/adb_io.cpp index 3370a0c..d89f304 100644 --- a/adb/adb_io.cpp +++ b/adb/adb_io.cpp @@ -79,6 +79,8 @@ bool WriteFdExactly(int fd, const void* buf, size_t len) { D("writex: fd=%d disconnected\n", fd); errno = 0; return false; + } else { + return false; } } else { len -= r; diff --git a/adb/adb_io_test.cpp b/adb/adb_io_test.cpp index 0c69bc9..da340b2 100644 --- a/adb/adb_io_test.cpp +++ b/adb/adb_io_test.cpp @@ -18,8 +18,11 @@ #include <gtest/gtest.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> +#include <sys/stat.h> +#include <sys/types.h> #include <unistd.h> #include <string> @@ -127,6 +130,15 @@ TEST(io, WriteFdExactly_partial) { EXPECT_EQ(expected, s); } +TEST(io, WriteFdExactly_ENOSPC) { + int fd = open("/dev/full", O_WRONLY); + ASSERT_NE(-1, fd); + + char buf[] = "foo"; + ASSERT_FALSE(WriteFdExactly(fd, buf, sizeof(buf))); + ASSERT_EQ(ENOSPC, errno); +} + TEST(io, WriteStringFully) { const char str[] = "Foobar"; TemporaryFile tf; |