8350524: Some hotspot/jtreg/serviceability/dcmd/vm tier1 tests fail on static JDK

Reviewed-by: stuefe
This commit is contained in:
Jiangli Zhou 2025-03-14 16:25:23 +00:00
parent 712a70c5c4
commit 7f42804148
4 changed files with 72 additions and 21 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -28,6 +28,7 @@ import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Platform;
import jdk.test.lib.dcmd.CommandExecutor;
import jdk.test.lib.dcmd.JMXExecutor;
import jdk.test.whitebox.WhiteBox;
/*
* @test
@ -37,16 +38,28 @@ import jdk.test.lib.dcmd.JMXExecutor;
* java.compiler
* java.management
* jdk.internal.jvmstat/sun.jvmstat.monitor
* @run testng DynLibsTest
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI DynLibsTest
*/
public class DynLibsTest {
public void run(CommandExecutor executor) {
OutputAnalyzer output = executor.execute("VM.dynlibs");
output.shouldContain(Platform.buildSharedLibraryName("jvm"));
output.shouldContain(Platform.buildSharedLibraryName("java"));
output.shouldContain(Platform.buildSharedLibraryName("management"));
if (WhiteBox.getWhiteBox().isStatic()) {
// On static JDK, JDK/VM native libraries are statically
// linked with the launcher. There is no separate mapping
// for libjvm, libjava, etc.
output.shouldContain("java");
output.shouldNotContain(Platform.buildSharedLibraryName("jvm"));
output.shouldNotContain(Platform.buildSharedLibraryName("java"));
output.shouldNotContain(Platform.buildSharedLibraryName("management"));
} else {
output.shouldContain(Platform.buildSharedLibraryName("jvm"));
output.shouldContain(Platform.buildSharedLibraryName("java"));
output.shouldContain(Platform.buildSharedLibraryName("management"));
}
}
@Test

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Red Hat, Inc. and/or its affiliates.
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2025, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -40,7 +40,9 @@ import java.util.regex.Pattern;
* java.compiler
* java.management
* jdk.internal.jvmstat/sun.jvmstat.monitor
* @run testng/othervm -XX:+UsePerfData SystemDumpMapTest
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UsePerfData SystemDumpMapTest
*/
public class SystemDumpMapTest extends SystemMapTestBase {

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Red Hat, Inc. and/or its affiliates.
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2025, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -36,7 +36,9 @@ import jdk.test.lib.process.OutputAnalyzer;
* java.compiler
* java.management
* jdk.internal.jvmstat/sun.jvmstat.monitor
* @run testng/othervm -XX:+UsePerfData SystemMapTest
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UsePerfData SystemMapTest
*/
/*
@ -49,7 +51,9 @@ import jdk.test.lib.process.OutputAnalyzer;
* java.compiler
* java.management
* jdk.internal.jvmstat/sun.jvmstat.monitor
* @run testng/othervm -XX:+UsePerfData -XX:+UseZGC SystemMapTest
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run testng/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UsePerfData -XX:+UseZGC SystemMapTest
*/
public class SystemMapTest extends SystemMapTestBase {
public void run(CommandExecutor executor) {

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, Red Hat, Inc. and/or its affiliates.
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2025, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,6 +23,8 @@
*/
import jdk.test.lib.Platform;
import jdk.test.lib.StringArrayUtils;
import jdk.test.whitebox.WhiteBox;
public class SystemMapTestBase {
@ -82,14 +84,17 @@ public class SystemMapTestBase {
static final String shouldMatchUnconditionally_linux[] = {
// java launcher
regexBase_committed + "/bin/java",
// libjvm
regexBase_committed + "/lib/.*/libjvm.so",
// heap segment, should be part of all user space apps on all architectures OpenJDK supports.
regexBase_committed + "\\[heap\\]",
// we should see the hs-perf data file, and it should appear as shared as well as committed
regexBase_shared_and_committed + "hsperfdata_.*"
};
static final String shouldMatch_linux_libjvm[] = {
// libjvm
regexBase_committed + "/lib/.*/libjvm.so"
};
static final String shouldMatchIfNMTIsEnabled_linux[] = {
regexBase_java_heap + "JAVAHEAP.*",
// metaspace
@ -103,7 +108,14 @@ public class SystemMapTestBase {
};
public String[] shouldMatchUnconditionally() {
return shouldMatchUnconditionally_linux;
if (WhiteBox.getWhiteBox().isStatic()) {
// On static JDK, libjvm is statically linked with the 'java'
// launcher. There is no separate mapping for libjvm.
return shouldMatchUnconditionally_linux;
} else {
return StringArrayUtils.concat(shouldMatchUnconditionally_linux,
shouldMatch_linux_libjvm);
}
}
public String[] shouldMatchIfNMTIsEnabled() {
@ -125,6 +137,9 @@ public class SystemMapTestBase {
static final String shouldMatchUnconditionally_windows[] = {
// java launcher
winimage + ".*[\\/\\\\]bin[\\/\\\\]java[.]exe",
};
static final String shouldMatch_windows_libjvm[] = {
// libjvm
winimage + ".*[\\/\\\\]bin[\\/\\\\].*[\\/\\\\]jvm.dll"
};
@ -142,7 +157,14 @@ public class SystemMapTestBase {
};
public String[] shouldMatchUnconditionally() {
return shouldMatchUnconditionally_windows;
if (WhiteBox.getWhiteBox().isStatic()) {
// On static JDK, libjvm is statically linked with the 'java'
// launcher. There is no separate mapping for libjvm.
return shouldMatchUnconditionally_windows;
} else {
return StringArrayUtils.concat(shouldMatchUnconditionally_windows,
shouldMatch_windows_libjvm);
}
}
public String[] shouldMatchIfNMTIsEnabled() {
@ -165,12 +187,15 @@ public class SystemMapTestBase {
static final String shouldMatchUnconditionally_macOS[] = {
// java launcher
macOSbase + macow + space + someNumber + space + "/.*/bin/java",
// libjvm
macOSbase + macow + space + someNumber + space + "/.*/lib/server/libjvm.dylib",
// we should see the hs-perf data file, and it should appear as shared as well as committed
macOSbase + macprivate + space + someNumber + space + ".*/.*/hsperfdata_.*"
};
static final String shouldMatch_macOS_libjvm[] = {
// libjvm
macOSbase + macow + space + someNumber + space + "/.*/lib/server/libjvm.dylib",
};
static final String shouldMatchIfNMTIsEnabled_macOS[] = {
// heap is private with G1GC, shared with ZGC
macOSbase + macprivate_or_shared + space + someNumber + space + "JAVAHEAP.*",
@ -183,7 +208,14 @@ public class SystemMapTestBase {
};
public String[] shouldMatchUnconditionally() {
return shouldMatchUnconditionally_macOS;
if (WhiteBox.getWhiteBox().isStatic()) {
// On static JDK, libjvm is statically linked with the 'java'
// launcher. There is no separate mapping for libjvm.
return shouldMatchUnconditionally_macOS;
} else {
return StringArrayUtils.concat(shouldMatchUnconditionally_macOS,
shouldMatch_macOS_libjvm);
}
}
public String[] shouldMatchIfNMTIsEnabled() {