com.oracle.java.testlibrary.JDKToolFinder Java Examples

The following examples show how to use com.oracle.java.testlibrary.JDKToolFinder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FinalizerInfoTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void run() throws Exception {
    try {
        lock.lock();
        for(int i = 0; i < objectsCount; ++i) {
            new MyObject();
        }
        System.out.println("Objects initialized: " + objectsCount);
        System.gc();

        while(wasTrapped < 1) {
            // Waiting for gc thread.
        }


        String pid = Integer.toString(ProcessTools.getProcessId());
        ProcessBuilder pb = new ProcessBuilder();
        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, cmd});
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
        output.shouldContain("MyObject");
    } finally {
        lock.unlock();
    }
}
 
Example #2
Source File: FinalizerInfoTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void run() throws Exception {
    try {
        lock.lock();
        for(int i = 0; i < objectsCount; ++i) {
            new MyObject();
        }
        System.out.println("Objects initialized: " + objectsCount);
        System.gc();

        while(wasTrapped < 1) {
            // Waiting for gc thread.
        }


        String pid = Integer.toString(ProcessTools.getProcessId());
        ProcessBuilder pb = new ProcessBuilder();
        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, cmd});
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
        output.shouldContain("MyObject");
    } finally {
        lock.unlock();
    }
}
 
Example #3
Source File: FinalizerInfoTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
void run() throws Exception {
    try {
        lock.lock();
        for(int i = 0; i < objectsCount; ++i) {
            new MyObject();
        }
        System.out.println("Objects initialized: " + objectsCount);
        System.gc();

        while(wasTrapped < 1) {
            // Waiting for gc thread.
        }


        String pid = Integer.toString(ProcessTools.getProcessId());
        ProcessBuilder pb = new ProcessBuilder();
        pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, cmd});
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
        output.shouldContain("MyObject");
    } finally {
        lock.unlock();
    }
}
 
Example #4
Source File: TestVerifyDuringStartup.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  ArrayList<String> vmOpts = new ArrayList();

  String testVmOptsStr = System.getProperty("test.java.opts");
  if (!testVmOptsStr.isEmpty()) {
    String[] testVmOpts = testVmOptsStr.split(" ");
    Collections.addAll(vmOpts, testVmOpts);
  }
  Collections.addAll(vmOpts, new String[] {"-XX:-UseTLAB",
                                           "-XX:+UnlockDiagnosticVMOptions",
                                           "-XX:+VerifyDuringStartup",
                                           "-version"});

  System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
  for (int i = 0; i < vmOpts.size(); i += 1) {
    System.out.print(" " + vmOpts.get(i));
  }
  System.out.println();

  ProcessBuilder pb =
    ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  System.out.println("Output:\n" + output.getOutput());

  output.shouldContain("[Verifying");
  output.shouldHaveExitValue(0);
}
 
Example #5
Source File: CtwTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected ProcessBuilder createJarProcessBuilder(String... command)
        throws Exception {
    String javapath = JDKToolFinder.getJDKTool("jar");

    ArrayList<String> args = new ArrayList<>();
    args.add(javapath);
    Collections.addAll(args, command);

    return new ProcessBuilder(args.toArray(new String[args.size()]));
}
 
Example #6
Source File: JMapHProfLargeHeapTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    // If we are on MacOSX, test if JMap tool is signed, otherwise return
    // since test will fail with privilege error.
    if (Platform.isOSX()) {
        String jmapToolPath = JDKToolFinder.getTestJDKTool("jmap");
        ProcessBuilder codesignProcessBuilder = new ProcessBuilder(
                "codesign", "-v", jmapToolPath);
        Process codesignProcess = codesignProcessBuilder.start();
        OutputAnalyzer analyser = new OutputAnalyzer(codesignProcess);
        try {
            analyser.shouldNotContain("code object is not signed at all");
            System.out.println("Signed jmap found at: " + jmapToolPath);
        } catch (Exception e) {
            // Abort since we can't know if the test will work
            System.out
                    .println("Test aborted since we are on MacOSX and the jmap tool is not signed.");
            return;
        }
    }

    // Small heap 22 megabytes, should create 1.0.1 file format
    testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_1);

    /**
     * This test was deliberately commented out since the test system lacks
     * support to handle the requirements for this kind of heap size in a
     * good way. If or when it becomes possible to run this kind of tests in
     * the test environment the test should be enabled again.
     * */
    // Large heap 2,2 gigabytes, should create 1.0.2 file format
    // testHProfFileFormat("-Xmx4g", 2 * G + 2 * M, HPROF_HEADER_1_0_2);
}
 
Example #7
Source File: TestVerifyDuringStartup.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  ArrayList<String> vmOpts = new ArrayList();

  String testVmOptsStr = System.getProperty("test.java.opts");
  if (!testVmOptsStr.isEmpty()) {
    String[] testVmOpts = testVmOptsStr.split(" ");
    Collections.addAll(vmOpts, testVmOpts);
  }
  Collections.addAll(vmOpts, new String[] {"-XX:-UseTLAB",
                                           "-XX:+UnlockDiagnosticVMOptions",
                                           "-XX:+VerifyDuringStartup",
                                           "-version"});

  System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
  for (int i = 0; i < vmOpts.size(); i += 1) {
    System.out.print(" " + vmOpts.get(i));
  }
  System.out.println();

  ProcessBuilder pb =
    ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  System.out.println("Output:\n" + output.getOutput());

  output.shouldContain("[Verifying");
  output.shouldHaveExitValue(0);
}
 
Example #8
Source File: CtwTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected ProcessBuilder createJarProcessBuilder(String... command)
        throws Exception {
    String javapath = JDKToolFinder.getJDKTool("jar");

    ArrayList<String> args = new ArrayList<>();
    args.add(javapath);
    Collections.addAll(args, command);

    return new ProcessBuilder(args.toArray(new String[args.size()]));
}
 
Example #9
Source File: JMapHProfLargeHeapTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    // If we are on MacOSX, test if JMap tool is signed, otherwise return
    // since test will fail with privilege error.
    if (Platform.isOSX()) {
        String jmapToolPath = JDKToolFinder.getTestJDKTool("jmap");
        ProcessBuilder codesignProcessBuilder = new ProcessBuilder(
                "codesign", "-v", jmapToolPath);
        Process codesignProcess = codesignProcessBuilder.start();
        OutputAnalyzer analyser = new OutputAnalyzer(codesignProcess);
        try {
            analyser.shouldNotContain("code object is not signed at all");
            System.out.println("Signed jmap found at: " + jmapToolPath);
        } catch (Exception e) {
            // Abort since we can't know if the test will work
            System.out
                    .println("Test aborted since we are on MacOSX and the jmap tool is not signed.");
            return;
        }
    }

    // Small heap 22 megabytes, should create 1.0.1 file format
    testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_1);

    /**
     * This test was deliberately commented out since the test system lacks
     * support to handle the requirements for this kind of heap size in a
     * good way. If or when it becomes possible to run this kind of tests in
     * the test environment the test should be enabled again.
     * */
    // Large heap 2,2 gigabytes, should create 1.0.2 file format
    // testHProfFileFormat("-Xmx4g", 2 * G + 2 * M, HPROF_HEADER_1_0_2);
}
 
Example #10
Source File: TestVerifyDuringStartup.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  ArrayList<String> vmOpts = new ArrayList();

  String testVmOptsStr = System.getProperty("test.java.opts");
  if (!testVmOptsStr.isEmpty()) {
    String[] testVmOpts = testVmOptsStr.split(" ");
    Collections.addAll(vmOpts, testVmOpts);
  }
  Collections.addAll(vmOpts, new String[] {"-XX:-UseTLAB",
                                           "-XX:+UnlockDiagnosticVMOptions",
                                           "-XX:+VerifyDuringStartup",
                                           "-version"});

  System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
  for (int i = 0; i < vmOpts.size(); i += 1) {
    System.out.print(" " + vmOpts.get(i));
  }
  System.out.println();

  ProcessBuilder pb =
    ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  System.out.println("Output:\n" + output.getOutput());

  output.shouldContain("[Verifying");
  output.shouldHaveExitValue(0);
}
 
Example #11
Source File: CtwTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected ProcessBuilder createJarProcessBuilder(String... command)
        throws Exception {
    String javapath = JDKToolFinder.getJDKTool("jar");

    ArrayList<String> args = new ArrayList<>();
    args.add(javapath);
    Collections.addAll(args, command);

    return new ProcessBuilder(args.toArray(new String[args.size()]));
}
 
Example #12
Source File: JMapHProfLargeHeapTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    // If we are on MacOSX, test if JMap tool is signed, otherwise return
    // since test will fail with privilege error.
    if (Platform.isOSX()) {
        String jmapToolPath = JDKToolFinder.getTestJDKTool("jmap");
        ProcessBuilder codesignProcessBuilder = new ProcessBuilder(
                "codesign", "-v", jmapToolPath);
        Process codesignProcess = codesignProcessBuilder.start();
        OutputAnalyzer analyser = new OutputAnalyzer(codesignProcess);
        try {
            analyser.shouldNotContain("code object is not signed at all");
            System.out.println("Signed jmap found at: " + jmapToolPath);
        } catch (Exception e) {
            // Abort since we can't know if the test will work
            System.out
                    .println("Test aborted since we are on MacOSX and the jmap tool is not signed.");
            return;
        }
    }

    // Small heap 22 megabytes, should create 1.0.1 file format
    testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_1);

    /**
     * This test was deliberately commented out since the test system lacks
     * support to handle the requirements for this kind of heap size in a
     * good way. If or when it becomes possible to run this kind of tests in
     * the test environment the test should be enabled again.
     * */
    // Large heap 2,2 gigabytes, should create 1.0.2 file format
    // testHProfFileFormat("-Xmx4g", 2 * G + 2 * M, HPROF_HEADER_1_0_2);
}
 
Example #13
Source File: TestVerifyDuringStartup.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  ArrayList<String> vmOpts = new ArrayList();

  String testVmOptsStr = System.getProperty("test.java.opts");
  if (!testVmOptsStr.isEmpty()) {
    String[] testVmOpts = testVmOptsStr.split(" ");
    Collections.addAll(vmOpts, testVmOpts);
  }
  Collections.addAll(vmOpts, new String[] {"-XX:-UseTLAB",
                                           "-XX:+UnlockDiagnosticVMOptions",
                                           "-XX:+VerifyDuringStartup",
                                           "-version"});

  System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
  for (int i = 0; i < vmOpts.size(); i += 1) {
    System.out.print(" " + vmOpts.get(i));
  }
  System.out.println();

  ProcessBuilder pb =
    ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  System.out.println("Output:\n" + output.getOutput());

  output.shouldContain("[Verifying");
  output.shouldHaveExitValue(0);
}
 
Example #14
Source File: CtwTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected ProcessBuilder createJarProcessBuilder(String... command)
        throws Exception {
    String javapath = JDKToolFinder.getJDKTool("jar");

    ArrayList<String> args = new ArrayList<>();
    args.add(javapath);
    Collections.addAll(args, command);

    return new ProcessBuilder(args.toArray(new String[args.size()]));
}
 
Example #15
Source File: HeapInfoTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    String pid = Integer.toString(ProcessTools.getProcessId());
    ProcessBuilder pb = new ProcessBuilder();
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "GC.heap_info"});
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    output.shouldContain("Metaspace");
}
 
Example #16
Source File: JMapHProfLargeHeapTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    // If we are on MacOSX, test if JMap tool is signed, otherwise return
    // since test will fail with privilege error.
    if (Platform.isOSX()) {
        String jmapToolPath = JDKToolFinder.getTestJDKTool("jmap");
        ProcessBuilder codesignProcessBuilder = new ProcessBuilder(
                "codesign", "-v", jmapToolPath);
        Process codesignProcess = codesignProcessBuilder.start();
        OutputAnalyzer analyser = new OutputAnalyzer(codesignProcess);
        try {
            analyser.shouldNotContain("code object is not signed at all");
            System.out.println("Signed jmap found at: " + jmapToolPath);
        } catch (Exception e) {
            // Abort since we can't know if the test will work
            System.out
                    .println("Test aborted since we are on MacOSX and the jmap tool is not signed.");
            return;
        }
    }

    // Small heap 22 megabytes, should create 1.0.1 file format
    testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_1);

    /**
     * This test was deliberately commented out since the test system lacks
     * support to handle the requirements for this kind of heap size in a
     * good way. If or when it becomes possible to run this kind of tests in
     * the test environment the test should be enabled again.
     * */
    // Large heap 2,2 gigabytes, should create 1.0.2 file format
    // testHProfFileFormat("-Xmx4g", 2 * G + 2 * M, HPROF_HEADER_1_0_2);
}
 
Example #17
Source File: TestVerifyDuringStartup.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  ArrayList<String> vmOpts = new ArrayList();

  String testVmOptsStr = System.getProperty("test.java.opts");
  if (!testVmOptsStr.isEmpty()) {
    String[] testVmOpts = testVmOptsStr.split(" ");
    Collections.addAll(vmOpts, testVmOpts);
  }
  Collections.addAll(vmOpts, new String[] {"-XX:-UseTLAB",
                                           "-XX:+UnlockDiagnosticVMOptions",
                                           "-XX:+VerifyDuringStartup",
                                           "-version"});

  System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
  for (int i = 0; i < vmOpts.size(); i += 1) {
    System.out.print(" " + vmOpts.get(i));
  }
  System.out.println();

  ProcessBuilder pb =
    ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  System.out.println("Output:\n" + output.getOutput());

  output.shouldContain("[Verifying");
  output.shouldHaveExitValue(0);
}
 
Example #18
Source File: CtwTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected ProcessBuilder createJarProcessBuilder(String... command)
        throws Exception {
    String javapath = JDKToolFinder.getJDKTool("jar");

    ArrayList<String> args = new ArrayList<>();
    args.add(javapath);
    Collections.addAll(args, command);

    return new ProcessBuilder(args.toArray(new String[args.size()]));
}
 
Example #19
Source File: HeapInfoTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    String pid = Integer.toString(ProcessTools.getProcessId());
    ProcessBuilder pb = new ProcessBuilder();
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "GC.heap_info"});
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    output.shouldContain("Metaspace");
}
 
Example #20
Source File: JMapHProfLargeHeapTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    // If we are on MacOSX, test if JMap tool is signed, otherwise return
    // since test will fail with privilege error.
    if (Platform.isOSX()) {
        String jmapToolPath = JDKToolFinder.getTestJDKTool("jmap");
        ProcessBuilder codesignProcessBuilder = new ProcessBuilder(
                "codesign", "-v", jmapToolPath);
        Process codesignProcess = codesignProcessBuilder.start();
        OutputAnalyzer analyser = new OutputAnalyzer(codesignProcess);
        try {
            analyser.shouldNotContain("code object is not signed at all");
            System.out.println("Signed jmap found at: " + jmapToolPath);
        } catch (Exception e) {
            // Abort since we can't know if the test will work
            System.out
                    .println("Test aborted since we are on MacOSX and the jmap tool is not signed.");
            return;
        }
    }

    // All heap dumps should create 1.0.2 file format
    testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_2);

    /**
     * This test was deliberately commented out since the test system lacks
     * support to handle the requirements for this kind of heap size in a
     * good way. If or when it becomes possible to run this kind of tests in
     * the test environment the test should be enabled again.
     * */
    // Large heap 2,2 gigabytes, should create 1.0.2 file format
    // testHProfFileFormat("-Xmx4g", 2 * G + 2 * M, HPROF_HEADER_1_0_2);
}
 
Example #21
Source File: TestVerifyDuringStartup.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  ArrayList<String> vmOpts = new ArrayList();

  String testVmOptsStr = System.getProperty("test.java.opts");
  if (!testVmOptsStr.isEmpty()) {
    String[] testVmOpts = testVmOptsStr.split(" ");
    Collections.addAll(vmOpts, testVmOpts);
  }
  Collections.addAll(vmOpts, new String[] {"-XX:-UseTLAB",
                                           "-XX:+UnlockDiagnosticVMOptions",
                                           "-XX:+VerifyDuringStartup",
                                           "-version"});

  System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
  for (int i = 0; i < vmOpts.size(); i += 1) {
    System.out.print(" " + vmOpts.get(i));
  }
  System.out.println();

  ProcessBuilder pb =
    ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  System.out.println("Output:\n" + output.getOutput());

  output.shouldContain("[Verifying");
  output.shouldHaveExitValue(0);
}
 
Example #22
Source File: CtwTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected ProcessBuilder createJarProcessBuilder(String... command)
        throws Exception {
    String javapath = JDKToolFinder.getJDKTool("jar");

    ArrayList<String> args = new ArrayList<>();
    args.add(javapath);
    Collections.addAll(args, command);

    return new ProcessBuilder(args.toArray(new String[args.size()]));
}
 
Example #23
Source File: JMapHProfLargeHeapTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    // If we are on MacOSX, test if JMap tool is signed, otherwise return
    // since test will fail with privilege error.
    if (Platform.isOSX()) {
        String jmapToolPath = JDKToolFinder.getTestJDKTool("jmap");
        ProcessBuilder codesignProcessBuilder = new ProcessBuilder(
                "codesign", "-v", jmapToolPath);
        Process codesignProcess = codesignProcessBuilder.start();
        OutputAnalyzer analyser = new OutputAnalyzer(codesignProcess);
        try {
            analyser.shouldNotContain("code object is not signed at all");
            System.out.println("Signed jmap found at: " + jmapToolPath);
        } catch (Exception e) {
            // Abort since we can't know if the test will work
            System.out
                    .println("Test aborted since we are on MacOSX and the jmap tool is not signed.");
            return;
        }
    }

    // Small heap 22 megabytes, should create 1.0.1 file format
    testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_1);

    /**
     * This test was deliberately commented out since the test system lacks
     * support to handle the requirements for this kind of heap size in a
     * good way. If or when it becomes possible to run this kind of tests in
     * the test environment the test should be enabled again.
     * */
    // Large heap 2,2 gigabytes, should create 1.0.2 file format
    // testHProfFileFormat("-Xmx4g", 2 * G + 2 * M, HPROF_HEADER_1_0_2);
}
 
Example #24
Source File: TestVerifyDuringStartup.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  ArrayList<String> vmOpts = new ArrayList();

  String testVmOptsStr = System.getProperty("test.java.opts");
  if (!testVmOptsStr.isEmpty()) {
    String[] testVmOpts = testVmOptsStr.split(" ");
    Collections.addAll(vmOpts, testVmOpts);
  }
  Collections.addAll(vmOpts, new String[] {"-XX:-UseTLAB",
                                           "-XX:+UnlockDiagnosticVMOptions",
                                           "-XX:+VerifyDuringStartup",
                                           "-version"});

  System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
  for (int i = 0; i < vmOpts.size(); i += 1) {
    System.out.print(" " + vmOpts.get(i));
  }
  System.out.println();

  ProcessBuilder pb =
    ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  System.out.println("Output:\n" + output.getOutput());

  output.shouldContain("[Verifying");
  output.shouldHaveExitValue(0);
}
 
Example #25
Source File: CtwTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected ProcessBuilder createJarProcessBuilder(String... command)
        throws Exception {
    String javapath = JDKToolFinder.getJDKTool("jar");

    ArrayList<String> args = new ArrayList<>();
    args.add(javapath);
    Collections.addAll(args, command);

    return new ProcessBuilder(args.toArray(new String[args.size()]));
}
 
Example #26
Source File: HeapInfoTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    String pid = Integer.toString(ProcessTools.getProcessId());
    ProcessBuilder pb = new ProcessBuilder();
    pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "GC.heap_info"});
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    output.shouldContain("Metaspace");
}
 
Example #27
Source File: JMapHProfLargeHeapTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    // If we are on MacOSX, test if JMap tool is signed, otherwise return
    // since test will fail with privilege error.
    if (Platform.isOSX()) {
        String jmapToolPath = JDKToolFinder.getTestJDKTool("jmap");
        ProcessBuilder codesignProcessBuilder = new ProcessBuilder(
                "codesign", "-v", jmapToolPath);
        Process codesignProcess = codesignProcessBuilder.start();
        OutputAnalyzer analyser = new OutputAnalyzer(codesignProcess);
        try {
            analyser.shouldNotContain("code object is not signed at all");
            System.out.println("Signed jmap found at: " + jmapToolPath);
        } catch (Exception e) {
            // Abort since we can't know if the test will work
            System.out
                    .println("Test aborted since we are on MacOSX and the jmap tool is not signed.");
            return;
        }
    }

    // Small heap 22 megabytes, should create 1.0.1 file format
    testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_1);

    /**
     * This test was deliberately commented out since the test system lacks
     * support to handle the requirements for this kind of heap size in a
     * good way. If or when it becomes possible to run this kind of tests in
     * the test environment the test should be enabled again.
     * */
    // Large heap 2,2 gigabytes, should create 1.0.2 file format
    // testHProfFileFormat("-Xmx4g", 2 * G + 2 * M, HPROF_HEADER_1_0_2);
}