8350824: New async logging gtest StallingModePreventsDroppedMessages fails

Reviewed-by: mbaesken, dholmes
This commit is contained in:
Johan Sjölen 2025-02-28 09:48:17 +00:00
parent eada1ea8d2
commit ac76d8d63f
2 changed files with 12 additions and 19 deletions

View File

@ -253,18 +253,6 @@ TEST_VM_F(AsyncLogTest, droppingMessage) {
EXPECT_TRUE(file_contains_substring(TestLogFileName, "messages dropped due to async logging"));
}
TEST_VM_F(AsyncLogTest, StallingModePreventsDroppedMessages) {
if (AsyncLogWriter::instance() == nullptr) {
return;
}
set_log_config(TestLogFileName, "logging=debug");
LogConfiguration::AsyncMode prev_mode = LogConfiguration::async_mode();
LogConfiguration::set_async_mode(LogConfiguration::AsyncMode::Off);
test_asynclog_drop_messages();
EXPECT_FALSE(file_contains_substring(TestLogFileName, "messages dropped due to async logging"));
LogConfiguration::set_async_mode(prev_mode);
}
TEST_VM_F(AsyncLogTest, stdoutOutput) {
testing::internal::CaptureStdout();
@ -272,7 +260,8 @@ TEST_VM_F(AsyncLogTest, stdoutOutput) {
return;
}
bool async = AsyncLogWriter::instance() != nullptr;
bool async = AsyncLogWriter::instance() != nullptr
&& LogConfiguration::async_mode() == LogConfiguration::AsyncMode::Drop;
if (async) {
test_asynclog_drop_messages();
AsyncLogWriter::flush();
@ -301,7 +290,8 @@ TEST_VM_F(AsyncLogTest, stderrOutput) {
return;
}
bool async = AsyncLogWriter::instance() != nullptr;
bool async = AsyncLogWriter::instance() != nullptr
&& LogConfiguration::async_mode() == LogConfiguration::AsyncMode::Drop;
if (async) {
test_asynclog_drop_messages();
AsyncLogWriter::flush();

View File

@ -35,19 +35,22 @@ import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
public class StressAsyncUL {
static void analyze_output(String... args) throws Exception {
static void analyze_output(boolean stalling_mode, String... args) throws Exception {
ProcessBuilder pb =
ProcessTools.createLimitedTestJavaProcessBuilder(args);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
if (stalling_mode) {
output.shouldNotContain("messages dropped due to async logging");
}
}
public static void main(String[] args) throws Exception {
analyze_output("-Xlog:async:drop", "-Xlog:all=trace", InnerClass.class.getName());
analyze_output("-Xlog:async:stall", "-Xlog:all=trace", InnerClass.class.getName());
analyze_output(false, "-Xlog:async:drop", "-Xlog:all=trace", InnerClass.class.getName());
analyze_output(true, "-Xlog:async:stall", "-Xlog:all=trace", InnerClass.class.getName());
// Stress test with a very small buffer. Note: Any valid buffer size must be able to hold a flush token.
// Therefore the size of the buffer cannot be zero.
analyze_output("-Xlog:async:drop", "-Xlog:all=trace", "-XX:AsyncLogBufferSize=192", InnerClass.class.getName());
analyze_output("-Xlog:async:stall", "-Xlog:all=trace", "-XX:AsyncLogBufferSize=192", InnerClass.class.getName());
analyze_output(false, "-Xlog:async:drop", "-Xlog:all=trace", "-XX:AsyncLogBufferSize=192", InnerClass.class.getName());
analyze_output(true, "-Xlog:async:stall", "-Xlog:all=trace", "-XX:AsyncLogBufferSize=192", InnerClass.class.getName());
}
public static class InnerClass {