Skip to content
Permalink
Browse files

8244385: various clean-ups in runtime tests

Reviewed-by: minqi
  • Loading branch information
iignatev committed May 5, 2020
1 parent 5ac7556 commit c976be69c3b39de6e3a58c2a7f5771c73e40bc51
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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
@@ -30,6 +30,7 @@
import static jdk.test.lib.process.ProcessTools.createJavaProcessBuilder;
import static jdk.test.lib.Platform.isWindows;
import jdk.test.lib.Utils;
import jtreg.SkippedException;

import java.io.BufferedReader;
import java.io.File;
@@ -50,6 +51,7 @@
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @run driver TestInheritFD
*/

/**
@@ -83,9 +85,7 @@ public static void main(String[] args) throws Exception {
File commFile = Utils.createTempFile("communication", ".txt").toFile();

if (!isWindows() && !lsofCommand().isPresent()) {
System.out.println("Could not find lsof like command");
System.out.println("Exit test case as successful though it could not verify anything");
return;
throw new SkippedException("Could not find lsof like command");
}

ProcessBuilder pb = createJavaProcessBuilder(
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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
@@ -64,12 +64,14 @@ public static void main(String args[]) throws Throwable {
"-cp", "." + File.pathSeparator + System.getProperty("test.classes"), "PVTest");
oa = new OutputAnalyzer(pb.start());
oa.shouldContain("Hi!");
oa.shouldHaveExitValue(0);

// Test -Xlog:class+preview
pb = ProcessTools.createJavaProcessBuilder("--enable-preview", "-Xlog:class+preview",
"-cp", "." + File.pathSeparator + System.getProperty("test.classes"), "PVTest");
oa = new OutputAnalyzer(pb.start());
oa.shouldContain("[info][class,preview] Loading class PVTest that depends on preview features");
oa.shouldHaveExitValue(0);

// Subtract 1 from class's major version. The class should fail to load
// because its major_version does not match the JVM current version.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, 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
@@ -29,9 +29,9 @@
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @run main CompressedClassSpaceSize
* @run driver CompressedClassSpaceSize
*/
import jdk.test.lib.Platform;

import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;

@@ -40,71 +40,62 @@
public static void main(String[] args) throws Exception {
ProcessBuilder pb;
OutputAnalyzer output;
if (Platform.is64bit()) {
// Minimum size is 1MB
pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=0",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("outside the allowed range")
.shouldHaveExitValue(1);
// Minimum size is 1MB
pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=0",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("outside the allowed range")
.shouldHaveExitValue(1);

// Invalid size of -1 should be handled correctly
pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=-1",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Improperly specified VM option 'CompressedClassSpaceSize=-1'")
.shouldHaveExitValue(1);
// Invalid size of -1 should be handled correctly
pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=-1",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Improperly specified VM option 'CompressedClassSpaceSize=-1'")
.shouldHaveExitValue(1);


// Maximum size is 3GB
pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=4g",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("outside the allowed range")
.shouldHaveExitValue(1);
// Maximum size is 3GB
pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=4g",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("outside the allowed range")
.shouldHaveExitValue(1);


// Make sure the minimum size is set correctly and printed
pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
"-XX:CompressedClassSpaceSize=1m",
"-Xlog:gc+metaspace=trace",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Compressed class space size: 1048576")
.shouldHaveExitValue(0);
// Make sure the minimum size is set correctly and printed
pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
"-XX:CompressedClassSpaceSize=1m",
"-Xlog:gc+metaspace=trace",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Compressed class space size: 1048576")
.shouldHaveExitValue(0);


// Make sure the maximum size is set correctly and printed
pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
"-XX:CompressedClassSpaceSize=3g",
"-Xlog:gc+metaspace=trace",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Compressed class space size: 3221225472")
.shouldHaveExitValue(0);
// Make sure the maximum size is set correctly and printed
pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
"-XX:CompressedClassSpaceSize=3g",
"-Xlog:gc+metaspace=trace",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Compressed class space size: 3221225472")
.shouldHaveExitValue(0);


pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedOops",
"-XX:CompressedClassSpaceSize=1m",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used")
.shouldHaveExitValue(0);
pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedOops",
"-XX:CompressedClassSpaceSize=1m",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used")
.shouldHaveExitValue(0);


pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedClassPointers",
"-XX:CompressedClassSpaceSize=1m",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used")
.shouldHaveExitValue(0);
} else {
// 32bit platforms doesn't have compressed oops
pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=1m",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used")
.shouldHaveExitValue(0);
}
pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedClassPointers",
"-XX:CompressedClassSpaceSize=1m",
"-version");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used")
.shouldHaveExitValue(0);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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
@@ -27,7 +27,6 @@
import java.io.InputStreamReader;
import java.util.regex.Pattern;

import jdk.test.lib.Platform;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;

@@ -36,16 +35,15 @@
* @bug 8194652
* @summary Printing native stack shows an "error occurred during error reporting".
* @modules java.base/jdk.internal.misc
* @requires vm.debug
* @requires vm.flavor != "zero"
* @library /test/lib
* @run driver BadNativeStackInErrorHandlingTest
*/

// This test was adapted from SafeFetchInErrorHandlingTest.java.
public class BadNativeStackInErrorHandlingTest {
public static void main(String[] args) throws Exception {
if (!Platform.isDebugBuild() || Platform.isZero()) {
return;
}

ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-XX:+UnlockDiagnosticVMOptions",
"-Xmx100M",
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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
@@ -44,13 +44,16 @@ public static void main(String[] args) {
}

public static void main(String[] args) throws Exception {
runTest("-XX:-CreateCoredumpOnCrash").shouldContain("CreateCoredumpOnCrash turned off, no core file dumped");
runTest("-XX:-CreateCoredumpOnCrash").shouldContain("CreateCoredumpOnCrash turned off, no core file dumped")
.shouldNotHaveExitValue(0);

if (Platform.isWindows()) {
// The old CreateMinidumpOnCrash option should still work
runTest("-XX:-CreateMinidumpOnCrash").shouldContain("CreateCoredumpOnCrash turned off, no core file dumped");
runTest("-XX:-CreateMinidumpOnCrash").shouldContain("CreateCoredumpOnCrash turned off, no core file dumped")
.shouldNotHaveExitValue(0);
} else {
runTest("-XX:+CreateCoredumpOnCrash").shouldNotContain("CreateCoredumpOnCrash turned off, no core file dumped");
runTest("-XX:+CreateCoredumpOnCrash").shouldNotContain("CreateCoredumpOnCrash turned off, no core file dumped")
.shouldNotHaveExitValue(0);
}

}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@@ -25,11 +25,11 @@
* @test
* @bug 8184765
* @summary make sure the SystemDictionary gets resized when load factor is too high
* @requires vm.debug
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @compile TriggerResize.java
* @requires (vm.debug == true)
* @run driver TestResize
*/

@@ -112,16 +112,14 @@ static void analyzeOutputOn(ProcessBuilder pb) throws Exception {
}

public static void main(String[] args) throws Exception {
if (Platform.isDebugBuild()) {
// -XX:+PrintSystemDictionaryAtExit will print the details of system dictionary,
// that will allow us to calculate the table's load factor.
// -Xlog:safepoint+cleanup will print out cleanup details at safepoint
// that will allow us to detect if the system dictionary resized.
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintSystemDictionaryAtExit",
"-Xlog:safepoint+cleanup",
"TriggerResize",
"50000");
analyzeOutputOn(pb);
}
// -XX:+PrintSystemDictionaryAtExit will print the details of system dictionary,
// that will allow us to calculate the table's load factor.
// -Xlog:safepoint+cleanup will print out cleanup details at safepoint
// that will allow us to detect if the system dictionary resized.
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintSystemDictionaryAtExit",
"-Xlog:safepoint+cleanup",
"TriggerResize",
"50000");
analyzeOutputOn(pb);
}
}
}
@@ -25,36 +25,37 @@
* @test
* @bug 8047290
* @summary Ensure that a Monitor::lock_without_safepoint_check fires an assert when it incorrectly acquires a lock which must always have safepoint checks.
* @requires vm.debug
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @build sun.hotspot.WhiteBox
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
* @run main AssertSafepointCheckConsistency1
* @run driver AssertSafepointCheckConsistency1
*/

import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Platform;

import sun.hotspot.WhiteBox;

public class AssertSafepointCheckConsistency1 {
public static void main(String args[]) throws Exception {
if (args.length > 0) {
WhiteBox.getWhiteBox().assertMatchingSafepointCalls(true, true);
return;
}
if (Platform.isDebugBuild()){
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xbootclasspath/a:.",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-XX:-CreateCoredumpOnCrash",
"-Xmx128m",
"AssertSafepointCheckConsistency1",
"test");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("assert").shouldContain("always");
}
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xbootclasspath/a:.",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-XX:-CreateCoredumpOnCrash",
"-Xmx128m",
"AssertSafepointCheckConsistency1",
"test");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("assert")
.shouldContain("always")
.shouldNotHaveExitValue(0);
}
}

0 comments on commit c976be6

Please sign in to comment.