am 3b2774c1: am a16b0f4c: Merge "The generic failure case disappeared..."

* commit '3b2774c1c3109c6c7b7f6213ec849bde325a8a49':
  The generic failure case disappeared...
This commit is contained in:
Dan Albert 2015-03-20 04:07:48 +00:00 committed by Android Git Automerger
commit e8ee209733
2 changed files with 14 additions and 0 deletions

View file

@ -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;

View file

@ -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;