Java Code Examples for com.oracle.java.testlibrary.Platform#isOSX()

The following examples show how to use com.oracle.java.testlibrary.Platform#isOSX() . 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: 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);
}
 
Example 2
Source File: DynLibDcmdTest.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 result = DcmdUtil.executeDcmd("VM.dynlibs");

    String osDependentBaseString = null;
    if (Platform.isSolaris()) {
        osDependentBaseString = "lib%s.so";
    } else if (Platform.isWindows()) {
        osDependentBaseString = "%s.dll";
    } else if (Platform.isOSX()) {
        osDependentBaseString = "lib%s.dylib";
    } else if (Platform.isLinux()) {
        osDependentBaseString = "lib%s.so";
    }

    if (osDependentBaseString == null) {
        throw new Exception("Unsupported OS");
    }

    Set<String> expectedContent = new HashSet<>();
    expectedContent.add(String.format(osDependentBaseString, "jvm"));
    expectedContent.add(String.format(osDependentBaseString, "java"));
    expectedContent.add(String.format(osDependentBaseString, "management"));

    for(String expected : expectedContent) {
        if (!result.contains(expected)) {
            throw new Exception("Dynamic library list output did not contain the expected string: '" + expected + "'");
        }
    }
}
 
Example 3
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 4
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 5
Source File: DynLibDcmdTest.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 result = DcmdUtil.executeDcmd("VM.dynlibs");

    String osDependentBaseString = null;
    if (Platform.isSolaris()) {
        osDependentBaseString = "lib%s.so";
    } else if (Platform.isWindows()) {
        osDependentBaseString = "%s.dll";
    } else if (Platform.isOSX()) {
        osDependentBaseString = "lib%s.dylib";
    } else if (Platform.isLinux()) {
        osDependentBaseString = "lib%s.so";
    }

    if (osDependentBaseString == null) {
        throw new Exception("Unsupported OS");
    }

    Set<String> expectedContent = new HashSet<>();
    expectedContent.add(String.format(osDependentBaseString, "jvm"));
    expectedContent.add(String.format(osDependentBaseString, "java"));
    expectedContent.add(String.format(osDependentBaseString, "management"));

    for(String expected : expectedContent) {
        if (!result.contains(expected)) {
            throw new Exception("Dynamic library list output did not contain the expected string: '" + expected + "'");
        }
    }
}
 
Example 6
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 7
Source File: DynLibDcmdTest.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 result = DcmdUtil.executeDcmd("VM.dynlibs");

    String osDependentBaseString = null;
    if (Platform.isSolaris()) {
        osDependentBaseString = "lib%s.so";
    } else if (Platform.isWindows()) {
        osDependentBaseString = "%s.dll";
    } else if (Platform.isOSX()) {
        osDependentBaseString = "lib%s.dylib";
    } else if (Platform.isLinux()) {
        osDependentBaseString = "lib%s.so";
    }

    if (osDependentBaseString == null) {
        throw new Exception("Unsupported OS");
    }

    Set<String> expectedContent = new HashSet<>();
    expectedContent.add(String.format(osDependentBaseString, "jvm"));
    expectedContent.add(String.format(osDependentBaseString, "java"));
    expectedContent.add(String.format(osDependentBaseString, "management"));

    for(String expected : expectedContent) {
        if (!result.contains(expected)) {
            throw new Exception("Dynamic library list output did not contain the expected string: '" + expected + "'");
        }
    }
}
 
Example 8
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 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: 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);
}