Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a16b0f4c authored by Dan Albert's avatar Dan Albert Committed by Gerrit Code Review
Browse files

Merge "The generic failure case disappeared..."

parents 28f07697 08f66bc7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;
+12 −0
Original line number Diff line number Diff line
@@ -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;