test/hotspot/jtreg/compiler/ciReplay/SABase.java
author rwestberg
Mon, 04 Jun 2018 16:21:08 +0200
changeset 50391 2bea53d7a27b
parent 47216 71c04702a3d5
child 50791 b1e90a8a876c
permissions -rw-r--r--
8202095: JFR TestBiasedLockRevocationEvents should cope with multiple events during a single safepoint Reviewed-by: mgronlun, egahlin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42029
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
     1
/*
44636
a50cc126180c 8178731: compiler/ciReplay/SABase.java does not compile
iignatyev
parents: 42543
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
42029
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
     4
 *
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
     7
 * published by the Free Software Foundation.
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
     8
 *
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    13
 * accompanied this code).
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    14
 *
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    18
 *
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    21
 * questions.
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    22
 */
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    23
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    24
package compiler.ciReplay;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    25
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    26
import java.nio.file.Files;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    27
import java.nio.file.Paths;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    28
import java.io.IOException;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    29
import java.io.File;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    30
import java.io.FileInputStream;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    31
import java.io.OutputStream;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    32
import java.util.Arrays;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    33
import jdk.test.lib.Platform;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    34
import jdk.test.lib.Asserts;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    35
import jdk.test.lib.JDKToolFinder;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    36
import jdk.test.lib.process.OutputAnalyzer;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    37
import jdk.test.lib.process.ProcessTools;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    38
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    39
public class SABase extends CiReplayBase {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    40
    private static final String REPLAY_FILE_COPY = "replay_vm.txt";
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    41
42543
9e7ac7aff2d1 8166837: [TESTBUG] Fix tests on Linux/s390x
goetz
parents: 42029
diff changeset
    42
    public static void main(String args[]) throws Exception {
9e7ac7aff2d1 8166837: [TESTBUG] Fix tests on Linux/s390x
goetz
parents: 42029
diff changeset
    43
        if (!Platform.shouldSAAttach()) {
9e7ac7aff2d1 8166837: [TESTBUG] Fix tests on Linux/s390x
goetz
parents: 42029
diff changeset
    44
            System.out.println("SA attach not expected to work - test skipped.");
9e7ac7aff2d1 8166837: [TESTBUG] Fix tests on Linux/s390x
goetz
parents: 42029
diff changeset
    45
            return;
9e7ac7aff2d1 8166837: [TESTBUG] Fix tests on Linux/s390x
goetz
parents: 42029
diff changeset
    46
        }
9e7ac7aff2d1 8166837: [TESTBUG] Fix tests on Linux/s390x
goetz
parents: 42029
diff changeset
    47
42029
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    48
        checkSetLimits();
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    49
        new SABase(args).runTest(/* needCoreDump = */ true, args);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    50
    }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    51
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    52
    public SABase(String[] args) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    53
        super(args);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    54
    }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    55
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    56
    @Override
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    57
    public void testAction() {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    58
        try {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    59
            Files.move(Paths.get(REPLAY_FILE_NAME), Paths.get(REPLAY_FILE_COPY));
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    60
        } catch (IOException ioe) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    61
            throw new Error("Can't move files: " + ioe, ioe);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    62
        }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    63
        ProcessBuilder pb;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    64
        try {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    65
            pb = ProcessTools.createJavaProcessBuilder(true, "--add-modules", "jdk.hotspot.agent",
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    66
                   "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED",
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    67
                    "sun.jvm.hotspot.CLHSDB", JDKToolFinder.getTestJDKTool("java"),
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    68
                    TEST_CORE_FILE_NAME);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    69
        } catch (Exception e) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    70
            throw new Error("Can't create process builder: " + e, e);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    71
        }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    72
        Process p;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    73
        try {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    74
            p = pb.start();
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    75
        } catch (IOException ioe) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    76
            throw new Error("Can't start child process: " + ioe, ioe);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    77
        }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    78
        OutputStream input = p.getOutputStream();
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    79
        String str = "dumpreplaydata -a > " + REPLAY_FILE_NAME + "\nquit\n";
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    80
        try {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    81
            input.write(str.getBytes());
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    82
            input.flush();
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    83
        } catch (IOException ioe) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    84
            throw new Error("Problem writing process input: " + str, ioe);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    85
        }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    86
        try {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    87
            p.waitFor();
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    88
        } catch (InterruptedException ie) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    89
            throw new Error("Problem waitinig child process: " + ie, ie);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    90
        }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    91
        int exitValue = p.exitValue();
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    92
        if (exitValue != 0) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    93
            String output;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    94
            try {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    95
                output = new OutputAnalyzer(p).getOutput();
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    96
            } catch (IOException ioe) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    97
                throw new Error("Can't get failed CLHSDB process output: " + ioe, ioe);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    98
            }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
    99
            throw new AssertionError("CLHSDB wasn't run successfully: " + output);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   100
        }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   101
        File replay = new File(REPLAY_FILE_NAME);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   102
        Asserts.assertTrue(replay.exists() && replay.isFile() && replay.length() > 0,
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   103
                "Replay data wasn't generated by SA");
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   104
        try {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   105
            FileInputStream rep = new FileInputStream(replay);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   106
            FileInputStream repCopy = new FileInputStream(REPLAY_FILE_COPY);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   107
            byte repBuffer[] = new byte[512];
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   108
            byte repCopyBuffer[] = new byte[512];
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   109
            boolean filesNotEqual = false;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   110
            while(rep.available() > 0 && !filesNotEqual) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   111
                int count = rep.read(repBuffer);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   112
                int count2 = repCopy.read(repCopyBuffer);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   113
                filesNotEqual = count != count2 || Arrays.equals(repBuffer, repCopyBuffer);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   114
            }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   115
            if (filesNotEqual) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   116
                System.out.println("Warning: replay files are not equal");
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   117
            }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   118
        } catch (IOException ioe) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   119
            throw new Error("Can't read replay files: " + ioe, ioe);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   120
        }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   121
        commonTests();
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   122
        runVmTests();
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   123
    }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   124
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   125
    public static void checkSetLimits() {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   126
        if (!Platform.isWindows()) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   127
            OutputAnalyzer oa;
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   128
            try {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   129
                // first check if setting limit is possible
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   130
                oa = ProcessTools.executeProcess("sh", "-c", RUN_SHELL_NO_LIMIT + "ulimit -c");
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   131
            } catch (Throwable t) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   132
                throw new Error("Can't set limits: " + t, t);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   133
            }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   134
            oa.shouldHaveExitValue(0);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   135
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   136
            String out = oa.getOutput().trim(); // cut win/*nix newlines
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   137
            if (!out.equals("unlimited") && !out.equals("-1")) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   138
                throw new Error("Unable to set limits");
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   139
            }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   140
        }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   141
        if (Platform.isSolaris()) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   142
            try {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   143
                OutputAnalyzer oa = ProcessTools.executeProcess("coreadm", "-p", "core",
44636
a50cc126180c 8178731: compiler/ciReplay/SABase.java does not compile
iignatyev
parents: 42543
diff changeset
   144
                        "" + ProcessHandle.current().pid());
42029
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   145
                oa.shouldHaveExitValue(0);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   146
            } catch (Throwable t) {
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   147
                throw new Error("Can't launch coreadm: " + t, t);
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   148
            }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   149
        }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   150
    }
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   151
}
73e8eed6e85d 8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
dpochepk
parents:
diff changeset
   152