Java Code Examples for jdk.test.lib.Platform#shouldSAAttach()

The following examples show how to use jdk.test.lib.Platform#shouldSAAttach() . 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 openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (!Platform.shouldSAAttach()) {
        System.out.println("SA attach not expected to work - test skipped.");
        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 2
Source File: TestPrintMdo.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main (String... args) throws Exception {

        LingeredApp app = null;

        if (!Platform.shouldSAAttach()) {
            System.out.println(
               "SA attach not expected to work - test skipped.");
            return;
        }

        try {
            List<String> vmArgs = new ArrayList<String>();
            vmArgs.add("-XX:+ProfileInterpreter");
            vmArgs.addAll(Utils.getVmOptions());

            app = LingeredApp.startApp(vmArgs);
            System.out.println ("Started LingeredApp with pid " + app.getPid());
            startClhsdbForPrintMdo(app.getPid());
            verifyPrintMdoOutput();
        } finally {
            LingeredApp.stopApp(app);
        }
    }
 
Example 3
Source File: TestInstanceKlassSize.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (!Platform.shouldSAAttach()) {
            System.out.println("SA attach not expected to work - test skipped.");
            return;
        }

        if (args == null || args.length == 0) {
            System.out.println ("No args run. Starting with args now.");
            startMeWithArgs();
        } else {
            String[] SAInstanceKlassNames = new String[] {
                                                "java.lang.Object",
                                                "java.util.Vector",
                                                "sun.util.PreHashedMap",
                                                "java.lang.String",
                                                "java.lang.Thread",
                                                "java.lang.Byte"
                                             };
            SAInstanceKlassSize(Integer.parseInt(args[0]), SAInstanceKlassNames);
        }
    }
 
Example 4
Source File: BasicLauncherTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (!Platform.shouldSAAttach()) {
            // Silently skip the test if we don't have enough permissions to attach
            System.err.println("Error! Insufficient permissions to attach.");
            return;
        }

        launchCLHSDB();

        launch("compiler detected", null, "jmap", "--clstats");
        launchJStack();
        launch("compiler detected", null, "jmap");
        launch("Java System Properties",
               "System Properties info not available", "jinfo");
        launch("java.threads", null, "jsnap");

        // The test throws RuntimeException on error.
        // IOException is thrown if LingeredApp can't start because of some bad
        // environment condition
        System.out.println("Test PASSED");
    }
 
Example 5
Source File: HeapDumpTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (!Platform.shouldSAAttach()) {
            // Silently skip the test if we don't have enough permissions to attach
            System.err.println("Error! Insufficient permissions to attach - test skipped.");
            return;
        }


        testHeapDump();

        // The test throws RuntimeException on error.
        // IOException is thrown if LingeredApp can't start because of some bad
        // environment condition
        System.out.println("Test PASSED");
    }
 
Example 6
Source File: TestInstanceKlassSizeForInterface.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main (String... args) throws Exception {
    String[] instanceKlassNames = new String[] {
                                      "Language",
                                      "ParselTongue",
                                      "LingeredAppWithInterface$1"
                                  };

    if (!Platform.shouldSAAttach()) {
        System.out.println(
           "SA attach not expected to work - test skipped.");
        return;
    }

    if (args == null || args.length == 0) {
        try {
            List<String> vmArgs = new ArrayList<String>();
            vmArgs.addAll(Utils.getVmOptions());

            theApp = new LingeredAppWithInterface();
            LingeredApp.startApp(vmArgs, theApp);
            createAnotherToAttach(instanceKlassNames,
                                  (int)theApp.getPid());
        } finally {
            LingeredApp.stopApp(theApp);
        }
    } else {
        SAInstanceKlassSize(Integer.parseInt(args[0]), instanceKlassNames);
    }
}
 
Example 7
Source File: TestHeapDumpForLargeArray.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main (String... args) throws Exception {

        String heapDumpFileName = "LargeArrayHeapDump.bin";

        if (!Platform.shouldSAAttach()) {
            System.out.println(
               "SA attach not expected to work - test skipped.");
            return;
        }

        File heapDumpFile = new File(heapDumpFileName);
        if (heapDumpFile.exists()) {
            heapDumpFile.delete();
        }

        try {
            List<String> vmArgs = new ArrayList<String>();
            vmArgs.add("-XX:+UsePerfData");
            vmArgs.add("-Xmx8g");
            vmArgs.addAll(Utils.getVmOptions());

            theApp = new LingeredAppWithLargeArray();
            LingeredApp.startApp(vmArgs, theApp);
            attachAndDump(heapDumpFileName, theApp.getPid());
        } finally {
            LingeredApp.stopApp(theApp);
            heapDumpFile.delete();
        }
    }
 
Example 8
Source File: TestCpoolForInvokeDynamic.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main (String... args) throws Exception {

        String[] instanceKlassNames = new String[] {
                                          "LingeredAppWithInvokeDynamic"
                                      };

        if (!Platform.shouldSAAttach()) {
            System.out.println(
               "SA attach not expected to work - test skipped.");
            return;
        }

        if (args == null || args.length == 0) {
            try {
                List<String> vmArgs = new ArrayList<String>();
                vmArgs.add("-XX:+UsePerfData");
                vmArgs.addAll(Utils.getVmOptions());

                theApp = new LingeredAppWithInvokeDynamic();
                LingeredApp.startApp(vmArgs, theApp);
                createAnotherToAttach(instanceKlassNames,
                                      theApp.getPid());
            } finally {
                LingeredApp.stopApp(theApp);
            }
        } else {
            printBytecodes(args[0], instanceKlassNames);
        }
    }
 
Example 9
Source File: TestDefaultMethods.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main (String... args) throws Exception {

        String[] instanceKlassNames = new String[] {
                                          "Language",
                                          "ParselTongue",
                                          "SlytherinSpeak"
                                      };

        if (!Platform.shouldSAAttach()) {
            System.out.println(
               "SA attach not expected to work - test skipped.");
            return;
        }

        if (args == null || args.length == 0) {
            try {
                List<String> vmArgs = new ArrayList<String>();
                vmArgs.add("-XX:+UsePerfData");
                vmArgs.addAll(Utils.getVmOptions());

                theApp = new LingeredAppWithDefaultMethods();
                LingeredApp.startApp(vmArgs, theApp);
                createAnotherToAttach(instanceKlassNames,
                                      theApp.getPid());
            } finally {
                LingeredApp.stopApp(theApp);
            }
        } else {
            printDefaultMethods(args[0], instanceKlassNames);
        }
    }
 
Example 10
Source File: TestHeapDumpForInvokeDynamic.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main (String... args) throws Exception {

        String heapDumpFileName = "lambdaHeapDump.bin";

        if (!Platform.shouldSAAttach()) {
            System.out.println(
               "SA attach not expected to work - test skipped.");
            return;
        }

        File heapDumpFile = new File(heapDumpFileName);
        if (heapDumpFile.exists()) {
            heapDumpFile.delete();
        }

        try {
            List<String> vmArgs = new ArrayList<String>();
            vmArgs.add("-XX:+UsePerfData");
            vmArgs.addAll(Utils.getVmOptions());

            theApp = new LingeredAppWithInvokeDynamic();
            LingeredApp.startApp(vmArgs, theApp);
            attachDumpAndVerify(heapDumpFileName, theApp.getPid());
        } finally {
            LingeredApp.stopApp(theApp);
        }
    }
 
Example 11
Source File: SASymbolTableTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (!Platform.shouldSAAttach()) {
        System.out.println("SA attach not expected to work - test skipped.");
        return;
    }
    createArchive();
    run(true);
    run(false);
}
 
Example 12
Source File: SABase.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    if (!Platform.shouldSAAttach()) {
        System.out.println("SA attach not expected to work - test skipped.");
        return;
    }

    checkSetLimits();
    new SABase(args).runTest(/* needCoreDump = */ true, args);
}
 
Example 13
Source File: DeadlockDetectionTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    System.out.println("Starting DeadlockDetectionTest");

    if (!Platform.shouldSAAttach()) {
        // Silently skip the test if we don't have enough permissions to attach
        // Not all conditions checked by function is relevant to SA but it's worth
        // to check
        System.err.println("Error! Insufficient permissions to attach.");
        return;
    }

    if (Platform.isOSX()) {
        // Coredump stackwalking is not implemented for Darwin
        System.out.println("This test is not expected to work on OS X. Skipping");
        return;
    }


    if (!LingeredApp.isLastModifiedWorking()) {
        // Exact behaviour of the test depends on operating system and the test nature,
        // so just print the warning and continue
        System.err.println("Warning! Last modified time doesn't work.");
    }

    try {
        List<String> vmArgs = new ArrayList<String>();
        vmArgs.add("-XX:+UsePerfData");
        vmArgs.addAll(Utils.getVmOptions());

        theApp = new LingeredAppWithDeadlock();
        LingeredApp.startApp(vmArgs, theApp);
        OutputAnalyzer output = jstack("--pid", Long.toString(theApp.getPid()));
        System.out.println(output.getOutput());

        if (output.getExitValue() == 3) {
            System.out.println("Test can't run for some reason. Skipping");
        }
        else {
            output.shouldHaveExitValue(0);
            output.shouldContain("Found a total of 1 deadlock.");
        }

    } finally {
        LingeredApp.stopApp(theApp);
    }
}
 
Example 14
Source File: JMapHeapConfigTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    System.out.println("Starting JMapHeapConfigTest");

    if (!Platform.shouldSAAttach()) {
        // Silently skip the test if we don't have enough permissions to attach
        System.err.println("Error! Insufficient permissions to attach.");
        return;
    }

    if (!LingeredApp.isLastModifiedWorking()) {
        // Exact behaviour of the test depends to operating system and the test nature,
        // so just print the warning and continue
        System.err.println("Warning! Last modified time doesn't work.");
    }

    boolean mx_found = false;
    List<String> jvmOptions = Utils.getVmOptions();
    for (String option : jvmOptions) {
        if (option.startsWith("-Xmx")) {
           System.out.println("INFO: maximum heap size set by JTREG as " + option);
           mx_found = true;
           break;
       }
    }

    // Forward vm options to LingeredApp
    ArrayList<String> cmd = new ArrayList();
    cmd.addAll(Utils.getVmOptions());
    if (!mx_found) {
        cmd.add(desiredMaxHeapSize);
        System.out.println("INFO: maximum heap size set explicitly as " + desiredMaxHeapSize);
    }
    cmd.add("-XX:+PrintFlagsFinal");

    TmtoolTestScenario tmt = TmtoolTestScenario.create("jmap", "--heap");
    int exitcode = tmt.launch(cmd);
    if (exitcode != 0) {
        throw new RuntimeException("Test FAILED jmap exits with non zero exit code " + exitcode);
    }

    Map<String,String> parsedJmapOutput = parseJMapOutput(tmt.getToolOutput());
    Map<String,String> parsedVMOutput = tmt.parseFlagsFinal();

    compareValues(parsedJmapOutput, parsedVMOutput);

    // If test fails it throws RuntimeException
    System.out.println("Test PASSED");
}