From 88c7c2010223f0e6e018e5fd0a89d648d3a57fb2 Mon Sep 17 00:00:00 2001 From: vitaut Date: Thu, 25 Jun 2015 07:06:30 -0700 Subject: [PATCH] Fix posix-test on FreeBSD (#179) --- test/posix-test.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/posix-test.cc b/test/posix-test.cc index 701fc427..23bfb426 100644 --- a/test/posix-test.cc +++ b/test/posix-test.cc @@ -292,11 +292,11 @@ TEST(FileTest, Read) { } TEST(FileTest, ReadError) { - File read_end, write_end; - File::pipe(read_end, write_end); + File f("test-file", File::WRONLY); char buf; - // We intentionally read from write_end to cause error. - EXPECT_SYSTEM_ERROR(write_end.read(&buf, 1), EBADF, "cannot read from file"); + // We intentionally read from a file opened in the write-only mode to + // cause error. + EXPECT_SYSTEM_ERROR(f.read(&buf, 1), EBADF, "cannot read from file"); } TEST(FileTest, Write) { @@ -308,10 +308,10 @@ TEST(FileTest, Write) { } TEST(FileTest, WriteError) { - File read_end, write_end; - File::pipe(read_end, write_end); - // We intentionally write to read_end to cause error. - EXPECT_SYSTEM_ERROR(read_end.write(" ", 1), EBADF, "cannot write to file"); + File f("test-file", File::RDONLY); + // We intentionally write to a file opened in the read-only mode to + // cause error. + EXPECT_SYSTEM_ERROR(f.write(" ", 1), EBADF, "cannot write to file"); } TEST(FileTest, Dup) {