8281822: Test failures on non-DTrace builds due to incomplete DTrace* flags handling
Reviewed-by: dholmes, kvn
This commit is contained in:
parent
980d187891
commit
847a99b53d
@ -2064,6 +2064,14 @@ WB_ENTRY(jboolean, WB_IsJFRIncluded(JNIEnv* env))
|
||||
#endif // INCLUDE_JFR
|
||||
WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_IsDTraceIncluded(JNIEnv* env))
|
||||
#if defined(DTRACE_ENABLED)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif // DTRACE_ENABLED
|
||||
WB_END
|
||||
|
||||
#if INCLUDE_CDS
|
||||
|
||||
WB_ENTRY(jint, WB_GetCDSOffsetForName(JNIEnv* env, jobject o, jstring name))
|
||||
@ -2709,6 +2717,7 @@ static JNINativeMethod methods[] = {
|
||||
{CC"areOpenArchiveHeapObjectsMapped", CC"()Z", (void*)&WB_AreOpenArchiveHeapObjectsMapped},
|
||||
{CC"isCDSIncluded", CC"()Z", (void*)&WB_IsCDSIncluded },
|
||||
{CC"isJFRIncluded", CC"()Z", (void*)&WB_IsJFRIncluded },
|
||||
{CC"isDTraceIncluded", CC"()Z", (void*)&WB_IsDTraceIncluded },
|
||||
{CC"isC2OrJVMCIIncluded", CC"()Z", (void*)&WB_isC2OrJVMCIIncluded },
|
||||
{CC"isJVMCISupportedByGC", CC"()Z", (void*)&WB_IsJVMCISupportedByGC},
|
||||
{CC"canWriteJavaHeapArchive", CC"()Z", (void*)&WB_CanWriteJavaHeapArchive },
|
||||
|
@ -2906,6 +2906,18 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
|
||||
jio_fprintf(defaultStream::error_stream(),
|
||||
"ExtendedDTraceProbes flag is not applicable for this configuration\n");
|
||||
return JNI_EINVAL;
|
||||
} else if (match_option(option, "-XX:+DTraceMethodProbes")) {
|
||||
jio_fprintf(defaultStream::error_stream(),
|
||||
"DTraceMethodProbes flag is not applicable for this configuration\n");
|
||||
return JNI_EINVAL;
|
||||
} else if (match_option(option, "-XX:+DTraceAllocProbes")) {
|
||||
jio_fprintf(defaultStream::error_stream(),
|
||||
"DTraceAllocProbes flag is not applicable for this configuration\n");
|
||||
return JNI_EINVAL;
|
||||
} else if (match_option(option, "-XX:+DTraceMonitorProbes")) {
|
||||
jio_fprintf(defaultStream::error_stream(),
|
||||
"DTraceMonitorProbes flag is not applicable for this configuration\n");
|
||||
return JNI_EINVAL;
|
||||
#endif // defined(DTRACE_ENABLED)
|
||||
#ifdef ASSERT
|
||||
} else if (match_option(option, "-XX:+FullGCALot")) {
|
||||
|
@ -63,6 +63,7 @@ requires.properties= \
|
||||
vm.debug \
|
||||
vm.hasSA \
|
||||
vm.hasJFR \
|
||||
vm.hasDTrace \
|
||||
vm.rtm.cpu \
|
||||
vm.rtm.compiler \
|
||||
vm.cds \
|
||||
|
@ -22,11 +22,29 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @test id=with-dtrace
|
||||
* @requires vm.debug
|
||||
* @requires vm.hasDTrace
|
||||
* @bug 8168712
|
||||
*
|
||||
* @run main/othervm -XX:CompileCommand=compileonly,Test8168712.*
|
||||
* -XX:CompileCommand=compileonly,*Object.*
|
||||
* -XX:+DTraceMethodProbes
|
||||
* -XX:-UseOnStackReplacement
|
||||
* -XX:+DeoptimizeRandom
|
||||
* compiler.runtime.Test8168712
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test id=without-dtrace
|
||||
* @requires vm.debug
|
||||
* @bug 8168712
|
||||
*
|
||||
* @run main/othervm -XX:CompileCommand=compileonly,Test8168712.* -XX:CompileCommand=compileonly,*Object.* -XX:+DTraceMethodProbes -XX:-UseOnStackReplacement -XX:+DeoptimizeRandom compiler.runtime.Test8168712
|
||||
* @run main/othervm -XX:CompileCommand=compileonly,Test8168712.*
|
||||
* -XX:CompileCommand=compileonly,*Object.*
|
||||
* -XX:-UseOnStackReplacement
|
||||
* -XX:+DeoptimizeRandom
|
||||
* compiler.runtime.Test8168712
|
||||
*/
|
||||
package compiler.runtime;
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
* @summary Test SDT probes available on GNU/Linux when DTRACE_ENABLED
|
||||
* @requires os.family == "linux"
|
||||
* @requires vm.flagless
|
||||
* @requires vm.hasDTrace
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run driver SDTProbesGNULinuxTest
|
||||
@ -36,7 +37,6 @@
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jtreg.SkippedException;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@ -44,19 +44,7 @@ import java.nio.file.Paths;
|
||||
|
||||
public class SDTProbesGNULinuxTest {
|
||||
public static void main(String[] args) throws Throwable {
|
||||
{
|
||||
var pb = ProcessTools.createJavaProcessBuilder(
|
||||
"-XX:+DTraceMethodProbes",
|
||||
"-XX:+DTraceAllocProbes",
|
||||
"-XX:+DTraceMonitorProbes",
|
||||
"-version");
|
||||
var oa = new OutputAnalyzer(pb.start());
|
||||
// This test only matters when build with DTRACE_ENABLED.
|
||||
if (oa.getExitValue() != 0) {
|
||||
throw new SkippedException("Not build using DTRACE_ENABLED");
|
||||
}
|
||||
}
|
||||
|
||||
// This test only matters when build with DTRACE_ENABLED.
|
||||
try (var libjvms = Files.walk(Paths.get(Utils.TEST_JDK))) {
|
||||
libjvms.filter(p -> "libjvm.so".equals(p.getFileName().toString()))
|
||||
.map(Path::toAbsolutePath)
|
||||
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Red Hat, Inc. 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test id=enabled
|
||||
* @bug 8281822
|
||||
* @summary Test DTrace options are accepted on suitable builds
|
||||
* @requires vm.flagless
|
||||
* @requires vm.hasDTrace
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run driver DTraceOptionsTest true
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test id=disabled
|
||||
* @bug 8281822
|
||||
* @summary Test DTrace options are rejected on unsuitable builds
|
||||
* @requires vm.flagless
|
||||
* @requires !vm.hasDTrace
|
||||
*
|
||||
* @library /test/lib
|
||||
* @run driver DTraceOptionsTest disabled
|
||||
*/
|
||||
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
public class DTraceOptionsTest {
|
||||
public static void main(String[] args) throws Throwable {
|
||||
boolean dtraceEnabled;
|
||||
if (args.length > 0) {
|
||||
dtraceEnabled = Boolean.parseBoolean(args[0]);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Should provide the argument");
|
||||
}
|
||||
|
||||
String[] options = {
|
||||
"ExtendedDTraceProbes",
|
||||
"DTraceMethodProbes",
|
||||
"DTraceAllocProbes",
|
||||
"DTraceMonitorProbes",
|
||||
};
|
||||
|
||||
for (String opt : options) {
|
||||
var pb = ProcessTools.createJavaProcessBuilder("-XX:+" + opt, "-version");
|
||||
var oa = new OutputAnalyzer(pb.start());
|
||||
if (dtraceEnabled) {
|
||||
oa.shouldHaveExitValue(0);
|
||||
} else {
|
||||
oa.shouldNotHaveExitValue(0);
|
||||
oa.shouldContain(opt + " flag is not applicable for this configuration");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -102,6 +102,7 @@ public class VMProps implements Callable<Map<String, String>> {
|
||||
// vm.hasJFR is "true" if JFR is included in the build of the VM and
|
||||
// so tests can be executed.
|
||||
map.put("vm.hasJFR", this::vmHasJFR);
|
||||
map.put("vm.hasDTrace", this::vmHasDTrace);
|
||||
map.put("vm.jvmti", this::vmHasJVMTI);
|
||||
map.put("vm.cpu.features", this::cpuFeatures);
|
||||
map.put("vm.pageSize", this::vmPageSize);
|
||||
@ -368,6 +369,13 @@ public class VMProps implements Callable<Map<String, String>> {
|
||||
return "" + WB.isJVMTIIncluded();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return "true" if the VM is compiled with DTrace
|
||||
*/
|
||||
protected String vmHasDTrace() {
|
||||
return "" + WB.isDTraceIncluded();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if compiler in use supports RTM and false otherwise.
|
||||
*/
|
||||
|
@ -634,6 +634,7 @@ public class WhiteBox {
|
||||
public native boolean isSharedInternedString(String s);
|
||||
public native boolean isCDSIncluded();
|
||||
public native boolean isJFRIncluded();
|
||||
public native boolean isDTraceIncluded();
|
||||
public native boolean canWriteJavaHeapArchive();
|
||||
public native Object getResolvedReferences(Class<?> c);
|
||||
public native void linkClass(Class<?> c);
|
||||
|
@ -635,6 +635,7 @@ public class WhiteBox {
|
||||
public native boolean isSharedInternedString(String s);
|
||||
public native boolean isCDSIncluded();
|
||||
public native boolean isJFRIncluded();
|
||||
public native boolean isDTraceIncluded();
|
||||
public native boolean canWriteJavaHeapArchive();
|
||||
public native Object getResolvedReferences(Class<?> c);
|
||||
public native void linkClass(Class<?> c);
|
||||
|
Loading…
x
Reference in New Issue
Block a user