Fix test.

This commit is contained in:
Victor Zverovich 2014-05-04 18:23:06 -07:00
parent a07350a0d4
commit 3555341ab4

View File

@ -573,12 +573,17 @@ TEST(OutputRedirectTest, ErrorInDtor) {
OutputRedirect *redir = new OutputRedirect(f.get()); OutputRedirect *redir = new OutputRedirect(f.get());
// Put a character in a file buffer. // Put a character in a file buffer.
EXPECT_EQ('x', fputc('x', f.get())); EXPECT_EQ('x', fputc('x', f.get()));
#ifndef _WIN32
// The close function must be called inside EXPECT_STDERR, otherwise // The close function must be called inside EXPECT_STDERR, otherwise
// the system may recycle closed file descriptor when redirecting the // the system may recycle closed file descriptor when redirecting the
// output in EXPECT_STDERR and the second close will break output // output in EXPECT_STDERR and the second close will break output
// redirection. // redirection.
EXPECT_STDERR(close(write_fd); delete redir, EXPECT_STDERR(close(write_fd); delete redir,
FormatSystemErrorMessage(EBADF, "cannot flush stream")); FormatSystemErrorMessage(EBADF, "cannot flush stream"));
#else
close(write_fd);
EXPECT_DEATH(delete redir, "");
#endif
write_dup.dup2(write_fd); // "undo" close or dtor of BufferedFile will fail write_dup.dup2(write_fd); // "undo" close or dtor of BufferedFile will fail
} }