Here are the examples of the java api jdk.test.lib.process.OutputAnalyzer.getStdout() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
53 Examples
18
Source : TestUseCompressedOopsErgoTools.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static long getMaxHeapForCompressedOops(String[] vmargs) throws Exception {
Outputreplacedyzer output = runWhiteBoxTest(vmargs, DetermineMaxHeapForCompressedOops.clreplaced.getName(), new String[] {}, false);
return Long.parseLong(output.getStdout());
}
16
Source : CommandExecutor.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
/**
* Execute a diagnostic command
*
* @param cmd The diagnostic command to execute
* @param silent Do not print the command output
* @return an {@link jdk.testlibrary.Outputreplacedyzer} encapsulating the output of the command
* @throws CommandExecutorException if there is an exception on the "calling side" while trying to execute the
* Diagnostic Command. Exceptions thrown on the remote side are available as textual representations in
* stderr, regardless of the specific executor used.
*/
public final Outputreplacedyzer execute(String cmd, boolean silent) throws CommandExecutorException {
if (!silent) {
System.out.printf("Running DCMD '%s' through '%s'%n", cmd, this.getClreplaced().getSimpleName());
}
Outputreplacedyzer oa = executeImpl(cmd);
if (!silent) {
System.out.println("---------------- stdout ----------------");
System.out.println(oa.getStdout());
System.out.println("---------------- stderr ----------------");
System.out.println(oa.getStderr());
System.out.println("----------------------------------------");
System.out.println();
}
return oa;
}
16
Source : CDSTestUtils.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
// ============================= Logging
public static Outputreplacedyzer executeAndLog(ProcessBuilder pb, String logName) throws Exception {
long started = System.currentTimeMillis();
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
writeFile(getOutputFile(logName + ".stdout"), output.getStdout());
writeFile(getOutputFile(logName + ".stderr"), output.getStderr());
System.out.println("[ELAPSED: " + (System.currentTimeMillis() - started) + " ms]");
System.out.println("[STDERR]\n" + output.getStderr());
if (CopyChildStdoutToMainStdout)
System.out.println("[STDOUT]\n" + output.getStdout());
return output;
}
16
Source : CDSTestUtils.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
// This method should be used to check the output of child VM for common exceptions.
// Most of CDS tests deal with child VM processes for creating and using the archive.
// However exceptions that occur in the child process do not automatically propagate
// to the parent process. This mechanism aims to improve the propagation
// of exceptions and common errors.
// Exception e argument - an exception to be re-thrown if none of the common
// exceptions match. Preplaced null if you wish not to re-throw any exception.
public static boolean checkCommonExecExceptions(Outputreplacedyzer output, Exception e) throws Exception {
if (output.getStdout().contains("http://bugreport.java.com/bugreport/crash.jsp")) {
throw new RuntimeException("Hotspot crashed");
}
if (output.getStdout().contains("TEST FAILED")) {
throw new RuntimeException("Test Failed");
}
if (output.getOutput().contains("shared clreplaced paths mismatch")) {
// throw new RuntimeException("shared clreplaced paths mismatch");
}
if (output.getOutput().contains("Unable to unmap shared space")) {
throw new RuntimeException("Unable to unmap shared space");
}
// Special case -- sometimes Xshare:on fails because it failed to map
// at given address. This behavior is platform-specific, machine config-specific
// and can be random (see ASLR).
if (isUnableToMap(output)) {
System.out.println(UnableToMapMsg);
return true;
}
if (e != null) {
throw e;
}
return false;
}
16
Source : CDSTestUtils.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
// This method should be used to check the output of child VM for common exceptions.
// Most of CDS tests deal with child VM processes for creating and using the archive.
// However exceptions that occur in the child process do not automatically propagate
// to the parent process. This mechanism aims to improve the propagation
// of exceptions and common errors.
// Exception e argument - an exception to be re-thrown if none of the common
// exceptions match. Preplaced null if you wish not to re-throw any exception.
public static void checkCommonExecExceptions(Outputreplacedyzer output, Exception e) throws Exception {
if (output.getStdout().contains("http://bugreport.java.com/bugreport/crash.jsp")) {
throw new RuntimeException("Hotspot crashed");
}
if (output.getStdout().contains("TEST FAILED")) {
throw new RuntimeException("Test Failed");
}
if (output.getOutput().contains("shared clreplaced paths mismatch")) {
throw new RuntimeException("shared clreplaced paths mismatch");
}
if (output.getOutput().contains("Unable to unmap shared space")) {
throw new RuntimeException("Unable to unmap shared space");
}
// Special case -- sometimes Xshare:on fails because it failed to map
// at given address. This behavior is platform-specific, machine config-specific
// and can be random (see ASLR).
if (isUnableToMap(output)) {
System.out.println(UnableToMapMsg);
return;
}
if (e != null)
throw e;
}
16
Source : JVMOptionsUtils.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
static void printOutputContent(Outputreplacedyzer output) {
System.err.println(String.format("stdout content[%s]", output.getStdout()));
System.err.println(String.format("stderr content[%s]%n", output.getStderr()));
}
16
Source : TestUseCompressedOopsErgoTools.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static String expect(String[] flags, boolean hasWarning, boolean hasError, int errorcode) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flags);
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
output.shouldHaveExitValue(errorcode);
return output.getStdout();
}
16
Source : TestParallelGCThreads.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static long getParallelGCThreadCount(String[] flags) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flags);
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
output.shouldHaveExitValue(0);
String stdout = output.getStdout();
return FlagsValue.getFlagLongValue("ParallelGCThreads", stdout);
}
16
Source : TestObjectTenuringFlags.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static void runTenuringFlagsConsistencyTest(String[] tenuringFlags, boolean shouldFail, ExpectedTenuringFlags expectedFlags) throws Exception {
List<String> vmOpts = new ArrayList<>();
if (tenuringFlags.length > 0) {
Collections.addAll(vmOpts, tenuringFlags);
}
Collections.addAll(vmOpts, "-XX:+UseParallelGC", "-XX:+PrintFlagsFinal", "-version");
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
if (shouldFail) {
output.shouldHaveExitValue(1);
} else {
output.shouldHaveExitValue(0);
String stdout = output.getStdout();
checkTenuringFlagsConsistency(stdout, expectedFlags);
}
}
16
Source : TestMaxHeapSizeTools.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static void getNewOldSize(String gcflag, long[] values) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(gcflag, "-XX:+PrintFlagsFinal", "-version");
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
output.shouldHaveExitValue(0);
String stdout = output.getStdout();
values[0] = getFlagValue(" NewSize", stdout);
values[1] = getFlagValue(" OldSize", stdout);
}
16
Source : TestG1ConcRefinementThreads.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static void runG1ConcRefinementThreadsTest(String[] preplacededOpts, int expectedValue) throws Exception {
List<String> vmOpts = new ArrayList<>();
if (preplacededOpts.length > 0) {
Collections.addAll(vmOpts, preplacededOpts);
}
Collections.addAll(vmOpts, "-XX:+UseG1GC", "-XX:+PrintFlagsFinal", "-version");
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
output.shouldHaveExitValue(0);
String stdout = output.getStdout();
checkG1ConcRefinementThreadsConsistency(stdout, expectedValue);
}
16
Source : SpaceUtilizationCheck.java
with GNU General Public License v2.0
from AdoptOpenJDK
with GNU General Public License v2.0
from AdoptOpenJDK
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./SpaceUtilizationCheck.jsa", "-Xshare:dump");
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
String stdout = output.getStdout();
ArrayList<String> utilization = findUtilization(stdout);
if (utilization.size() != NUMBER_OF_CHECKED_SHARED_REGIONS)
throw new RuntimeException("The output format of sharing summary has changed");
for (String str : utilization) {
int value = Integer.parseInt(str);
if (value < MIN_UTILIZATION) {
System.out.println(stdout);
throw new RuntimeException("Utilization for one of the regions" + "is below a threshold of " + MIN_UTILIZATION + "%");
}
}
}
15
Source : FindTest.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private void replacedertOutputEquals(List<String> actual, Outputreplacedyzer expected) throws IOException {
List<String> expectedList = Arrays.asList(expected.getStdout().split(System.lineSeparator()));
replacedertEquals(actual.size(), expectedList.size());
replacedertTrue(actual.removeAll(expectedList));
}
15
Source : CtwTest.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
protected void dump(Outputreplacedyzer output, String name) {
try (Writer w = new FileWriter(name + ".out")) {
String s = output.getStdout();
w.write(s, s.length(), 0);
} catch (IOException io) {
io.printStackTrace();
}
try (Writer w = new FileWriter(name + ".err")) {
String s = output.getStderr();
w.write(s, s.length(), 0);
} catch (IOException io) {
io.printStackTrace();
}
}
15
Source : TestNumWorkerOutput.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static void runTest(String gcArg) throws Exception {
final String[] arguments = { "-Xbootclreplacedpath/a:.", "-XX:+UnlockExperimentalVMOptions", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:+" + gcArg, "-Xmx10M", "-XX:+PrintGCDetails", GCTest.clreplaced.getName() };
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments);
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
output.shouldHaveExitValue(0);
System.out.println(output.getStdout());
String stdout = output.getStdout();
checkPatternOnce(".*[info.*].*[gc,task.*].*GC\\(0\\) .*Using \\d+ workers of \\d+ for evacuation.*", stdout);
}
15
Source : TestAgeOutput.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static void runTest(String gcArg) throws Exception {
final String[] arguments = { "-Xbootclreplacedpath/a:.", "-XX:+UnlockExperimentalVMOptions", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:+" + gcArg, "-Xmx10M", "-Xlog:gc+age=trace", GCTest.clreplaced.getName() };
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments);
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
output.shouldHaveExitValue(0);
System.out.println(output.getStdout());
String stdout = output.getStdout();
checkPattern(".*GC\\(0\\) .*Desired survivor size.*", stdout);
checkPattern(".*GC\\(0\\) .*Age table with threshold.*", stdout);
checkPattern(".*GC\\(0\\) .*- age 1:.*", stdout);
}
15
Source : TestLogging.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static void test(String vmFlag) throws Exception {
System.out.println(String.format("%s: running with %s flag", TestLogging.clreplaced.getSimpleName(), vmFlag));
Outputreplacedyzer output = spawnMixedGCProvoker(vmFlag);
System.out.println(output.getStdout());
output.shouldHaveExitValue(0);
output.shouldContain("Pause Mixed (G1 Evacuation Pause)");
}
15
Source : TestMaxHeapSizeTools.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static void getMinInitialMaxHeap(String[] args, MinInitialMaxValues val) throws Exception {
Outputreplacedyzer output = runWhiteBoxTest(args, ErgoArgsPrinter.clreplaced.getName(), new String[] {}, false);
// the output we watch for has the following format:
//
// "Minimum heap X Initial heap Y Maximum heap Z Min alignment A Max Alignment B"
//
// where A, B, X, Y and Z are sizes in bytes.
// Unfortunately there is no other way to retrieve the minimum heap size and
// the alignments.
Matcher m = Pattern.compile("Minimum heap \\d+ Initial heap \\d+ Maximum heap \\d+ Space alignment \\d+ Heap alignment \\d+").matcher(output.getStdout());
if (!m.find()) {
throw new RuntimeException("Could not find heap size string.");
}
String match = m.group();
// actual values
val.minHeapSize = valueAfter(match, "Minimum heap ");
val.initialHeapSize = valueAfter(match, "Initial heap ");
val.maxHeapSize = valueAfter(match, "Maximum heap ");
val.spaceAlignment = valueAfter(match, "Space alignment ");
val.heapAlignment = valueAfter(match, "Heap alignment ");
}
15
Source : TestG1ConcMarkStepDurationMillis.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static void runG1ConcMarkStepDurationMillisTest(String expectedValue, int expectedResult) throws Exception {
List<String> vmOpts = new ArrayList<>();
Collections.addAll(vmOpts, "-XX:+UseG1GC", "-XX:G1ConcMarkStepDurationMillis=" + expectedValue, "-XX:+PrintFlagsFinal", "-version");
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
output.shouldHaveExitValue(expectedResult == Preplaced ? 0 : 1);
String stdout = output.getStdout();
if (expectedResult == Preplaced) {
checkG1ConcMarkStepDurationMillisConsistency(stdout, expectedValue);
} else if (expectedResult == FAIL_IMPROPER_VALUE) {
output.shouldContain("Improperly specified VM option");
} else if (expectedResult == FAIL_OUT_RANGE) {
output.shouldContain("outside the allowed range");
}
}
15
Source : BMITestRunner.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
/**
* Dump stdout and stderr of test process to <i>prefix</i>.test.out
* and <i>prefix</i>.test.err respectively.
*
* @param outputreplacedyzer Outputreplacedyzer whom output should be dumped
* @param prefix Prefix that will be used in file names.
* @throws IOException if unable to dump output to file.
*/
protected static void dumpOutput(Outputreplacedyzer outputreplacedyzer, String prefix) throws IOException {
Files.write(Paths.get(prefix + ".test.out"), outputreplacedyzer.getStdout().getBytes());
Files.write(Paths.get(prefix + ".test.err"), outputreplacedyzer.getStderr().getBytes());
}
15
Source : BMITestRunner.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
/**
* Execute all methods implemented by <b>expr</b> in int and comp modes
* and compare output.
* Test preplaced only of output obtained with different VM modes is equal.
* To control behaviour of test following options could be preplaceded:
* <ul>
* <li>-iterations=<N> each operation implemented by
* <b>expr</b> will be executed <i>N</i> times. Default value
* is 4000.</li>
* <li>-seed=<SEED> arguments for <b>expr</b>'s methods
* obtained via RNG initiated with seed <i>SEED</i>. By default
* some random seed will be used.</li>
* </ul>
*
* @param expr operation that should be tested
* @param testOpts options to control test behaviour
* @param additionalVMOpts additional options for VM
*
* @throws Throwable if test failed.
*/
public static void runTests(Clreplaced<? extends Expr> expr, String[] testOpts, String... additionalVMOpts) throws Throwable {
int seed = Utils.getRandomInstance().nextInt();
int iterations = DEFAULT_ITERATIONS_COUNT;
for (String testOption : testOpts) {
if (testOption.startsWith("-iterations=")) {
iterations = Integer.valueOf(testOption.replace("-iterations=", ""));
} else if (testOption.startsWith("-seed=")) {
seed = Integer.valueOf(testOption.replace("-seed=", ""));
}
}
Outputreplacedyzer intOutput = runTest(expr, VMMode.INT, additionalVMOpts, seed, iterations);
Outputreplacedyzer compOutput = runTest(expr, VMMode.COMP, additionalVMOpts, seed, iterations);
dumpOutput(intOutput, "int");
dumpOutput(compOutput, "comp");
replacederts.replacedertStringsEqual(intOutput.getStdout(), compOutput.getStdout(), "Results obtained in -Xint and " + "-Xcomp should be the same.");
}
14
Source : CheckForProperDetailStackTrace.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static boolean stackTraceMatches(String stackTrace, Outputreplacedyzer output) {
Matcher stdoutMatcher = Pattern.compile(stackTrace, Pattern.MULTILINE).matcher(output.getStdout());
Matcher stderrMatcher = Pattern.compile(stackTrace, Pattern.MULTILINE).matcher(output.getStderr());
return (stdoutMatcher.find() || stderrMatcher.find());
}
14
Source : TestStringDeduplicationTools.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static Outputreplacedyzer runTest(String... extraArgs) throws Exception {
String[] defaultArgs = new String[] { "-Xmn" + Xmn + "m", "-Xms" + Xms + "m", "-Xmx" + Xmx + "m", "-XX:+UseG1GC", "-XX:+UnlockDiagnosticVMOptions", "--add-opens=java.base/java.lang=ALL-UNNAMED", // Always verify after GC
"-XX:+VerifyAfterGC" };
ArrayList<String> args = new ArrayList<String>();
args.addAll(Arrays.asList(defaultArgs));
args.addAll(Arrays.asList(extraArgs));
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(new String[args.size()]));
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
System.err.println(output.getStderr());
System.out.println(output.getStdout());
return output;
}
14
Source : TestRemsetLoggingTools.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static String runTest(String[] additionalArgs, int numGCs) throws Exception {
ArrayList<String> finalargs = new ArrayList<String>();
String[] defaultArgs = new String[] { "-Xbootclreplacedpath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-cp", System.getProperty("java.clreplaced.path"), "-XX:+UseG1GC", "-Xmn4m", // -Xint makes the test run faster
"-Xint", "-Xms20m", "-Xmx20m", "-XX:ParallelGCThreads=1", // we don't want the additional GCs due to initial marking
"-XX:InitiatingHeapOccupancyPercent=100", "-XX:+UnlockDiagnosticVMOptions", "-XX:G1HeapRegionSize=1M" };
finalargs.addAll(Arrays.asList(defaultArgs));
if (additionalArgs != null) {
finalargs.addAll(Arrays.asList(additionalArgs));
}
finalargs.add(VerifySummaryOutput.clreplaced.getName());
finalargs.add(String.valueOf(numGCs));
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs.toArray(new String[0]));
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
output.shouldHaveExitValue(0);
String result = output.getStdout();
return result;
}
14
Source : TestPrintRegionRememberedSetInfo.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static String runTest(String arg) throws Exception {
ArrayList<String> finalargs = new ArrayList<String>();
String[] defaultArgs = new String[] { "-XX:+UseG1GC", "-Xmx10m", "-XX:+ExplicitGCInvokesConcurrent", "-XX:+UnlockDiagnosticVMOptions", "-XX:G1HeapRegionSize=1M", "-XX:InitiatingHeapOccupancyPercent=0" };
finalargs.addAll(Arrays.asList(defaultArgs));
finalargs.add(arg);
finalargs.add(RunAndWaitForMarking.clreplaced.getName());
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs.toArray(new String[0]));
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
output.shouldHaveExitValue(0);
String result = output.getStdout();
return result;
}
14
Source : TestUseNUMAInterleaving.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static void main(String[] args) throws Exception {
String[] vmargs = new String[] { "-XX:+UseNUMA", "-XX:+PrintFlagsFinal", "-version" };
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, vmargs);
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
boolean isNUMAEnabled = Boolean.parseBoolean(output.firstMatch(NUMA_FLAG_PATTERN, 1));
if (isNUMAEnabled) {
output.shouldMatch("\\bUseNUMAInterleaving\\b.*?=.*?true");
System.out.println(output.getStdout());
} else {
System.out.println(output.firstMatch(NUMA_FLAG_PATTERN));
System.out.println(output.firstMatch(NUMA_FLAG_PATTERN, 1));
}
}
14
Source : TestG1HeapRegionSize.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static void checkG1HeapRegionSize(String[] flags, int expectedValue, int exitValue) throws Exception {
ArrayList<String> flagList = new ArrayList<String>();
flagList.addAll(Arrays.asList(flags));
flagList.add("-XX:+UseG1GC");
flagList.add("-XX:+PrintFlagsFinal");
flagList.add("-version");
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flagList.toArray(new String[0]));
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
output.shouldHaveExitValue(exitValue);
if (exitValue == 0) {
String stdout = output.getStdout();
int flagValue = getFlagValue("G1HeapRegionSize", stdout);
if (flagValue != expectedValue) {
throw new RuntimeException("Wrong value for G1HeapRegionSize. Expected " + expectedValue + " but got " + flagValue);
}
}
}
13
Source : JInfoTest.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static void clreplacedNameMatch() throws Exception {
System.out.println("#### clreplacedNameMatch ####");
LingeredApp app1 = new JInfoTestLingeredApp();
LingeredApp app2 = new JInfoTestLingeredApp();
try {
ArrayList<String> params = new ArrayList<String>();
LingeredApp.startApp(params, app1);
LingeredApp.startApp(params, app2);
Outputreplacedyzer output = jinfo("JInfoTestLingeredApp");
output.shouldHaveExitValue(0);
// "Runtime Environment" written once per proc
doreplacedentMatch(output.getStdout(), ".*Runtime Environment.*Runtime Environment.*");
} finally {
JInfoTestLingeredApp.stopApp(app1);
JInfoTestLingeredApp.stopApp(app2);
}
}
13
Source : JInfoTest.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static void setFlag() throws Exception {
System.out.println("#### setFlag ####");
LingeredApp app1 = new JInfoTestLingeredApp();
LingeredApp app2 = new JInfoTestLingeredApp();
try {
ArrayList<String> params = new ArrayList<String>();
LingeredApp.startApp(params, app1);
LingeredApp.startApp(params, app2);
Outputreplacedyzer output = jinfo("-flag", "MinHeapFreeRatio=1", "JInfoTestLingeredApp");
output.shouldHaveExitValue(0);
output = jinfo("-flag", "MinHeapFreeRatio", "JInfoTestLingeredApp");
output.shouldHaveExitValue(0);
doreplacedentMatch(output.getStdout(), ".*MinHeapFreeRatio=1.*MinHeapFreeRatio=1.*");
} finally {
JInfoTestLingeredApp.stopApp(app1);
JInfoTestLingeredApp.stopApp(app2);
}
}
13
Source : ReadFromNoaccessArea.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static void main(String[] args) throws Exception {
if (!Platform.is64bit()) {
System.out.println("ReadFromNoaccessArea tests is useful only on 64bit architecture. Preplaceding silently.");
return;
}
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclreplacedpath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:+UseCompressedOops", "-XX:HeapBaseMinAddress=33G", "-XX:-CreateCoredumpOnCrash", "-Xmx32m", DummyClreplacedWithMainTryingToReadFromNoaccessArea.clreplaced.getName());
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
System.out.println("******* Printing stdout for replacedysis in case of failure *******");
System.out.println(output.getStdout());
System.out.println("******* Printing stderr for replacedysis in case of failure *******");
System.out.println(output.getStderr());
System.out.println("***************************************************************");
if (output.getStdout() != null && output.getStdout().contains("WB_ReadFromNoaccessArea method is useless")) {
// Test conditions broken. There is no protected page in ReservedHeapSpace in these cirreplacedstances. Silently preplaceding test.
return;
}
if (Platform.isWindows()) {
output.shouldContain("EXCEPTION_ACCESS_VIOLATION");
} else if (Platform.isOSX()) {
output.shouldContain("SIGBUS");
} else {
output.shouldContain("SIGSEGV");
}
}
13
Source : TestWBGC.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-Xbootclreplacedpath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:MaxTenuringThreshold=1", "-Xlog:gc", GCYoungTest.clreplaced.getName());
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
System.out.println(output.getStdout());
output.shouldHaveExitValue(0);
output.shouldContain("WhiteBox Initiated Young GC");
output.shouldNotContain("Full");
// To be sure that we don't provoke Full GC additionaly to young
}
13
Source : TestShrinkAuxiliaryData.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private void performTest(List<String> opts) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, opts.toArray(new String[opts.size()]));
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
System.out.println(output.getStdout());
System.err.println(output.getStderr());
output.shouldHaveExitValue(0);
}
13
Source : TestRemsetLoggingThreads.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static void runTest(int refinementThreads, int workerThreads) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", "-XX:+UnlockDiagnosticVMOptions", "-Xlog:gc+remset+exit=trace", "-XX:G1ConcRefinementThreads=" + refinementThreads, "-XX:ParallelGCThreads=" + workerThreads, "-version");
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
// a zero in refinement thread numbers indicates that the value in ParallelGCThreads should be used.
// Additionally use at least one thread.
int expectedNumRefinementThreads = refinementThreads;
String pattern = "Concurrent RS threads times \\(s\\)$";
Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout());
if (!m.find()) {
throw new Exception("Could not find correct output for concurrent RS threads times in stdout," + " should match the pattern \"" + pattern + "\", but stdout is \n" + output.getStdout());
}
output.shouldHaveExitValue(0);
}
13
Source : TestMaxNewSize.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static String getMaxNewSize(String[] flags) throws Exception {
ArrayList<String> finalargs = new ArrayList<String>();
finalargs.addAll(Arrays.asList(flags));
if (isRunningG1(flags)) {
finalargs.add("-XX:G1HeapRegionSize=1M");
}
finalargs.add("-XX:+PrintFlagsFinal");
finalargs.add("-version");
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs.toArray(new String[0]));
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
output.shouldHaveExitValue(0);
String stdout = output.getStdout();
// System.out.println(stdout);
return getFlagValue("MaxNewSize", stdout);
}
12
Source : HeapChangeLogging.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128m", "-Xmn100m", "-XX:+UseSerialGC", "-Xlog:gc", "HeapFiller");
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
String stdout = output.getStdout();
System.out.println(stdout);
Matcher stdoutMatcher = Pattern.compile(".*\\(Allocation Failure\\) [0-9]+[KMG]->[0-9]+[KMG]\\([0-9]+[KMG]\\)", Pattern.MULTILINE).matcher(stdout);
if (!stdoutMatcher.find()) {
throw new RuntimeException("No proper GC log line found");
}
output.shouldHaveExitValue(0);
}
11
Source : Utils.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
/**
* Searches for a jvm pid in the output from "jcmd -l".
*
* Example output from jcmd is:
* 12498 sun.tools.jcmd.JCmd -l
* 12254 /tmp/jdk8/tl/jdk/JTwork/clreplacedes/com/sun/tools/attach/Application.jar
*
* @param key A regular expression to search for.
* @return The found pid, or -1 if not found.
* @throws Exception If multiple matching jvms are found.
*/
public static int tryFindJvmPid(String key) throws Throwable {
Outputreplacedyzer output = null;
try {
JDKToolLauncher jcmdLauncher = JDKToolLauncher.create("jcmd");
jcmdLauncher.addToolArg("-l");
output = ProcessTools.executeProcess(jcmdLauncher.getCommand());
output.shouldHaveExitValue(0);
// Search for a line starting with numbers (pid), follwed by the key.
Pattern pattern = Pattern.compile("([0-9]+)\\s.*(" + key + ").*\\r?\\n");
Matcher matcher = pattern.matcher(output.getStdout());
int pid = -1;
if (matcher.find()) {
pid = Integer.parseInt(matcher.group(1));
System.out.println("findJvmPid.pid: " + pid);
if (matcher.find()) {
throw new Exception("Found multiple JVM pids for key: " + key);
}
}
return pid;
} catch (Throwable t) {
System.out.println(String.format("Utils.findJvmPid(%s) failed: %s", key, t));
throw t;
}
}
11
Source : SASymbolTableTest.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static void run(boolean useArchive) throws Exception {
String flag = useArchive ? "auto" : "off";
try {
// (1) Launch the attachee process
System.out.println("Starting LingeredApp");
List<String> vmOpts = Arrays.asList("-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=" + jsaName, "-Xshare:" + flag, // so we can see "sharing" in the output
"-showversion");
theApp = LingeredApp.startApp(vmOpts);
// (2) Launch the agent process
long pid = theApp.getPid();
System.out.println("Attaching agent to " + pid);
ProcessBuilder tool = ProcessTools.createJavaProcessBuilder("--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED", "SASymbolTableTestAgent", Long.toString(pid));
Outputreplacedyzer output = CDSTestUtils.executeAndLog(tool, "tool");
if (output.getStdout().contains("connected too early")) {
System.out.println("SymbolTable not created by VM - test skipped");
return;
}
output.shouldHaveExitValue(0);
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
LingeredApp.stopApp(theApp);
}
}
11
Source : TestPLABOutput.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static void runTest() throws Exception {
final String[] arguments = { "-Xbootclreplacedpath/a:.", "-XX:+UnlockExperimentalVMOptions", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:+UseG1GC", "-Xmx10M", "-Xlog:gc+plab=debug", GCTest.clreplaced.getName() };
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments);
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
output.shouldHaveExitValue(0);
System.out.println(output.getStdout());
String pattern = ".*GC\\(0\\) .*allocated: (\\d+).*";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(output.getStdout());
if (!m.find()) {
throw new RuntimeException("Could not find any PLAB statistics output");
}
int allocated = Integer.parseInt(m.group(1));
replacedertGT(allocated, 0, "Did not allocate any memory during test");
}
10
Source : TestEagerReclaimHumongousRegionsWithRefs.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", "-Xms128M", "-Xmx128M", "-Xmn16M", "-Xlog:gc", ReclaimRegionFast.clreplaced.getName());
Pattern p = Pattern.compile("Full GC");
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
int found = 0;
Matcher m = p.matcher(output.getStdout());
while (m.find()) {
found++;
}
System.out.println("Issued " + found + " Full GCs");
replacedertLessThan(found, 10, "Found that " + found + " Full GCs were issued. This is larger than the bound. Eager reclaim of objects once referenced from old gen seems to not work at all");
output.shouldHaveExitValue(0);
}
10
Source : TestEagerReclaimHumongousRegionsLog.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static void runTest() throws Exception {
final String[] arguments = { "-Xbootclreplacedpath/a:.", "-XX:+UnlockExperimentalVMOptions", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:+UseG1GC", "-XX:G1HeapRegionSize=1M", "-Xms128M", "-Xmx128M", "-Xlog:gc+phases=trace,gc+heap=info", GCTest.clreplaced.getName() };
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments);
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
output.shouldHaveExitValue(0);
System.out.println(output.getStdout());
// This gives an array of lines containing eager reclaim of humongous regions
// log messages contents after the ":" in the following order for every GC:
// Humongous Register: a.ams
// Humongous Total: b
// Humongous Candidate: c
// Humongous Reclaim: d.dms
// Humongous Reclaimed: e
// Humongous Regions: f->g
String[] lines = Arrays.stream(output.getStdout().split("\\R")).filter(s -> s.contains("Humongous")).map(s -> s.substring(s.indexOf(LogSeparator) + LogSeparator.length())).toArray(String[]::new);
replacederts.replacedertTrue(lines.length % 6 == 0, "There seems to be an unexpected amount of log messages (total: " + lines.length + ") per GC");
for (int i = 0; i < lines.length; i += 6) {
int total = Integer.parseInt(lines[i + 1]);
int candidate = Integer.parseInt(lines[i + 2]);
int reclaimed = Integer.parseInt(lines[i + 4]);
int before = Integer.parseInt(lines[i + 5].substring(0, 1));
int after = Integer.parseInt(lines[i + 5].substring(3, 4));
System.out.println("total " + total + " candidate " + candidate + " reclaimed " + reclaimed + " before " + before + " after " + after);
replacederts.replacedertEQ(total, candidate, "Not all humonguous objects are candidates");
replacederts.replacedertLTE(reclaimed, candidate, "The number of reclaimed objects must be less or equal than the number of candidates");
if (reclaimed > 0) {
replacederts.replacedertLT(after, before, "Number of regions after must be smaller than before.");
replacederts.replacedertEQ(reclaimed, candidate, "Must have reclaimed all candidates.");
replacederts.replacedertGT((before - after), reclaimed, "Number of regions reclaimed (" + (before - after) + ") must be larger than number of objects reclaimed (" + reclaimed + ")");
}
}
}
10
Source : CheckControl.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private static String executeTest(String gcName, String[] gcOptions, String[] gcStepPhases) throws Exception {
System.out.println("\n---------- Testing ---------");
final String[] wb_arguments = { "-Xbootclreplacedpath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI" };
List<String> arglist = new ArrayList<String>();
Collections.addAll(arglist, wb_arguments);
Collections.addAll(arglist, gcOptions);
arglist.add(Executor.clreplaced.getName());
Collections.addAll(arglist, gcStepPhases);
String[] arguments = arglist.toArray(new String[arglist.size()]);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments);
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
String messages = output.getStdout();
System.out.println(messages);
output.shouldHaveExitValue(0);
output.shouldContain("Using " + gcName);
return messages;
}
9
Source : TestJcmdStartStopDefault.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
private static String parseRecordingName(Outputreplacedyzer output) {
// Expected output:
// Started recording recording-1. No limit (duration/maxsize/maxage) in use.
// Use JFR.dump name=recording-1 filename=FILEPATH to copy recording data to file.
String stdout = output.getStdout();
Pattern p = Pattern.compile(".*Use jcmd \\d+ JFR.dump name=(\\S+).*", Pattern.DOTALL);
Matcher m = p.matcher(stdout);
replacederts.replacedertTrue(m.matches(), "Could not parse recording name");
String name = m.group(1);
System.out.println("Recording name=" + name);
return name;
}
9
Source : JLinkMultiReleaseJarTest.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public void runImage(String image, boolean expected) throws Throwable {
Path java = Paths.get(image, "bin", "java");
Outputreplacedyzer oa = ProcessTools.executeProcess(java.toString(), "-m", "m1/p.Main");
String sout = oa.getStdout();
boolean actual = sout.contains("logging found");
replacedert.replacedertEquals(actual, expected);
System.out.println(sout);
System.err.println(oa.getStderr());
replacedert.replacedertEquals(oa.getExitValue(), 0);
}
9
Source : TestEagerReclaimHumongousRegions.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", "-Xms128M", "-Xmx128M", "-Xmn16M", "-Xlog:gc", ReclaimRegionFast.clreplaced.getName());
Pattern p = Pattern.compile("Full GC");
Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
int found = 0;
Matcher m = p.matcher(output.getStdout());
while (m.find()) {
found++;
}
System.out.println("Issued " + found + " Full GCs");
replacederts.replacedertLT(found, 10, "Found that " + found + " Full GCs were issued. This is larger than the bound. Eager reclaim seems to not work at all");
output.shouldHaveExitValue(0);
}
9
Source : SASymbolTableTest.java
with GNU General Public License v2.0
from AdoptOpenJDK
with GNU General Public License v2.0
from AdoptOpenJDK
private static void run(boolean useArchive) throws Exception {
String flag = useArchive ? "auto" : "off";
try {
// (1) Launch the attachee process
System.out.println("Starting LingeredApp");
List<String> vmOpts = Arrays.asList("-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=" + jsaName, "-Xshare:" + flag, // so we can see "sharing" in the output
"-showversion");
theApp = LingeredApp.startApp(vmOpts);
// (2) Launch the agent process
long pid = theApp.getPid();
System.out.println("Attaching agent to " + pid);
ProcessBuilder tool = ProcessTools.createJavaProcessBuilder("--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED", "SASymbolTableTestAgent", Long.toString(pid));
Outputreplacedyzer output = ProcessTools.executeProcess(tool);
System.out.println("STDOUT[");
System.out.println(output.getOutput());
if (output.getStdout().contains("connected too early")) {
System.out.println("SymbolTable not created by VM - test skipped");
return;
}
System.out.println("]");
System.out.println("STDERR[");
System.out.print(output.getStderr());
System.out.println("]");
output.shouldHaveExitValue(0);
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
LingeredApp.stopApp(theApp);
}
}
7
Source : JitTesterDriver.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static void main(String[] args) {
if (args.length < 1) {
throw new IllegalArgumentException("[TESTBUG]: wrong number of argument : " + args.length + ". Expected at least 1 argument -- jit-tester test name.");
}
Outputreplacedyzer oa;
try {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, args);
oa = new Outputreplacedyzer(pb.start());
} catch (Exception e) {
throw new Error("Unexpected exception on test jvm start :" + e, e);
}
String name = args[args.length - 1];
// tests use \n only in stdout
Pattern splitOut = Pattern.compile("\\n");
// can handle both \r\n and \n
Pattern splitErr = Pattern.compile("\\r?\\n");
Path testDir = Paths.get(Utils.TEST_SRC);
String goldOut = formatOutput(streamGoldFile(testDir, name, "out"));
String anlzOut = formatOutput(Arrays.stream(splitOut.split(oa.getStdout())));
replacederts.replacedertEQ(anlzOut, goldOut, "Actual stdout isn't equal to golden one");
String goldErr = formatOutput(streamGoldFile(testDir, name, "err"));
String anlzErr = formatOutput(Arrays.stream(splitErr.split(oa.getStderr())));
replacederts.replacedertEQ(anlzErr, goldErr, "Actual stderr isn't equal to golden one");
int exitValue = Integer.parseInt(streamGoldFile(testDir, name, "exit").findFirst().get());
oa.shouldHaveExitValue(exitValue);
}
6
Source : JhsdbThreadInfoTest.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
public static void main(String[] args) throws Exception {
if (!Platform.shouldSAAttach()) {
System.out.println("SA attach not expected to work - test skipped.");
return;
}
LingeredApp app = null;
try {
app = LingeredApp.startApp(Utils.getVmOptions());
System.out.println("Started LingeredApp with pid " + app.getPid());
JDKToolLauncher jhsdbLauncher = JDKToolLauncher.createUsingTestJDK("jhsdb");
jhsdbLauncher.addToolArg("jstack");
jhsdbLauncher.addToolArg("--pid");
jhsdbLauncher.addToolArg(Long.toString(app.getPid()));
ProcessBuilder pb = new ProcessBuilder();
pb.command(jhsdbLauncher.getCommand());
Process jhsdb = pb.start();
jhsdb.waitFor();
Outputreplacedyzer out = new Outputreplacedyzer(jhsdb);
System.out.println(out.getStdout());
System.err.println(out.getStderr());
out.shouldMatch("\".+\" #\\d+ daemon prio=\\d+ tid=0x[0-9a-f]+ nid=0x[0-9a-f]+ .+ \\[0x[0-9a-f]+]");
out.shouldMatch("\"main\" #\\d+ prio=\\d+ tid=0x[0-9a-f]+ nid=0x[0-9a-f]+ .+ \\[0x[0-9a-f]+]");
out.shouldMatch(" java.lang.Thread.State: .+");
out.shouldMatch(" JavaThread state: _thread_.+");
out.shouldNotContain(" java.lang.Thread.State: UNKNOWN");
out.stderrShouldBeEmpty();
System.out.println("Test Completed");
} catch (InterruptedException ie) {
throw new Error("Problem awaiting the child process: " + ie, ie);
} catch (Exception attachE) {
throw new Error("Couldn't start jhsdb, attach to LingeredApp or match ThreadName: " + attachE);
} finally {
LingeredApp.stopApp(app);
}
}
6
Source : TestRTMRetryCount.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
private void verifyRTMRetryCount(int retryCount) throws Throwable {
CompilableTest busyLock = new BusyLock();
long expectedAborts = retryCount + 1L;
Outputreplacedyzer outputreplacedyzer = RTMTestBase.executeRTMTest(busyLock, "-XX:-UseRTMXendForLockBusy", "-XX:RTMTotalCountIncrRate=1", CommandLineOptionTest.prepareNumericFlag("RTMRetryCount", retryCount), "-XX:RTMTotalCountIncrRate=1", "-XX:+PrintPreciseRTMLockingStatistics", BusyLock.clreplaced.getName(), Boolean.toString(TestRTMRetryCount.INFLATE_MONITOR), Integer.toString(TestRTMRetryCount.LOCKING_TIME));
outputreplacedyzer.shouldHaveExitValue(0);
List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(busyLock.getMethodWithLockName(), outputreplacedyzer.getStdout());
replacederts.replacedertEQ(statistics.size(), 1, "VM output should contain " + "exactly one rtm locking statistics entry for method " + busyLock.getMethodWithLockName());
replacederts.replacedertEQ(statistics.get(0).getTotalAborts(), expectedAborts, String.format("It is expected to get %d aborts", expectedAborts));
}
5
Source : SpaceUtilizationCheck.java
with GNU General Public License v2.0
from hzio
with GNU General Public License v2.0
from hzio
static void test(String... extra_options) throws Exception {
Outputreplacedyzer output = CDSTestUtils.createArchive(extra_options);
CDSTestUtils.checkDump(output);
Pattern pattern = Pattern.compile("^(..) space: *([0-9]+).* out of *([0-9]+) bytes .* at 0x([0-9a0-f]+)");
WhiteBox wb = WhiteBox.getWhiteBox();
long reserve_alignment = wb.metaspaceReserveAlignment();
System.out.println("Metaspace::reserve_alignment() = " + reserve_alignment);
long last_region = -1;
Hashtable<String, String> checked = new Hashtable<>();
for (String line : output.getStdout().split("\n")) {
if (line.contains(" space:") && !line.contains("st space:")) {
Matcher matcher = pattern.matcher(line);
if (matcher.find()) {
String name = matcher.group(1);
if (name.equals("s0") || name.equals("s1")) {
// String regions are listed at the end and they may not be fully occupied.
break;
} else {
System.out.println("Checking " + name + " in : " + line);
checked.put(name, name);
}
long used = Long.parseLong(matcher.group(2));
long capacity = Long.parseLong(matcher.group(3));
long address = Long.parseLong(matcher.group(4), 16);
long unused = capacity - used;
if (unused < 0) {
throw new RuntimeException("Unused space (" + unused + ") less than 0");
}
if (unused > reserve_alignment) {
// [1] Check for unused space
throw new RuntimeException("Unused space (" + unused + ") must be smaller than Metaspace::reserve_alignment() (" + reserve_alignment + ")");
}
if (last_region >= 0 && address != last_region) {
// [2] Check for no-gap
throw new RuntimeException("Region 0x" + address + " should have started at 0x" + Long.toString(last_region, 16));
}
last_region = address + capacity;
}
}
}
if (checked.size() != 5) {
throw new RuntimeException("Must have 5 consecutive, fully utilized regions");
}
}
4
Source : ClhsdbJstackXcompStress.java
with GNU General Public License v2.0
from Tencent
with GNU General Public License v2.0
from Tencent
private static void runJstackInLoop(LingeredApp app) throws Exception {
boolean anyMatchedCompiledFrame = false;
for (int i = 0; i < MAX_ITERATIONS; i++) {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
launcher.addToolArg("jstack");
launcher.addToolArg("--pid");
launcher.addToolArg(Long.toString(app.getPid()));
ProcessBuilder pb = new ProcessBuilder();
pb.command(launcher.getCommand());
Process jhsdb = pb.start();
Outputreplacedyzer out = new Outputreplacedyzer(jhsdb);
jhsdb.waitFor();
if (DEBUG) {
System.out.println(out.getStdout());
System.err.println(out.getStderr());
}
// NPE's are reported on the err stream
out.stderrShouldBeEmpty();
out.stdoutShouldNotContain("Error occurred during stack walking:");
out.stdoutShouldContain(LingeredAppWithRecComputation.THREAD_NAME);
List<String> stdoutList = Arrays.asList(out.getStdout().split("\\R"));
anyMatchedCompiledFrame = anyMatchedCompiledFrame || isMatchCompiledFrame(stdoutList);
}
if (!anyMatchedCompiledFrame) {
throw new RuntimeException("Expected jstack output to contain 'Compiled frame'");
}
System.out.println("DEBUG: jhsdb jstack did not throw NPE, as expected.");
}
See More Examples