jdk.test.lib.process.OutputAnalyzer - java examples

Here are the examples of the java api jdk.test.lib.process.OutputAnalyzer taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

19 View Complete Implementation : WeakAlg.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
static void checkCertReq(String alias, String options, String bad) {
    Outputreplacedyzer oa = certreq(alias, options);
    if (bad == null) {
        oa.shouldNotContain("Warning");
    } else {
        oa.shouldContain("Warning").shouldMatch("The generated certificate request.*" + bad + ".*risk");
    }
    oa = kt("-printcertreq -file " + alias + ".req");
    if (bad == null) {
        oa.shouldNotContain("Warning").shouldNotContain("(weak)");
    } else {
        oa.shouldContain("Warning").shouldMatch("The certificate request.*" + bad + ".*risk").shouldContain(bad + " (weak)");
    }
}

19 View Complete Implementation : TestObjectGraphAfterGC.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Checks that gc log contains what we expected and does not contain what we didn't expect
 *
 * @param gcLogName        gc log name
 * @param shouldContain    list of tokens that should be contained in gc log
 * @param shouldNotContain list of tokens that should not be contained in gc log
 * @throws IOException if there are some issues with gc log
 */
private static void checkGCLog(String gcLogName, List<String> shouldContain, List<String> shouldNotContain) throws IOException {
    if (gcLogName == null) {
        return;
    }
    String gcLog = new String(Files.readAllBytes(new File(gcLogName).toPath()));
    Outputreplacedyzer outputreplacedyzer = new Outputreplacedyzer(gcLog, "");
    shouldContain.stream().forEach(outputreplacedyzer::shouldContain);
    shouldNotContain.stream().forEach(outputreplacedyzer::shouldNotContain);
}

19 View Complete Implementation : VMAliasOptions.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
static void testAliases(String[][] optionInfo) throws Throwable {
    String[] aliasNames = new String[optionInfo.length];
    String[] optionNames = new String[optionInfo.length];
    String[] expectedValues = new String[optionInfo.length];
    for (int i = 0; i < optionInfo.length; i++) {
        aliasNames[i] = optionInfo[i][0];
        optionNames[i] = optionInfo[i][1];
        expectedValues[i] = optionInfo[i][2];
    }
    Outputreplacedyzer output = CommandLineOptionTest.startVMWithOptions(aliasNames, expectedValues, "-XX:+PrintFlagsFinal");
    CommandLineOptionTest.verifyOptionValuesFromOutput(output, optionNames, expectedValues);
}

18 View Complete Implementation : CommandLineOptionTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Verifies that JVM startup behavior matches our expectations.
 *
 * @param expectedMessages an array of patterns that should occur in JVM
 *                         output. If {@code null} then
 *                         JVM output could be empty.
 * @param unexpectedMessages an array of patterns that should not occur
 *                           in JVM output. If {@code null} then
 *                           JVM output could be empty.
 * @param wrongWarningMessage message that will be shown if messages are
 *                            not as expected.
 * @param outputreplacedyzer Outputreplacedyzer instance
 * @throws replacedertionError if verification fails.
 */
public static void verifyOutput(String[] expectedMessages, String[] unexpectedMessages, String wrongWarningMessage, Outputreplacedyzer outputreplacedyzer) {
    if (expectedMessages != null) {
        for (String expectedMessage : expectedMessages) {
            try {
                outputreplacedyzer.shouldMatch(expectedMessage);
            } catch (RuntimeException e) {
                String errorMessage = String.format("Expected message not found: '%s'.%n%s", expectedMessage, wrongWarningMessage);
                throw new replacedertionError(errorMessage, e);
            }
        }
    }
    if (unexpectedMessages != null) {
        for (String unexpectedMessage : unexpectedMessages) {
            try {
                outputreplacedyzer.shouldNotMatch(unexpectedMessage);
            } catch (RuntimeException e) {
                String errorMessage = String.format("Unexpected message found: '%s'.%n%s", unexpectedMessage, wrongWarningMessage);
                throw new replacedertionError(errorMessage, e);
            }
        }
    }
}

18 View Complete Implementation : JcmdWithNMTDisabled.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void main(String[] args) throws Exception {
    // This test explicitly needs to be run with the exact command lines below, not preplaceding on
    // arguments from the parent VM is a conscious choice to avoid NMT being turned on.
    if (args.length > 0) {
        ProcessBuilder pb;
        Outputreplacedyzer output;
        String testjdkPath = System.getProperty("test.jdk");
        // First run without enabling NMT
        pb = ProcessTools.createJavaProcessBuilder("-Dtest.jdk=" + testjdkPath, "JcmdWithNMTDisabled");
        output = new Outputreplacedyzer(pb.start());
        output.shouldHaveExitValue(0);
        // Then run with explicitly disabling NMT, should not be any difference
        pb = ProcessTools.createJavaProcessBuilder("-Dtest.jdk=" + testjdkPath, "-XX:NativeMemoryTracking=off", "JcmdWithNMTDisabled");
        output = new Outputreplacedyzer(pb.start());
        output.shouldHaveExitValue(0);
        return;
    }
    // Grab my own PID
    pid = Long.toString(ProcessTools.getProcessId());
    jcmdCommand("summary");
    jcmdCommand("detail");
    jcmdCommand("baseline");
    jcmdCommand("summary.diff");
    jcmdCommand("detail.diff");
    jcmdCommand("scale=GB");
    jcmdCommand("shutdown");
}

18 View Complete Implementation : TestLargePagesFlags.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
private static Outputreplacedyzer executeNewJVM(Flag... flags) throws Exception {
    ArrayList<String> args = new ArrayList<>();
    for (Flag flag : flags) {
        args.add(flag.flagString());
    }
    args.add("-XX:+PrintFlagsFinal");
    args.add("-version");
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(new String[args.size()]));
    Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
    return output;
}

18 View Complete Implementation : ApiValidatorTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
private void moduleDirectivesCase(String baseDirectives, String versionedDirectives, boolean expectSuccess, String expectedMessage) throws Throwable {
    String[] moduleClreplacedes = { "package pkg1; public clreplaced A { }", "package pkg2; public clreplaced B extends pkg1.A { }", "package pkg3; public clreplaced C extends pkg2.B { }" };
    compileModule(clreplacedes.resolve("base"), "module A { " + baseDirectives + " }", moduleClreplacedes);
    compileModule(clreplacedes.resolve("v10"), "module A { " + versionedDirectives + " }", moduleClreplacedes);
    String jarfile = root.resolve("test.jar").toString();
    Outputreplacedyzer output = jar("cf", jarfile, "-C", clreplacedes.resolve("base").toString(), ".", "--release", "10", "-C", clreplacedes.resolve("v10").toString(), ".");
    if (expectSuccess) {
        output.shouldHaveExitValue(SUCCESS);
    } else {
        output.shouldNotHaveExitValue(SUCCESS).shouldContain(expectedMessage);
    }
}

18 View Complete Implementation : AotCompiler.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void main(String[] args) {
    String clreplacedName = null;
    List<String> compileList = new ArrayList<>();
    String libName = null;
    List<String> extraopts = new ArrayList<>();
    for (int i = 0; i < args.length; i++) {
        switch(args[i]) {
            case "-clreplaced":
                clreplacedName = args[++i];
                break;
            case "-compile":
                compileList.add("compileOnly " + args[++i]);
                break;
            case "-libname":
                libName = args[++i];
                break;
            case "-extraopt":
                extraopts.add(args[++i]);
                break;
            default:
                throw new Error("Unknown option: " + args[i]);
        }
    }
    extraopts.add("-clreplacedpath");
    extraopts.add(Utils.TEST_CLreplaced_PATH + File.pathSeparator + Utils.TEST_SRC);
    if (clreplacedName != null && libName != null) {
        Outputreplacedyzer oa = launchCompiler(libName, clreplacedName, extraopts, compileList);
        oa.shouldHaveExitValue(0);
    } else {
        printUsage();
        throw new Error("Mandatory arguments aren't preplaceded");
    }
}

18 View Complete Implementation : JarsTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
protected void prepare() throws Exception {
    ProcessBuilder pb = createJarProcessBuilder("cf", "foo.jar", "Foo.clreplaced", "Bar.clreplaced");
    Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
    dump(output, "ctw-foo.jar");
    output.shouldHaveExitValue(0);
    pb = createJarProcessBuilder("cf", "bar.jar", "Foo.clreplaced", "Bar.clreplaced");
    output = new Outputreplacedyzer(pb.start());
    dump(output, "ctw-bar.jar");
    output.shouldHaveExitValue(0);
}

18 View Complete Implementation : IhopUtils.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Checks that GC log contains expected ergonomic messages
 * @param outputreplacedyzer Outputreplacedyer with GC log for checking
 * @throws RuntimeException If no IHOP ergo messages were not found
 */
public static void checkErgoMessagesExist(Outputreplacedyzer outputreplacedyzer) {
    String output = outputreplacedyzer.getOutput();
    if (!(output.contains(CYCLE_INITIATION_MESSAGE) | output.contains(CYCLE_INITIATION_MESSAGE_FALSE))) {
        throw new RuntimeException("Cannot find expected IHOP ergonomics messages");
    }
}

18 View Complete Implementation : ClassAndLibraryNotMatchTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
private void compileHelloWorld() {
    String javac = JDKToolFinder.getCompileJDKTool("javac");
    ProcessBuilder pb = new ProcessBuilder(javac, HELLO_WORLD_FILE);
    Outputreplacedyzer oa;
    try {
        oa = ProcessTools.executeProcess(pb);
    } catch (Exception e) {
        throw new Error("Can't compile clreplaced " + e, e);
    }
    oa.shouldHaveExitValue(0);
}

18 View Complete Implementation : BMITestRunner.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * 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());
}

18 View Complete Implementation : BMITestRunner.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * 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.");
}

18 View Complete Implementation : LoadAgentDcmdTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public void run(CommandExecutor executor) {
    try {
        createJarFileForAgent();
        String libpath = getLibInstrumentPath();
        Outputreplacedyzer output = null;
        // Test 1: Native agent, no arguments
        output = executor.execute("JVMTI.agent_load " + libpath + " agent.jar");
        output.stderrShouldBeEmpty();
        // Test 2: Native agent, with arguments
        output = executor.execute("JVMTI.agent_load " + libpath + " \"agent.jar=foo=bar\"");
        output.stderrShouldBeEmpty();
        // Test 3: Java agent, no arguments
        output = executor.execute("JVMTI.agent_load " + "agent.jar");
        output.stderrShouldBeEmpty();
        // Test 4: Java agent, with arguments
        output = executor.execute("JVMTI.agent_load " + "\"agent.jar=foo=bar\"");
        output.stderrShouldBeEmpty();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

18 View Complete Implementation : ToolRunner.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Starts the process, waits for the process completion and returns the
 * results
 *
 * @return process results
 * @throws Exception if anything goes wrong
 */
ToolResults runToCompletion() throws Exception {
    ProcessBuilder pb = new ProcessBuilder(cmdArgs);
    Outputreplacedyzer oa = ProcessTools.executeProcess(pb);
    return new ToolResults(oa.getExitValue(), stringToList(oa.getStdout()), stringToList(oa.getStderr()));
}

18 View Complete Implementation : TestInstanceKlassSizeForInterface.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
private static String getJcmdInstanceKlreplacedSize(Outputreplacedyzer output, String instanceKlreplacedName) {
    for (String s : output.asLines()) {
        if (s.contains(instanceKlreplacedName)) {
            String[] tokens;
            System.out.println(s);
            tokens = s.split("\\s+");
            return tokens[3];
        }
    }
    return null;
}

18 View Complete Implementation : TransformRelatedClasses.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
// same test jar and archive can be used for all test cases
private void prepare() throws Exception {
    // create agent jar
    // Agent is the same for all test cases
    String pathToManifest = "../../../../testlibrary/jvmti/TransformerAgent.mf";
    agentJar = ClreplacedFileInstaller.writeJar("TransformerAgent.jar", ClreplacedFileInstaller.Manifest.fromSourceFile(pathToManifest), agentClreplacedes);
    // create a test jar
    testJar = ClreplacedFileInstaller.writeJar(parent + "-" + child + ".jar", testClreplacedes);
    // create an archive
    File clreplacedList = CDSTestUtils.makeClreplacedList("transform-" + parent, testNames);
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-Xbootclreplacedpath/a:" + testJar, "-XX:+UnlockDiagnosticVMOptions", "-XX:ExtraSharedClreplacedListFile=" + clreplacedList.getPath(), "-XX:SharedArchiveFile=" + archiveName, "-XX:+PrintSharedSpaces", "-Xshare:dump");
    Outputreplacedyzer out = new Outputreplacedyzer(pb.start());
    CDSTestUtils.checkDump(out);
}

18 View Complete Implementation : Executor.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
// Executes all diagnostic commands
protected Outputreplacedyzer[] executeJCMD(int pid) {
    int size = jcmdCommands.size();
    Outputreplacedyzer[] outputArray = new Outputreplacedyzer[size];
    CommandExecutor jcmdExecutor = new PidJcmdExecutor(String.valueOf(pid));
    for (int i = 0; i < size; i++) {
        outputArray[i] = jcmdExecutor.execute(jcmdCommands.get(i));
    }
    return outputArray;
}

18 View Complete Implementation : Executor.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Executes separate VM a gets an Outputreplacedyzer instance with the results
 * of execution
 */
public List<Outputreplacedyzer> execute() {
    // Add clreplaced name that would be executed in a separate VM
    vmOptions.add(execClreplaced);
    Outputreplacedyzer output;
    try (ServerSocket serverSocket = new ServerSocket(0)) {
        if (isValid) {
            // Get port test VM will connect to
            int port = serverSocket.getLocalPort();
            if (port == -1) {
                throw new Error("Socket is not bound: " + port);
            }
            vmOptions.add(String.valueOf(port));
            if (states != null) {
                // add flag to show that there should be state map preplaceded
                vmOptions.add("states");
            }
            // Start separate thread to connect with test VM
            new Thread(() -> connectTestVM(serverSocket)).start();
        }
        // Start test VM
        output = ProcessTools.executeTestJvmAllArgs(vmOptions.toArray(new String[vmOptions.size()]));
    } catch (Throwable thr) {
        throw new Error("Execution failed: " + thr.getMessage(), thr);
    }
    List<Outputreplacedyzer> outputList = new ArrayList<>();
    outputList.add(output);
    if (jcmdOutputreplacedyzers != null) {
        Collections.addAll(outputList, jcmdOutputreplacedyzers);
    }
    return outputList;
}

17 View Complete Implementation : TestCardTablePageCommits.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void main(String[] args) throws Exception {
    // The test is run with a small heap to make sure all pages in the card
    // table gets committed. Need 8 MB heap to trigger the bug on SPARC
    // because of 8kB pages, replacedume 4 KB pages for all other CPUs.
    String Xmx = Platform.isSparc() ? "-Xmx8m" : "-Xmx4m";
    String[] opts = { Xmx, "-XX:NativeMemoryTracking=detail", "-XX:+UseParallelGC", "-version" };
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(opts);
    Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
    output.shouldHaveExitValue(0);
}

17 View Complete Implementation : Test7068051.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
private static void runJar(List<String> params) {
    JDKToolLauncher jar = JDKToolLauncher.create("jar");
    for (String p : params) {
        jar.addToolArg(p);
    }
    ProcessBuilder pb = new ProcessBuilder(jar.getCommand());
    try {
        Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
        output.shouldHaveExitValue(0);
    } catch (IOException ex) {
        throw new replacedertionError("TESTBUG: jar failed.", ex);
    }
}

17 View Complete Implementation : JcmdScaleDetail.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void main(String[] args) throws Exception {
    ProcessBuilder pb = new ProcessBuilder();
    Outputreplacedyzer output;
    // Grab my own PID
    String pid = Long.toString(ProcessTools.getProcessId());
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=KB" });
    output = new Outputreplacedyzer(pb.start());
    output.shouldContain("KB, committed=");
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=MB" });
    output = new Outputreplacedyzer(pb.start());
    output.shouldContain("MB, committed=");
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=GB" });
    output = new Outputreplacedyzer(pb.start());
    output.shouldContain("GB, committed=");
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=apa" });
    output = new Outputreplacedyzer(pb.start());
    output.shouldContain("Incorrect scale value: apa");
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=GB" });
    output = new Outputreplacedyzer(pb.start());
    output.shouldContain("GB, committed=");
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=apa" });
    output = new Outputreplacedyzer(pb.start());
    output.shouldContain("Incorrect scale value: apa");
}

17 View Complete Implementation : CompressedClassSpaceSize.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void main(String[] args) throws Exception {
    ProcessBuilder pb;
    Outputreplacedyzer output;
    if (Platform.is64bit()) {
        // Minimum size is 1MB
        pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClreplacedSpaceSize=0", "-version");
        output = new Outputreplacedyzer(pb.start());
        output.shouldContain("outside the allowed range").shouldHaveExitValue(1);
        // Invalid size of -1 should be handled correctly
        pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClreplacedSpaceSize=-1", "-version");
        output = new Outputreplacedyzer(pb.start());
        output.shouldContain("Improperly specified VM option 'CompressedClreplacedSpaceSize=-1'").shouldHaveExitValue(1);
        // Maximum size is 3GB
        pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClreplacedSpaceSize=4g", "-version");
        output = new Outputreplacedyzer(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:CompressedClreplacedSpaceSize=1m", "-Xlog:gc+metaspace=trace", "-version");
        output = new Outputreplacedyzer(pb.start());
        output.shouldContain("Compressed clreplaced space size: 1048576").shouldHaveExitValue(0);
        // Make sure the maximum size is set correctly and printed
        pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:CompressedClreplacedSpaceSize=3g", "-Xlog:gc+metaspace=trace", "-version");
        output = new Outputreplacedyzer(pb.start());
        output.shouldContain("Compressed clreplaced space size: 3221225472").shouldHaveExitValue(0);
        pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedOops", "-XX:CompressedClreplacedSpaceSize=1m", "-version");
        output = new Outputreplacedyzer(pb.start());
        output.shouldContain("Setting CompressedClreplacedSpaceSize has no effect when compressed clreplaced pointers are not used").shouldHaveExitValue(0);
        pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedClreplacedPointers", "-XX:CompressedClreplacedSpaceSize=1m", "-version");
        output = new Outputreplacedyzer(pb.start());
        output.shouldContain("Setting CompressedClreplacedSpaceSize has no effect when compressed clreplaced pointers are not used").shouldHaveExitValue(0);
    } else {
        // 32bit platforms doesn't have compressed oops
        pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClreplacedSpaceSize=1m", "-version");
        output = new Outputreplacedyzer(pb.start());
        output.shouldContain("Setting CompressedClreplacedSpaceSize has no effect when compressed clreplaced pointers are not used").shouldHaveExitValue(0);
    }
}

17 View Complete Implementation : JVMOption.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Testing writeable option using Jcmd
 *
 * @return number of failed tests
 */
public int testJcmd() {
    DynamicVMOption option = new DynamicVMOption(name);
    int failedTests = 0;
    Outputreplacedyzer out;
    String origValue;
    if (option.isWriteable()) {
        System.out.println("Testing " + name + " option dynamically by jcmd");
        origValue = option.getValue();
        for (String value : getValidValues()) {
            out = executor.execute(String.format("VM.set_flag %s %s", name, value), true);
            if (out.getOutput().contains(name + " error")) {
                failedMessage(String.format("Option %s: Can not change " + "option to valid value \"%s\" via jcmd", name, value));
                printOutputContent(out);
                failedTests++;
            }
        }
        for (String value : getInvalidValues()) {
            out = executor.execute(String.format("VM.set_flag %s %s", name, value), true);
            if (!out.getOutput().contains(name + " error")) {
                failedMessage(String.format("Option %s: Error not reported for " + "option when it chagned to invalid value \"%s\" via jcmd", name, value));
                printOutputContent(out);
                failedTests++;
            }
        }
        option.setValue(origValue);
    }
    return failedTests;
}

17 View Complete Implementation : SummaryAfterShutdown.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void main(String[] args) throws Exception {
    Outputreplacedyzer output;
    // Grab my own PID
    String pid = Long.toString(ProcessTools.getProcessId());
    ProcessBuilder pb = new ProcessBuilder();
    // Run 'jcmd <pid> VM.native_memory shutdown'
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "shutdown" });
    output = new Outputreplacedyzer(pb.start());
    // Verify that jcmd reports that NMT is shutting down
    output.shouldContain("Native memory tracking has been turned off");
    // Run 'jcmd <pid> VM.native_memory summary'
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary" });
    output = new Outputreplacedyzer(pb.start());
    // Verify that jcmd reports that NMT has been shutdown
    output.shouldContain("Native memory tracking has been shutdown");
}

17 View Complete Implementation : TestG1PercentageOptions.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
private static void check(String flag, boolean is_valid) throws Exception {
    String[] flags = new String[] { "-XX:+UseG1GC", flag, "-version" };
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flags);
    Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
    if (is_valid) {
        output.shouldHaveExitValue(0);
    } else {
        output.shouldHaveExitValue(1);
    }
}

17 View Complete Implementation : TestAESIntrinsicsOnSupportedConfig.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Test checks following situation: <br/>
 * UseAES flag is set to true, TestAESMain is executed <br/>
 * Expected result: UseAESIntrinsics flag is set to true <br/>
 * If vm type is server then output should contain intrinsics usage <br/>
 *
 * @throws Throwable
 */
private void testUseAES() throws Throwable {
    Outputreplacedyzer outputreplacedyzer = ProcessTools.executeTestJvm(prepareArguments(prepareBooleanFlag(AESIntrinsicsBase.USE_AES, true)));
    final String errorMessage = "Case testUseAES failed";
    if (Platform.isServer() && !Platform.isEmulatedClient()) {
        verifyOutput(new String[] { AESIntrinsicsBase.CIPHER_INTRINSIC, AESIntrinsicsBase.AES_INTRINSIC }, null, errorMessage, outputreplacedyzer);
    } else {
        verifyOutput(null, new String[] { AESIntrinsicsBase.CIPHER_INTRINSIC, AESIntrinsicsBase.AES_INTRINSIC }, errorMessage, outputreplacedyzer);
    }
    verifyOptionValue(AESIntrinsicsBase.USE_AES, "true", errorMessage, outputreplacedyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "true", errorMessage, outputreplacedyzer);
}

17 View Complete Implementation : TestAESIntrinsicsOnUnsupportedConfig.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Test checks following situation: <br/>
 * UseAESIntrinsics flag is set to true, TestAESMain is executed <br/>
 * Expected result: UseAESIntrinsics flag is set to false <br/>
 * UseAES flag is set to false <br/>
 * Output shouldn't contain intrinsics usage <br/>
 * Output should contain message about intrinsics unavailability
 * @throws Throwable
 */
private void testUseAESIntrinsics() throws Throwable {
    Outputreplacedyzer outputreplacedyzer = ProcessTools.executeTestJvm(AESIntrinsicsBase.prepareArguments(prepareBooleanFlag(AESIntrinsicsBase.USE_AES_INTRINSICS, true)));
    final String errorMessage = "Case testUseAESIntrinsics failed";
    verifyOutput(new String[] { INTRINSICS_NOT_AVAILABLE_MSG }, new String[] { AESIntrinsicsBase.CIPHER_INTRINSIC, AESIntrinsicsBase.AES_INTRINSIC }, errorMessage, outputreplacedyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false", errorMessage, outputreplacedyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES, "false", errorMessage, outputreplacedyzer);
}

17 View Complete Implementation : TestG1ConcRefinementThreads.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
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);
}

17 View Complete Implementation : ModulesTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
static void testModuleTrace(String... args) throws Exception {
    Outputreplacedyzer output = run(args);
    output.shouldContain("define_javabase_module(): Definition of module:");
    output.shouldContain("define_javabase_module(): creation of package");
    output.shouldContain("define_module(): creation of module");
    output.shouldContain("define_module(): creation of package");
    output.shouldContain("set_bootloader_unnamed_module(): recording unnamed");
    output.shouldContain("add_module_exports(): package");
    output.shouldContain("add_reads_module(): Adding read from module");
    output.shouldContain("Setting package: clreplaced:");
    output.shouldHaveExitValue(0);
}

17 View Complete Implementation : TestAESIntrinsicsOnUnsupportedConfig.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Test checks following situation: <br/>
 * UseAESIntrinsics flag is set to true, TestAESMain is executed <br/>
 * Expected result: UseAES flag is set to false <br/>
 * UseAES flag is set to false <br/>
 * Output shouldn't contain intrinsics usage <br/>
 * Output should contain message about AES unavailability <br/>
 * @throws Throwable
 */
private void testUseAES() throws Throwable {
    Outputreplacedyzer outputreplacedyzer = ProcessTools.executeTestJvm(AESIntrinsicsBase.prepareArguments(prepareBooleanFlag(AESIntrinsicsBase.USE_AES, true)));
    final String errorMessage = "Case testUseAES failed";
    verifyOutput(new String[] { AES_NOT_AVAILABLE_MSG }, new String[] { AESIntrinsicsBase.CIPHER_INTRINSIC, AESIntrinsicsBase.AES_INTRINSIC }, errorMessage, outputreplacedyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false", errorMessage, outputreplacedyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES, "false", errorMessage, outputreplacedyzer);
}

17 View Complete Implementation : JcmdScale.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void main(String[] args) throws Exception {
    ProcessBuilder pb = new ProcessBuilder();
    Outputreplacedyzer output;
    // Grab my own PID
    String pid = Long.toString(ProcessTools.getProcessId());
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=KB" });
    output = new Outputreplacedyzer(pb.start());
    output.shouldContain("KB, committed=");
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=MB" });
    output = new Outputreplacedyzer(pb.start());
    output.shouldContain("MB, committed=");
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=GB" });
    output = new Outputreplacedyzer(pb.start());
    output.shouldContain("GB, committed=");
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=apa" });
    output = new Outputreplacedyzer(pb.start());
    output.shouldContain("Incorrect scale value: apa");
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=GB" });
    output = new Outputreplacedyzer(pb.start());
    output.shouldContain("GB, committed=");
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary", "scale=apa" });
    output = new Outputreplacedyzer(pb.start());
    output.shouldContain("Incorrect scale value: apa");
}

17 View Complete Implementation : SafepointCleanupTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
static void replacedyzeOutputOn(ProcessBuilder pb) throws Exception {
    Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
    output.shouldContain("[safepoint,cleanup]");
    output.shouldContain("deflating idle monitors");
    output.shouldContain("updating inline caches");
    output.shouldContain("compilation policy safepoint handler");
    output.shouldContain("mark nmethods");
    output.shouldContain("purging clreplaced loader data graph");
    output.shouldHaveExitValue(0);
}

17 View Complete Implementation : JcmdBaselineDetail.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void main(String[] args) throws Exception {
    // Grab my own PID
    String pid = Long.toString(ProcessTools.getProcessId());
    Outputreplacedyzer output;
    ProcessBuilder pb = new ProcessBuilder();
    // Run 'jcmd <pid> VM.native_memory baseline=true'
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "baseline=true" });
    output = new Outputreplacedyzer(pb.start());
    output.shouldContain("Baseline succeeded");
}

17 View Complete Implementation : IhopUtils.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Finds strings which contains patterns for finding.
 *
 * @param outputreplacedyzer List of string for IHOP messages extraction
 * @param stringsToFind Strings which is checked for matching with Outputreplacedyzer content
 * @return List of strings which were matched.
 */
private static List<String> findInLog(Outputreplacedyzer outputreplacedyzer, String... stringsToFind) {
    return outputreplacedyzer.asLines().stream().filter(string -> {
        return Stream.of(stringsToFind).filter(find -> string.contains(find)).findAny().isPresent();
    }).collect(Collectors.toList());
}

17 View Complete Implementation : RedefineLeak.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void main(String[] argv) throws Exception {
    if (argv.length == 1 && argv[0].equals("buildagent")) {
        buildAgent();
        return;
    }
    if (argv.length == 1 && argv[0].equals("runtest")) {
        // run outside of jtreg to not OOM on jtreg clreplacedes that are loaded after metaspace is full
        String[] javaArgs1 = { "-XX:MetaspaceSize=12m", "-XX:MaxMetaspaceSize=12m", "-javaagent:redefineagent.jar", "RedefineLeak" };
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(javaArgs1);
        Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
        output.shouldContain("transformCount:10000");
    }
}

17 View Complete Implementation : TestInitialTenuringThreshold.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void main(String[] args) throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(// some value below the default value of InitialTenuringThreshold of 7
    "-XX:MaxTenuringThreshold=1", "-version");
    Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
    output.shouldHaveExitValue(0);
    // successful tests
    runWithThresholds(0, 10, false);
    runWithThresholds(5, 5, false);
    runWithThresholds(8, 16, false);
    // failing tests
    runWithThresholds(10, 0, true);
    runWithThresholds(9, 8, true);
    runWithThresholds(-1, 8, true);
    runWithThresholds(0, -1, true);
    runWithThresholds(8, -1, true);
    runWithThresholds(16, 8, true);
    runWithThresholds(8, 17, true);
}

17 View Complete Implementation : ShutdownTwice.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void main(String[] args) throws Exception {
    // Grab my own PID
    String pid = Long.toString(ProcessTools.getProcessId());
    Outputreplacedyzer output;
    ProcessBuilder pb = new ProcessBuilder();
    // Run 'jcmd <pid> VM.native_memory shutdown'
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "shutdown" });
    output = new Outputreplacedyzer(pb.start());
    // Verify that jcmd reports that NMT is shutting down
    output.shouldContain("Native memory tracking has been turned off");
    // Run shutdown again
    output = new Outputreplacedyzer(pb.start());
    // Verify that jcmd reports that NMT has been shutdown already
    output.shouldContain("Native memory tracking has been shutdown");
}

17 View Complete Implementation : DumpSymbolAndStringTable.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void main(String[] args) throws Exception {
    // Grab my own PID
    String pid = Long.toString(ProcessTools.getProcessId());
    ProcessBuilder pb = new ProcessBuilder();
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.symboltable", "-verbose" });
    Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
    try {
        output.shouldContain("24 2: DumpSymbolAndStringTable\n");
    } catch (RuntimeException e) {
        output.shouldContain("Unknown diagnostic command");
    }
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.stringtable", "-verbose" });
    output = new Outputreplacedyzer(pb.start());
    try {
        output.shouldContain("16: java.lang.String\n");
    } catch (RuntimeException e) {
        output.shouldContain("Unknown diagnostic command");
    }
}

17 View Complete Implementation : ClassAndLibraryNotMatchTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
private void runAndCheckHelloWorld(String checkString) {
    ProcessBuilder pb;
    try {
        pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".", "-XX:+UseAOT", "-XX:AOTLibrary=./" + LIB_NAME, HELLO_WORLD_CLreplaced_NAME);
    } catch (Exception e) {
        throw new Error("Can't create ProcessBuilder to run " + HELLO_WORLD_CLreplaced_NAME + " " + e, e);
    }
    Outputreplacedyzer oa;
    try {
        oa = ProcessTools.executeProcess(pb);
    } catch (Exception e) {
        throw new Error("Can't execute " + HELLO_WORLD_CLreplaced_NAME + " " + e, e);
    }
    oa.shouldHaveExitValue(0);
    oa.shouldContain(checkString);
}

17 View Complete Implementation : BootAppendTests.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
// Test #3: If a clreplaced on -Xbootclreplacedpath/a is from a package defined in boot modules,
// the clreplaced can be loaded from -Xbootclreplacedpath/a when the module is excluded
// using --limit-modules. Verify the behavior is the same at runtime when CDS
// is enabled.
// 
// The java.desktop module is excluded using --limit-modules at runtime,
// javax.sound.sampled.MyClreplaced is archived from -Xbootclreplacedpath/a. It can be
// loaded from the archive at runtime.
public static void testBootAppendExcludedModuleClreplaced() throws Exception {
    for (String mode : modes) {
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./BootAppendTests.jsa", "-XX:+TraceClreplacedLoading", "-cp", appJar, "-Xbootclreplacedpath/a:" + bootAppendJar, "--limit-modules=java.base", "-Xshare:" + mode, APP_CLreplaced, BOOT_APPEND_MODULE_CLreplaced_NAME);
        Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
        output.shouldContain("[clreplaced,load] javax.sound.sampled.MyClreplaced");
        // When CDS is enabled, the shared clreplaced should be loaded from the archive.
        if (mode.equals("on")) {
            output.shouldContain("[clreplaced,load] javax.sound.sampled.MyClreplaced source: shared objects file");
        }
    }
}

17 View Complete Implementation : TestAESIntrinsicsOnSupportedConfig.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Test checks following situation: <br/>
 * UseAES flag is set to false, TestAESMain is executed <br/>
 * Expected result: UseAESIntrinsics flag is set to false <br/>
 * Output shouldn't contain intrinsics usage <br/>
 *
 * @throws Throwable
 */
private void testNoUseAES() throws Throwable {
    Outputreplacedyzer outputreplacedyzer = ProcessTools.executeTestJvm(prepareArguments(prepareBooleanFlag(AESIntrinsicsBase.USE_AES, false)));
    final String errorMessage = "Case testNoUseAES failed";
    verifyOutput(null, new String[] { AESIntrinsicsBase.CIPHER_INTRINSIC, AESIntrinsicsBase.AES_INTRINSIC }, errorMessage, outputreplacedyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES, "false", errorMessage, outputreplacedyzer);
    verifyOptionValue(AESIntrinsicsBase.USE_AES_INTRINSICS, "false", errorMessage, outputreplacedyzer);
}

17 View Complete Implementation : TestPLABEvacuationFailure.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
private static void runTest(int wastePct, int plabSize, int parGCThreads, int heapSize, boolean plabIsFixed) throws Throwable {
    System.out.println("Test case details:");
    System.out.println("  Heap size : " + heapSize + "M");
    System.out.println("  Initial PLAB size : " + plabSize);
    System.out.println("  Parallel GC buffer waste pct : " + wastePct);
    System.out.println("  Parallel GC threads : " + parGCThreads);
    System.out.println("  PLAB size is fixed: " + (plabIsFixed ? "yes" : "no"));
    // Set up test GC and PLAB options
    List<String> testOptions = new ArrayList<>();
    Collections.addAll(testOptions, COMMON_OPTIONS);
    Collections.addAll(testOptions, Utils.getTestJavaOpts());
    Collections.addAll(testOptions, "-XX:ParallelGCThreads=" + parGCThreads, "-XX:ParallelGCBufferWastePct=" + wastePct, "-XX:OldPLABSize=" + plabSize, "-XX:YoungPLABSize=" + plabSize, "-XX:" + (plabIsFixed ? "-" : "+") + "ResizePLAB", "-XX:MaxHeapSize=" + heapSize + "m");
    testOptions.add(AppPLABEvacuationFailure.clreplaced.getName());
    Outputreplacedyzer out = ProcessTools.executeTestJvm(testOptions.toArray(new String[testOptions.size()]));
    appPlabEvacFailureOutput = out.getOutput();
    if (out.getExitValue() != 0) {
        System.out.println(appPlabEvacFailureOutput);
        throw new RuntimeException("Expect exit code 0.");
    }
    // Get list of GC ID on evacuation failure
    evacuationFailureIDs = getGcIdPlabEvacFailures(out);
    logParser = new LogParser(appPlabEvacFailureOutput);
    checkResults();
}

17 View Complete Implementation : TestStringDeduplicationTools.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void testAgeThreshold() throws Exception {
    Outputreplacedyzer output;
    // Test with max age theshold
    output = DeduplicationTest.run(SmallNumberOfStrings, MaxAgeThreshold, YoungGC, "-Xlog:gc,gc+stringdedup=trace");
    output.shouldContain("Concurrent String Deduplication");
    output.shouldContain("Deduplicated:");
    output.shouldHaveExitValue(0);
    // Test with min age theshold
    output = DeduplicationTest.run(SmallNumberOfStrings, MinAgeThreshold, YoungGC, "-Xlog:gc,gc+stringdedup=trace");
    output.shouldContain("Concurrent String Deduplication");
    output.shouldContain("Deduplicated:");
    output.shouldHaveExitValue(0);
    // Test with too low age threshold
    output = DeduplicationTest.run(SmallNumberOfStrings, TooLowAgeThreshold, YoungGC);
    output.shouldContain("outside the allowed range");
    output.shouldHaveExitValue(1);
    // Test with too high age threshold
    output = DeduplicationTest.run(SmallNumberOfStrings, TooHighAgeThreshold, YoungGC);
    output.shouldContain("outside the allowed range");
    output.shouldHaveExitValue(1);
}

17 View Complete Implementation : JInfoTest.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
private static Outputreplacedyzer jinfo(String... toolArgs) throws Exception {
    JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jinfo");
    if (toolArgs != null) {
        for (String toolArg : toolArgs) {
            launcher.addToolArg(toolArg);
        }
    }
    processBuilder.command(launcher.getCommand());
    Outputreplacedyzer output = ProcessTools.executeProcess(processBuilder);
    return output;
}

17 View Complete Implementation : RTMTestBase.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
/**
 * Executes test case and save compilation log to {@code logFileName}.
 *
 * @param logFileName a name of compilation log file
 * @param test a test case to execute case to execute
 * @param options additional options to VM
 * @return Outputreplacedyzer for started test case
 * @throws Exception when something went wrong
 */
public static Outputreplacedyzer executeRTMTest(String logFileName, CompilableTest test, String... options) throws Exception {
    ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(RTMTestBase.prepareTestOptions(logFileName, test, options));
    Outputreplacedyzer outputreplacedyzer = new Outputreplacedyzer(processBuilder.start());
    System.out.println(outputreplacedyzer.getOutput());
    return outputreplacedyzer;
}

17 View Complete Implementation : VMDeprecatedOptions.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
static void testDeprecated(String[][] optionInfo) throws Throwable {
    String[] optionNames = new String[optionInfo.length];
    String[] expectedValues = new String[optionInfo.length];
    for (int i = 0; i < optionInfo.length; i++) {
        optionNames[i] = optionInfo[i][0];
        expectedValues[i] = optionInfo[i][1];
    }
    Outputreplacedyzer output = CommandLineOptionTest.startVMWithOptions(optionNames, expectedValues);
    // check for option deprecation messages:
    output.shouldHaveExitValue(0);
    for (String[] deprecated : optionInfo) {
        String match = getDeprecationString(deprecated[0]);
        output.shouldMatch(match);
    }
}

17 View Complete Implementation : FPRegs.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void main(String[] args) throws IOException {
    Path launcher = Paths.get(System.getProperty("test.nativepath"), "FPRegs" + (Platform.isWindows() ? ".exe" : ""));
    System.out.println("Launcher = " + launcher + (Files.exists(launcher) ? " (exists)" : " (not exists)"));
    Path jvmLib = findJVM();
    ProcessBuilder pb = new ProcessBuilder(launcher.toString(), jvmLib.toString());
    // bin as working directory to let Windows load dll
    pb.directory(jvmLib.getParent().getParent().toFile());
    Outputreplacedyzer outputf = new Outputreplacedyzer(pb.start());
    outputf.shouldHaveExitValue(0);
}

17 View Complete Implementation : TestLargePageUseForAuxMemory.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
static void checkSize(Outputreplacedyzer output, long expectedSize, String pattern) {
    String pageSizeStr = output.firstMatch(pattern, 1);
    if (pageSizeStr == null) {
        output.reportDiagnosticSummary();
        throw new RuntimeException("Match from '" + pattern + "' got 'null' expected: " + expectedSize);
    }
    long size = parseMemoryString(pageSizeStr);
    if (size != expectedSize) {
        output.reportDiagnosticSummary();
        throw new RuntimeException("Match from '" + pattern + "' got " + size + " expected: " + expectedSize);
    }
}

17 View Complete Implementation : NMTWithCDS.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static void main(String[] args) throws Exception {
    ProcessBuilder pb;
    pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./NMTWithCDS.jsa", "-Xshare:dump");
    Outputreplacedyzer output = new Outputreplacedyzer(pb.start());
    try {
        output.shouldContain("Loading clreplacedes to share");
        output.shouldHaveExitValue(0);
        pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:NativeMemoryTracking=detail", "-XX:SharedArchiveFile=./NMTWithCDS.jsa", "-Xshare:on", "-version");
        output = new Outputreplacedyzer(pb.start());
        output.shouldContain("sharing");
        output.shouldHaveExitValue(0);
    } catch (RuntimeException e) {
        // Report 'preplaceded' if CDS was turned off.
        output.shouldContain("Unable to use shared archive");
        output.shouldHaveExitValue(1);
    }
}