8297302: gtest/AsyncLogGtest.java fails AsyncLogTest.stdoutOutput_vm
Reviewed-by: dholmes, shade
This commit is contained in:
parent
20b1d19d26
commit
9412c0a2ca
@ -93,10 +93,8 @@ LOG_LEVEL_LIST
|
|||||||
if (f != NULL) {
|
if (f != NULL) {
|
||||||
size_t sz = output.size();
|
size_t sz = output.size();
|
||||||
size_t written = fwrite(output.c_str(), sizeof(char), output.size(), f);
|
size_t written = fwrite(output.c_str(), sizeof(char), output.size(), f);
|
||||||
|
// at least see "header"
|
||||||
if (written == sz * sizeof(char)) {
|
return fclose(f) == 0 && sz == written && sz >= 6;
|
||||||
return fclose(f) == 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -257,38 +255,46 @@ TEST_VM_F(AsyncLogTest, droppingMessage) {
|
|||||||
|
|
||||||
TEST_VM_F(AsyncLogTest, stdoutOutput) {
|
TEST_VM_F(AsyncLogTest, stdoutOutput) {
|
||||||
testing::internal::CaptureStdout();
|
testing::internal::CaptureStdout();
|
||||||
|
fprintf(stdout, "header");
|
||||||
set_log_config("stdout", "logging=debug");
|
set_log_config("stdout", "logging=debug");
|
||||||
|
|
||||||
test_asynclog_ls();
|
test_asynclog_ls();
|
||||||
test_asynclog_drop_messages();
|
test_asynclog_drop_messages();
|
||||||
|
|
||||||
AsyncLogWriter::flush();
|
AsyncLogWriter::flush();
|
||||||
EXPECT_TRUE(write_to_file(testing::internal::GetCapturedStdout()));
|
fflush(nullptr);
|
||||||
|
|
||||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "LogStreamWithAsyncLogImpl"));
|
if (write_to_file(testing::internal::GetCapturedStdout())) {
|
||||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream msg1-msg2-msg3"));
|
EXPECT_TRUE(file_contains_substring(TestLogFileName, "header"));
|
||||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream newline"));
|
EXPECT_TRUE(file_contains_substring(TestLogFileName, "LogStreamWithAsyncLogImpl"));
|
||||||
|
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream msg1-msg2-msg3"));
|
||||||
|
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream newline"));
|
||||||
|
|
||||||
if (AsyncLogWriter::instance() != nullptr) {
|
if (AsyncLogWriter::instance() != nullptr) {
|
||||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "messages dropped due to async logging"));
|
EXPECT_TRUE(file_contains_substring(TestLogFileName, "messages dropped due to async logging"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_VM_F(AsyncLogTest, stderrOutput) {
|
TEST_VM_F(AsyncLogTest, stderrOutput) {
|
||||||
testing::internal::CaptureStderr();
|
testing::internal::CaptureStderr();
|
||||||
|
fprintf(stderr, "header");
|
||||||
set_log_config("stderr", "logging=debug");
|
set_log_config("stderr", "logging=debug");
|
||||||
|
|
||||||
test_asynclog_ls();
|
test_asynclog_ls();
|
||||||
test_asynclog_drop_messages();
|
test_asynclog_drop_messages();
|
||||||
|
|
||||||
AsyncLogWriter::flush();
|
AsyncLogWriter::flush();
|
||||||
EXPECT_TRUE(write_to_file(testing::internal::GetCapturedStderr()));
|
fflush(nullptr);
|
||||||
|
|
||||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "LogStreamWithAsyncLogImpl"));
|
if (write_to_file(testing::internal::GetCapturedStderr())) {
|
||||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream msg1-msg2-msg3"));
|
EXPECT_TRUE(file_contains_substring(TestLogFileName, "header"));
|
||||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream newline"));
|
EXPECT_TRUE(file_contains_substring(TestLogFileName, "LogStreamWithAsyncLogImpl"));
|
||||||
|
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream msg1-msg2-msg3"));
|
||||||
|
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream newline"));
|
||||||
|
|
||||||
if (AsyncLogWriter::instance() != nullptr) {
|
if (AsyncLogWriter::instance() != nullptr) {
|
||||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "messages dropped due to async logging"));
|
EXPECT_TRUE(file_contains_substring(TestLogFileName, "messages dropped due to async logging"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user