8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java
authordpochepk
Thu, 20 Oct 2016 16:53:39 +0300
changeset 42029 73e8eed6e85d
parent 42028 6218944dbd18
child 42030 f7c0010a447e
child 42031 55dc92f033b9
8155219: [TESTBUG] Rewrite compiler/ciReplay/TestVM.sh in java Reviewed-by: kvn
hotspot/test/TEST.ROOT
hotspot/test/compiler/ciReplay/CiReplayBase.java
hotspot/test/compiler/ciReplay/SABase.java
hotspot/test/compiler/ciReplay/TestClientVM.java
hotspot/test/compiler/ciReplay/TestSA.sh
hotspot/test/compiler/ciReplay/TestSAClient.java
hotspot/test/compiler/ciReplay/TestSAServer.java
hotspot/test/compiler/ciReplay/TestServerVM.java
hotspot/test/compiler/ciReplay/TestVM.sh
hotspot/test/compiler/ciReplay/TestVMNoCompLevel.java
hotspot/test/compiler/ciReplay/TestVM_no_comp_level.sh
hotspot/test/compiler/ciReplay/VMBase.java
hotspot/test/compiler/ciReplay/common.sh
--- a/hotspot/test/TEST.ROOT	Thu Oct 20 10:51:54 2016 +0300
+++ b/hotspot/test/TEST.ROOT	Thu Oct 20 16:53:39 2016 +0300
@@ -44,7 +44,8 @@
     vm.gc.G1 \
     vm.gc.Serial \
     vm.gc.Parallel \
-    vm.gc.ConcMarkSweep
+    vm.gc.ConcMarkSweep \
+    vm.debug
 
 # Tests using jtreg 4.2 b03 features
 requiredVersion=4.2 b03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/ciReplay/CiReplayBase.java	Thu Oct 20 16:53:39 2016 +0300
@@ -0,0 +1,297 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package compiler.ciReplay;
+
+import compiler.whitebox.CompilerWhiteBoxTest;
+import java.io.IOException;
+import java.io.File;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import jdk.test.lib.Platform;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.Asserts;
+import jdk.test.lib.Utils;
+
+public abstract class CiReplayBase {
+    public static final String REPLAY_FILE_NAME = "test_replay.txt";
+    public static final boolean CLIENT_VM_AVAILABLE;
+    public static final boolean SERVER_VM_AVAILABLE;
+    public static final String TIERED_ENABLED_VM_OPTION = "-XX:+TieredCompilation";
+    public static final String TIERED_DISABLED_VM_OPTION = "-XX:-TieredCompilation";
+    public static final String ENABLE_COREDUMP_ON_CRASH = "-XX:+CreateCoredumpOnCrash";
+    public static final String DISABLE_COREDUMP_ON_CRASH = "-XX:-CreateCoredumpOnCrash";
+    public static final String CLIENT_VM_OPTION = "-client";
+    public static final String SERVER_VM_OPTION = "-server";
+    public static final String TEST_CORE_FILE_NAME = "test_core";
+    public static final String RUN_SHELL_NO_LIMIT = "ulimit -c unlimited && ";
+    private static final String REPLAY_FILE_OPTION = "-XX:ReplayDataFile=" + REPLAY_FILE_NAME;
+    private static final String LOCATIONS_STRING = "location: ";
+    private static final String HS_ERR_NAME = "hs_err_pid";
+    private static final String RUN_SHELL_ZERO_LIMIT = "ulimit -S -c 0 && ";
+    private static final String VERSION_OPTION = "-version";
+    private static final String[] REPLAY_GENERATION_OPTIONS = new String[]{"-Xms8m", "-Xmx32m",
+        "-XX:MetaspaceSize=4m", "-XX:MaxMetaspaceSize=16m", "-XX:InitialCodeCacheSize=512k",
+        "-XX:ReservedCodeCacheSize=4m", "-XX:ThreadStackSize=512", "-XX:VMThreadStackSize=512",
+        "-XX:CompilerThreadStackSize=512", "-XX:ParallelGCThreads=1", "-XX:CICompilerCount=2",
+        "-Xcomp", "-XX:CICrashAt=1", "-XX:+DumpReplayDataOnError", "-XX:-TransmitErrorReport",
+        "-XX:+PreferInterpreterNativeStubs", "-XX:+PrintCompilation", REPLAY_FILE_OPTION};
+    private static final String[] REPLAY_OPTIONS = new String[]{DISABLE_COREDUMP_ON_CRASH,
+        "-XX:+ReplayCompiles", REPLAY_FILE_OPTION};
+    protected final Optional<Boolean> runServer;
+
+    static {
+        try {
+            CLIENT_VM_AVAILABLE = ProcessTools.executeTestJvm(CLIENT_VM_OPTION, VERSION_OPTION)
+                    .getOutput().contains("Client");
+            SERVER_VM_AVAILABLE = ProcessTools.executeTestJvm(SERVER_VM_OPTION, VERSION_OPTION)
+                    .getOutput().contains("Server");
+        } catch(Throwable t) {
+            throw new Error("Initialization failed: " + t, t);
+        }
+    }
+
+    public CiReplayBase() {
+        runServer = Optional.empty();
+    }
+
+    public CiReplayBase(String args[]) {
+        if (args.length != 1 || (!"server".equals(args[0]) && !"client".equals(args[0]))) {
+            throw new Error("Expected 1 argument: [server|client]");
+        }
+        runServer = Optional.of("server".equals(args[0]));
+    }
+
+    public void runTest(boolean needCoreDump, String... args) {
+        cleanup();
+        if (generateReplay(needCoreDump)) {
+            testAction();
+            cleanup();
+        } else {
+            throw new Error("Host is not configured to generate cores");
+        }
+    }
+
+    public abstract void testAction();
+
+    private static void remove(String item) {
+        File toDelete = new File(item);
+        toDelete.delete();
+        if (Platform.isWindows()) {
+            Utils.waitForCondition(() -> !toDelete.exists());
+        }
+    }
+
+    private static void removeFromCurrentDirectoryStartingWith(String prefix) {
+        Arrays.stream(new File(".").listFiles())
+                .filter(f -> f.getName().startsWith(prefix))
+                .forEach(File::delete);
+    }
+
+    public static void cleanup() {
+        removeFromCurrentDirectoryStartingWith("core");
+        removeFromCurrentDirectoryStartingWith("replay");
+        removeFromCurrentDirectoryStartingWith(HS_ERR_NAME);
+        remove(TEST_CORE_FILE_NAME);
+        remove(REPLAY_FILE_NAME);
+    }
+
+    public boolean generateReplay(boolean needCoreDump, String... vmopts) {
+        OutputAnalyzer crashOut;
+        String crashOutputString;
+        try {
+            List<String> options = new ArrayList<>();
+            options.addAll(Arrays.asList(REPLAY_GENERATION_OPTIONS));
+            options.addAll(Arrays.asList(vmopts));
+            options.add(needCoreDump ? ENABLE_COREDUMP_ON_CRASH : DISABLE_COREDUMP_ON_CRASH);
+            options.add(VERSION_OPTION);
+            if (needCoreDump) {
+                crashOut = ProcessTools.executeProcess(getTestJavaCommandlineWithPrefix(
+                        RUN_SHELL_NO_LIMIT, options.toArray(new String[0])));
+            } else {
+                crashOut = ProcessTools.executeProcess(ProcessTools.createJavaProcessBuilder(true,
+                        options.toArray(new String[0])));
+            }
+            crashOutputString = crashOut.getOutput();
+            Asserts.assertNotEquals(crashOut.getExitValue(), 0, "Crash JVM exits gracefully");
+            Files.write(Paths.get("crash.out"), crashOutputString.getBytes(),
+                    StandardOpenOption.CREATE, StandardOpenOption.WRITE,
+                    StandardOpenOption.TRUNCATE_EXISTING);
+        } catch (Throwable t) {
+            throw new Error("Can't create replay: " + t, t);
+        }
+        if (needCoreDump) {
+            String coreFileLocation = getCoreFileLocation(crashOutputString);
+            if (coreFileLocation == null) {
+                if (Platform.isOSX()) {
+                    File coresDir = new File("/cores");
+                    if (!coresDir.isDirectory() || !coresDir.canWrite()) {
+                        return false;
+                    }
+                }
+                throw new Error("Couldn't find core file location in: '" + crashOutputString + "'");
+            }
+            try {
+                Asserts.assertGT(new File(coreFileLocation).length(), 0L, "Unexpected core size");
+                Files.move(Paths.get(coreFileLocation), Paths.get(TEST_CORE_FILE_NAME));
+            } catch (IOException ioe) {
+                throw new Error("Can't move core file: " + ioe, ioe);
+            }
+        }
+        removeFromCurrentDirectoryStartingWith(HS_ERR_NAME);
+        return true;
+    }
+
+    public void commonTests() {
+        positiveTest();
+        if (Platform.isTieredSupported()) {
+            positiveTest(TIERED_ENABLED_VM_OPTION);
+        }
+    }
+
+    public int startTest(String... additionalVmOpts) {
+        try {
+            List<String> allAdditionalOpts = new ArrayList<>();
+            allAdditionalOpts.addAll(Arrays.asList(REPLAY_OPTIONS));
+            allAdditionalOpts.addAll(Arrays.asList(additionalVmOpts));
+            OutputAnalyzer oa = ProcessTools.executeProcess(getTestJavaCommandlineWithPrefix(
+                    RUN_SHELL_ZERO_LIMIT, allAdditionalOpts.toArray(new String[0])));
+            return oa.getExitValue();
+        } catch (Throwable t) {
+            throw new Error("Can't run replay process: " + t, t);
+        }
+    }
+
+    public void runVmTests() {
+        boolean runServerValue = runServer.orElseThrow(() -> new Error("runServer must be set"));
+        if (runServerValue) {
+            if (CLIENT_VM_AVAILABLE) {
+                negativeTest(CLIENT_VM_OPTION);
+            }
+        } else {
+            if (SERVER_VM_AVAILABLE) {
+                negativeTest(TIERED_DISABLED_VM_OPTION, SERVER_VM_OPTION);
+                if (Platform.isTieredSupported()) {
+                    positiveTest(TIERED_ENABLED_VM_OPTION, SERVER_VM_OPTION);
+                }
+            }
+        }
+        nonTieredTests(runServerValue ? CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION
+                : CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
+    }
+
+    public int getCompLevelFromReplay() {
+        try(BufferedReader br = new BufferedReader(new FileReader(REPLAY_FILE_NAME))) {
+            return br.lines()
+                    .filter(s -> s.startsWith("compile "))
+                    .map(s -> s.substring(s.lastIndexOf(' ') + 1))
+                    .map(Integer::parseInt)
+                    .findAny()
+                    .get();
+        } catch (IOException ioe) {
+            throw new Error("Failed to read replay data: " + ioe, ioe);
+        }
+    }
+
+    public void positiveTest(String... additionalVmOpts) {
+        Asserts.assertEQ(startTest(additionalVmOpts), 0, "Unexpected exit code for positive case: "
+                + Arrays.toString(additionalVmOpts));
+    }
+
+    public void negativeTest(String... additionalVmOpts) {
+        Asserts.assertNE(startTest(additionalVmOpts), 0, "Unexpected exit code for negative case: "
+                + Arrays.toString(additionalVmOpts));
+    }
+
+    public void nonTieredTests(int compLevel) {
+        int replayDataCompLevel = getCompLevelFromReplay();
+        if (replayDataCompLevel == compLevel) {
+            positiveTest(TIERED_DISABLED_VM_OPTION);
+        } else {
+            negativeTest(TIERED_DISABLED_VM_OPTION);
+        }
+    }
+
+    // lets search few possible locations using process output and return existing location
+    private String getCoreFileLocation(String crashOutputString) {
+        Asserts.assertTrue(crashOutputString.contains(LOCATIONS_STRING),
+                "Output doesn't contain the location of core file, see crash.out");
+        String stringWithLocation = Arrays.stream(crashOutputString.split("\\r?\\n"))
+                .filter(str -> str.contains(LOCATIONS_STRING))
+                .findFirst()
+                .get();
+        stringWithLocation = stringWithLocation.substring(stringWithLocation
+                .indexOf(LOCATIONS_STRING) + LOCATIONS_STRING.length());
+        String coreWithPid;
+        if (stringWithLocation.contains("or ") && !Platform.isWindows()) {
+            Matcher m = Pattern.compile("or.* ([^ ]+[^\\)])\\)?").matcher(stringWithLocation);
+            if (!m.find()) {
+                throw new Error("Couldn't find path to core inside location string");
+            }
+            coreWithPid = m.group(1);
+        } else {
+            coreWithPid = stringWithLocation.trim();
+        }
+        if (new File(coreWithPid).exists()) {
+            return coreWithPid;
+        }
+        String justCore = Paths.get("core").toString();
+        if (new File(justCore).exists()) {
+            return justCore;
+        }
+        Path coreWithPidPath = Paths.get(coreWithPid);
+        String justFile = coreWithPidPath.getFileName().toString();
+        if (new File(justFile).exists()) {
+            return justFile;
+        }
+        Path parent = coreWithPidPath.getParent();
+        if (parent != null) {
+            String coreWithoutPid = parent.resolve("core").toString();
+            if (new File(coreWithoutPid).exists()) {
+                return coreWithoutPid;
+            }
+        }
+        return null;
+    }
+
+    private String[] getTestJavaCommandlineWithPrefix(String prefix, String... args) {
+        try {
+            String cmd = ProcessTools.getCommandLine(ProcessTools.createJavaProcessBuilder(true, args));
+            return new String[]{"sh", "-c", prefix
+                    + (Platform.isWindows() ? cmd.replace('\\', '/').replace(";", "\\;") : cmd)};
+        } catch(Throwable t) {
+            throw new Error("Can't create process builder: " + t, t);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/ciReplay/SABase.java	Thu Oct 20 16:53:39 2016 +0300
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package compiler.ciReplay;
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.io.IOException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import jdk.test.lib.Platform;
+import jdk.test.lib.Asserts;
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+public class SABase extends CiReplayBase {
+    private static final String REPLAY_FILE_COPY = "replay_vm.txt";
+
+    public static void main(String args[]) {
+        checkSetLimits();
+        new SABase(args).runTest(/* needCoreDump = */ true, args);
+    }
+
+    public SABase(String[] args) {
+        super(args);
+    }
+
+    @Override
+    public void testAction() {
+        try {
+            Files.move(Paths.get(REPLAY_FILE_NAME), Paths.get(REPLAY_FILE_COPY));
+        } catch (IOException ioe) {
+            throw new Error("Can't move files: " + ioe, ioe);
+        }
+        ProcessBuilder pb;
+        try {
+            pb = ProcessTools.createJavaProcessBuilder(true, "--add-modules", "jdk.hotspot.agent",
+                   "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED",
+                    "sun.jvm.hotspot.CLHSDB", JDKToolFinder.getTestJDKTool("java"),
+                    TEST_CORE_FILE_NAME);
+        } catch (Exception e) {
+            throw new Error("Can't create process builder: " + e, e);
+        }
+        Process p;
+        try {
+            p = pb.start();
+        } catch (IOException ioe) {
+            throw new Error("Can't start child process: " + ioe, ioe);
+        }
+        OutputStream input = p.getOutputStream();
+        String str = "dumpreplaydata -a > " + REPLAY_FILE_NAME + "\nquit\n";
+        try {
+            input.write(str.getBytes());
+            input.flush();
+        } catch (IOException ioe) {
+            throw new Error("Problem writing process input: " + str, ioe);
+        }
+        try {
+            p.waitFor();
+        } catch (InterruptedException ie) {
+            throw new Error("Problem waitinig child process: " + ie, ie);
+        }
+        int exitValue = p.exitValue();
+        if (exitValue != 0) {
+            String output;
+            try {
+                output = new OutputAnalyzer(p).getOutput();
+            } catch (IOException ioe) {
+                throw new Error("Can't get failed CLHSDB process output: " + ioe, ioe);
+            }
+            throw new AssertionError("CLHSDB wasn't run successfully: " + output);
+        }
+        File replay = new File(REPLAY_FILE_NAME);
+        Asserts.assertTrue(replay.exists() && replay.isFile() && replay.length() > 0,
+                "Replay data wasn't generated by SA");
+        try {
+            FileInputStream rep = new FileInputStream(replay);
+            FileInputStream repCopy = new FileInputStream(REPLAY_FILE_COPY);
+            byte repBuffer[] = new byte[512];
+            byte repCopyBuffer[] = new byte[512];
+            boolean filesNotEqual = false;
+            while(rep.available() > 0 && !filesNotEqual) {
+                int count = rep.read(repBuffer);
+                int count2 = repCopy.read(repCopyBuffer);
+                filesNotEqual = count != count2 || Arrays.equals(repBuffer, repCopyBuffer);
+            }
+            if (filesNotEqual) {
+                System.out.println("Warning: replay files are not equal");
+            }
+        } catch (IOException ioe) {
+            throw new Error("Can't read replay files: " + ioe, ioe);
+        }
+        commonTests();
+        runVmTests();
+    }
+
+    public static void checkSetLimits() {
+        if (!Platform.isWindows()) {
+            OutputAnalyzer oa;
+            try {
+                // first check if setting limit is possible
+                oa = ProcessTools.executeProcess("sh", "-c", RUN_SHELL_NO_LIMIT + "ulimit -c");
+            } catch (Throwable t) {
+                throw new Error("Can't set limits: " + t, t);
+            }
+            oa.shouldHaveExitValue(0);
+
+            String out = oa.getOutput().trim(); // cut win/*nix newlines
+            if (!out.equals("unlimited") && !out.equals("-1")) {
+                throw new Error("Unable to set limits");
+            }
+        }
+        if (Platform.isSolaris()) {
+            try {
+                OutputAnalyzer oa = ProcessTools.executeProcess("coreadm", "-p", "core",
+                        "" + ProcessHandle.current().getPid());
+                oa.shouldHaveExitValue(0);
+            } catch (Throwable t) {
+                throw new Error("Can't launch coreadm: " + t, t);
+            }
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/ciReplay/TestClientVM.java	Thu Oct 20 16:53:39 2016 +0300
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8011675
+ * @library / /test/lib
+ * @summary testing of ciReplay with using generated by VM replay.txt
+ * @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & vm.flavor == "client"
+ * @modules java.base/jdk.internal.misc
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *      compiler.ciReplay.VMBase client
+ */
--- a/hotspot/test/compiler/ciReplay/TestSA.sh	Thu Oct 20 10:51:54 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-#!/bin/sh
-# 
-# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-# 
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-# 
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-# 
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-# 
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-# 
-# 
-
-##
-## @test
-## @bug 8011675
-## @ignore 8029528
-## @summary testing of ciReplay with using generated by SA replay.txt 
-## @author igor.ignatyev@oracle.com
-## @requires vm.flightRecorder != true
-## @run shell TestSA.sh
-##
-
-if [ "${TESTSRC}" = "" ]
-then
-  TESTSRC=${PWD}
-  echo "TESTSRC not set.  Using "${TESTSRC}" as default"
-fi
-echo "TESTSRC=${TESTSRC}"
-
-## Adding common setup Variables for running shell tests.
-. ${TESTSRC}/../../test_env.sh
-
-. ${TESTSRC}/common.sh
-
-generate_replay
-
-${MV} ${replay_data} replay_vm.txt    
-
-if [ -z "${core_file}" -o ! -r "${core_file}" ]
-then
-    # skip test if MacOS host isn't configured for core dumping
-    if [ "$OS" = "Darwin" ]
-    then
-        if [ ! -d "/cores" ]
-        then
-            echo TEST SKIPPED: \'/cores\' dir doens\'t exist
-            exit 0
-        fi
-        if [ ! -w "/cores" ]
-        then
-            echo TEST SKIPPED: \'/cores\' dir exists but is not writable
-            exit 0
-        fi
-    fi
-    test_fail 2 "CHECK :: CORE GENERATION" "core wasn't generated on $OS"
-fi
-
-echo "dumpreplaydata -a > ${replay_data}" | \
-        ${JAVA} ${TESTOPTS} \
-        sun.jvm.hotspot.CLHSDB  ${JAVA} ${core_file}
-
-if [ ! -s ${replay_data} ]
-then
-    test_fail 1 "CHECK :: REPLAY DATA GENERATION" \
-        "replay data wasn't generated by SA"
-fi
-
-diff ${replay_data} replay_vm.txt > replay.diff 2>&1
-if [ -s replay.diff ]
-then
-    echo WARNING: replay.txt from SA != replay.txt from VM:
-    cat replay.diff
-fi
-
-common_tests 10 
-${VM_TYPE}_tests 20
-
-cleanup
-
-echo TEST PASSED
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/ciReplay/TestSAClient.java	Thu Oct 20 16:53:39 2016 +0300
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8011675
+ * @library / /test/lib
+ * @summary testing of ciReplay with using generated by SA replay.txt
+ * @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & vm.flavor == "client"
+ * @modules java.base/jdk.internal.misc
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *      compiler.ciReplay.SABase client
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/ciReplay/TestSAServer.java	Thu Oct 20 16:53:39 2016 +0300
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8011675
+ * @library / /test/lib
+ * @summary testing of ciReplay with using generated by SA replay.txt
+ * @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & vm.flavor == "server"
+ * @modules java.base/jdk.internal.misc
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *      compiler.ciReplay.SABase server
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/ciReplay/TestServerVM.java	Thu Oct 20 16:53:39 2016 +0300
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8011675
+ * @library / /test/lib
+ * @summary testing of ciReplay with using generated by VM replay.txt
+ * @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & vm.flavor == "server"
+ * @modules java.base/jdk.internal.misc
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *      compiler.ciReplay.VMBase server
+ */
--- a/hotspot/test/compiler/ciReplay/TestVM.sh	Thu Oct 20 10:51:54 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-#!/bin/sh
-# 
-# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-# 
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-# 
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-# 
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-# 
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-# 
-# 
-
-##
-## @test
-## @bug 8011675
-## @summary testing of ciReplay with using generated by VM replay.txt 
-## @author igor.ignatyev@oracle.com
-## @requires vm.flightRecorder != true
-## @run shell TestVM.sh
-##
-
-if [ "${TESTSRC}" = "" ]
-then
-  TESTSRC=${PWD}
-  echo "TESTSRC not set.  Using "${TESTSRC}" as default"
-fi
-echo "TESTSRC=${TESTSRC}"
-
-## Adding common setup Variables for running shell tests.
-. ${TESTSRC}/../../test_env.sh
-
-. ${TESTSRC}/common.sh
-
-generate_replay
-
-if [ ! -s ${replay_data} ]
-then
-    test_fail 1 "CHECK :: REPLAY DATA GENERATION" \
-        "replay data wasn't generated by VM"
-fi
-
-common_tests 10
-${VM_TYPE}_tests 20
-
-cleanup
-
-if [ $is_tiered -eq 1 ]
-then
-    stop_level=1
-    while [ $stop_level -le $server_level ]
-    do
-        generate_replay "-XX:TieredStopAtLevel=$stop_level"
-        if [ ! -s ${replay_data} ]
-        then
-            test_fail `expr $stop_level + 30` \
-                    "TIERED LEVEL $stop_level :: REPLAY DATA GENERATION" \
-                    "replay data wasn't generated by VM with stop_level=$stop_level"
-        fi
-        level=`grep "^compile " $replay_data | awk '{print $6}'`
-        if [ $level -gt $stop_level ]
-        then
-            test_fail `expr $stop_level + 40` \
-                    "TIERED LEVEL $stop_level :: COMP_LEVEL VERIFICATION" \
-                    "comp_level in replay[$level] is greater than stop_level[$stop_level]"
-        fi
-        positive_test `expr $stop_level + 50` "TIERED LEVEL $stop_level :: REPLAY" \
-                "-XX:TieredStopAtLevel=$stop_level"
-        stop_level=`expr $stop_level + 1`
-        cleanup
-    done
-fi
-
-echo TEST PASSED
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/ciReplay/TestVMNoCompLevel.java	Thu Oct 20 16:53:39 2016 +0300
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8011675
+ * @library / /test/lib
+ * @summary testing of ciReplay with using generated by VM replay.txt w/o comp_level
+ * @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true
+ * @modules java.base/jdk.internal.misc
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                                sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ *      compiler.ciReplay.TestVMNoCompLevel
+ */
+
+package compiler.ciReplay;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+import java.util.List;
+
+public class TestVMNoCompLevel extends CiReplayBase {
+    public static void main(String args[]) {
+        new TestVMNoCompLevel().runTest(false);
+    }
+
+    @Override
+    public void testAction() {
+        try {
+            Path replayFilePath = Paths.get(REPLAY_FILE_NAME);
+            List<String> replayContent = Files.readAllLines(replayFilePath);
+            for (int i = 0; i < replayContent.size(); i++) {
+                String line = replayContent.get(i);
+                if (line.startsWith("compile ")) {
+                    replayContent.set(i, line.substring(0, line.lastIndexOf(" ")));
+                }
+            }
+            Files.write(replayFilePath, replayContent, StandardOpenOption.TRUNCATE_EXISTING);
+        } catch (IOException ioe) {
+            throw new Error("Failed to read/write replay data: " + ioe, ioe);
+        }
+        if (CLIENT_VM_AVAILABLE) {
+            negativeTest(CLIENT_VM_OPTION);
+        }
+        if (SERVER_VM_AVAILABLE) {
+            positiveTest(TIERED_DISABLED_VM_OPTION, SERVER_VM_OPTION);
+            positiveTest(TIERED_ENABLED_VM_OPTION, SERVER_VM_OPTION);
+        }
+    }
+}
+
--- a/hotspot/test/compiler/ciReplay/TestVM_no_comp_level.sh	Thu Oct 20 10:51:54 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-#!/bin/sh
-# 
-# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-# 
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-# 
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-# 
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-# 
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-# 
-# 
-
-##
-## @test
-## @bug 8011675
-## @summary testing of ciReplay with using generated by VM replay.txt w/o comp_level
-## @author igor.ignatyev@oracle.com
-## @requires vm.flightRecorder != true
-## @run shell TestVM_no_comp_level.sh
-##
-
-if [ "${TESTSRC}" = "" ]
-then
-  TESTSRC=${PWD}
-  echo "TESTSRC not set.  Using "${TESTSRC}" as default"
-fi
-echo "TESTSRC=${TESTSRC}"
-
-## Adding common setup Variables for running shell tests.
-. ${TESTSRC}/../../test_env.sh
-
-. ${TESTSRC}/common.sh
-
-generate_replay
-
-if [ ! -s ${replay_data} ]
-then
-    test_fail 1 "CHECK :: REPLAY DATA GENERATION" \
-            "replay data wasn't generated by VM"
-fi
-
-${CP} ${replay_data} replay_vm.txt
-
-sed 's/^\(compile *[^ ][^ ]* *[^ ][^ ]* [^ ][^ ]* [^ ][^ ]*\).*$/\1/' \
-        replay_vm.txt > ${replay_data}
-
-if [ $client_available -eq 1 ]
-then
-    # tiered is unavailable in client vm, so results w/ flags will be the same as w/o flags
-    negative_test 10 "CLIENT" -client
-fi
-
-if [ $server_available -eq 1 ]
-then
-    positive_test 21 "SERVER :: NON-TIERED" -XX:-TieredCompilation -server
-    positive_test 22 "SERVER :: TIERED" -XX:+TieredCompilation -server
-fi
-
-cleanup
-
-echo TEST PASSED
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/ciReplay/VMBase.java	Thu Oct 20 16:53:39 2016 +0300
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package compiler.ciReplay;
+
+import compiler.whitebox.CompilerWhiteBoxTest;
+import jdk.test.lib.Asserts;
+import sun.hotspot.WhiteBox;
+
+public class VMBase extends CiReplayBase {
+
+    public static void main(String args[]) {
+        new VMBase(args).runTest(/* needCoreDump = */ false, args);
+    }
+
+    public VMBase(String[] args) {
+        super(args);
+    }
+
+    @Override
+    public void testAction() {
+        commonTests();
+        runVmTests();
+        cleanup();
+        if (runServer.orElseThrow(() -> new Error("runServer must be set"))
+                && WhiteBox.getWhiteBox().getBooleanVMFlag("TieredCompilation")) {
+            for (int stop = 1; stop < CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION; stop++) {
+                String vmOpt = "-XX:TieredStopAtLevel=" + stop;
+                generateReplay(/* need coredump = */ false, vmOpt);
+                int replayCompLevel = getCompLevelFromReplay();
+                Asserts.assertGTE(stop, replayCompLevel, "Unexpected compLevel in replay");
+                positiveTest(vmOpt);
+            }
+        }
+    }
+}
+
--- a/hotspot/test/compiler/ciReplay/common.sh	Thu Oct 20 10:51:54 2016 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,291 +0,0 @@
-#!/bin/sh
-# 
-# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-# 
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-# 
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-# 
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-# 
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-# 
-# 
-set -x
-
-# $1 - error code
-# $2 - test name
-# $3,.. - decription
-test_fail() {
-    error=$1
-    shift
-    name=$1
-    shift
-    echo "TEST [$name] FAILED:"
-    echo "$@"
-    exit $error
-}
-
-# $@ - additional vm opts
-start_test() {
-    # disable core dump on *nix
-    ulimit -S -c 0
-    # disable core dump on windows
-    VMOPTS="$@ -XX:-CreateMinidumpOnCrash"
-    cmd="${JAVA} ${VMOPTS} -XX:+ReplayCompiles -XX:ReplayDataFile=${replay_data}"
-    echo $cmd
-    $cmd
-    return $?
-}
-
-# $1 - error_code
-# $2 - test name
-# $3,.. - additional vm opts
-positive_test() {
-    error=$1
-    shift
-    name=$1
-    shift
-    VMOPTS="${TESTOPTS} $@"
-    echo "POSITIVE TEST [$name]"
-    start_test ${VMOPTS}
-    exit_code=$?
-    if [ ${exit_code} -ne 0 ]
-    then
-        test_fail $error "$name" "exit_code[${exit_code}] != 0 during replay "\
-                "w/ vmopts: ${VMOPTS}"
-    fi
-}
-
-# $1 - error_code
-# $2 - test name
-# $2,.. - additional vm opts
-negative_test() {
-    error=$1
-    shift
-    name=$1
-    shift
-    VMOPTS="${TESTOPTS} $@"
-    echo "NEGATIVE TEST [$name]"
-    start_test ${VMOPTS}
-    exit_code=$?
-    if [ ${exit_code} -eq 0 ]
-    then
-        test_fail $error "$name" "exit_code[${exit_code}] == 0 during replay "\
-                "w/ vmopts: ${VMOPTS}"
-    fi
-}
-
-# $1 - initial error_code
-common_tests() {
-    positive_test $1 "COMMON :: THE SAME FLAGS"
-    if [ $tiered_available -eq 1 ]
-    then
-        positive_test `expr $1 + 1` "COMMON :: TIERED" -XX:+TieredCompilation
-    fi
-}
-
-# $1 - initial error_code
-# $2 - non-tiered comp_level 
-nontiered_tests() {
-    level=`grep "^compile " $replay_data | awk '{print $6}'`
-    # is level available in non-tiered
-    if [ "$level" -eq $2 ]
-    then
-        positive_test $1 "NON-TIERED :: AVAILABLE COMP_LEVEL" \
-                -XX:-TieredCompilation
-    else
-        negative_test `expr $1 + 1` "NON-TIERED :: UNAVAILABLE COMP_LEVEL" \
-                -XX:-TieredCompilation
-    fi
-}
-
-# $1 - initial error_code
-client_tests() {
-    # testing in opposite VM
-    if [ $server_available -eq 1 ]
-    then
-        negative_test $1 "SERVER :: NON-TIERED" -XX:-TieredCompilation \
-                -server
-        if [ $tiered_available -eq 1 ]
-        then
-            positive_test `expr $1 + 1` "SERVER :: TIERED" -XX:+TieredCompilation \
-                    -server
-        fi
-    fi
-    nontiered_tests `expr $1 + 2` $client_level 
-}
-
-# $1 - initial error_code
-server_tests() {
-    # testing in opposite VM
-    if [ $client_available -eq 1 ]
-    then
-        # tiered is unavailable in client vm, so results w/ flags will be the same as w/o flags
-        negative_test $1 "CLIENT" -client
-    fi
-    nontiered_tests `expr $1 + 2` $server_level
-}
-
-cleanup() {
-    ${RM} -f core*
-    ${RM} -f replay*.txt
-    ${RM} -f hs_err_pid*.log
-    ${RM} -f test_core
-    ${RM} -f test_replay.txt
-}
-
-JAVA=${TESTJAVA}${FS}bin${FS}java
-
-replay_data=test_replay.txt
-
-${JAVA} ${TESTOPTS} -Xinternalversion 2>&1 | grep debug
-
-# Only test fastdebug 
-if [ $? -ne 0 ]
-then
-    echo TEST SKIPPED: product build
-    exit 0
-fi
-
-is_int=`${JAVA} ${TESTOPTS} -version 2>&1 | grep -c "interpreted mode"`
-# Not applicable for Xint
-if [ $is_int -ne 0 ]
-then
-    echo TEST SKIPPED: interpreted mode
-    exit 0
-fi
-
-cleanup
-
-client_available=`${JAVA} ${TESTOPTS} -client -Xinternalversion 2>&1 | \
-        grep -c Client`
-server_available=`${JAVA} ${TESTOPTS} -server -Xinternalversion 2>&1 | \
-        grep -c Server`
-tiered_available=`${JAVA} ${TESTOPTS} -XX:+TieredCompilation -XX:+PrintFlagsFinal -version | \
-        grep TieredCompilation | \
-        grep -c true`
-is_tiered=`${JAVA} ${TESTOPTS} -XX:+PrintFlagsFinal -version | \
-        grep TieredCompilation | \
-        grep -c true`
-# CompLevel_simple -- C1
-client_level=1
-# CompLevel_full_optimization -- C2 or Shark 
-server_level=4
-
-echo "client_available=$client_available"
-echo "server_available=$server_available"
-echo "tiered_available=$tiered_available"
-echo "is_tiered=$is_tiered"
-
-# crash vm in compiler thread with generation replay data and 'small' dump-file
-# $@ - additional vm opts
-generate_replay() {
-    if [ $VM_OS != "windows" ]
-    then
-        # enable core dump
-        ulimit -c unlimited
-        new_ulimit=`ulimit -c`
-        if [ $new_ulimit != "unlimited" -a $new_ulimit != "-1" ]
-        then
-            test_fail 2 "CHECK :: ULIMIT" "Could not set 'ulimit -c unlimited'. 'ulimit -c' returns : $new_ulimit"
-        fi
-
-        if [ $VM_OS = "solaris" ]
-        then
-            coreadm -p core $$
-        fi
-    fi
-
-    cmd="${JAVA} ${TESTOPTS} $@ \
-            -Xms8m \
-            -Xmx32m \
-            -XX:MetaspaceSize=4m \
-            -XX:MaxMetaspaceSize=16m \
-            -XX:InitialCodeCacheSize=512k \
-            -XX:ReservedCodeCacheSize=4m \
-            -XX:ThreadStackSize=512 \
-            -XX:VMThreadStackSize=512 \
-            -XX:CompilerThreadStackSize=512 \
-            -XX:ParallelGCThreads=1 \
-            -XX:CICompilerCount=2 \
-            -Xcomp \
-            -XX:CICrashAt=1 \
-            -XX:+CreateMinidumpOnCrash \
-            -XX:+DumpReplayDataOnError \
-            -XX:-TransmitErrorReport \
-            -XX:+PreferInterpreterNativeStubs \
-            -XX:+PrintCompilation \
-            -XX:ReplayDataFile=${replay_data} \
-            -version"
-    echo GENERATION OF REPLAY.TXT:
-    echo $cmd
-
-    ${cmd} > crash.out 2>&1
-
-    exit_code=$?
-    if [ ${exit_code} -eq 0 ]
-    then
-        cat crash.out
-        test_fail 3 "CHECK :: CRASH" "JVM exits gracefully"
-    fi
-
-    core_locations=`grep -i core crash.out | grep "location:" | \
-            sed -e 's/.*location: //'`
-   
-    if [ -z "${core_locations}" ]
-    then
-        test_fail 4 "CHECK :: CORE_LOCATION" "output doesn't contain the location of core file, see crash.out"
-    fi
-
-    rm crash.out 
-    
-    # processing core locations for *nix
-    if [ $VM_OS != "windows" ]
-    then
-        # remove 'or' between '<core_path>/core.<pid>' and 'core'
-        # and the rest of line -- ' (max size ...) . To ensure a full core ...'
-        core_locations=`echo $core_locations | \
-                sed -e 's/\([^ ]*\) or \([^ ]*\).*/\1 \2/'`
-        core_with_dir=`echo $core_locations | awk '{print $1}'`
-        core_with_pid=`echo $core_locations | awk '{print $2}'`
-        dir=`dirname $core_with_dir`
-        file=`basename $core_with_dir`
-        # add <core_path>/core.<pid> core
-        core_locations='$core_with_dir' '$file'
-        if [ -n "${core_with_pid}" ]
-        then
-            core_locations=$core_locations '$core_with_pid' '$dir${FS}$core_with_pid'
-        fi
-    fi
-
-    echo "LOOKING FOR CORE IN ${core_locations}"
-    for core in $core_locations
-    do
-        if [ -r "$core" ]
-        then
-            core_file=$core
-        fi
-    done
-
-    # core-file was found
-    if [ -n "$core_file" ]
-    then
-        ${MV} "${core_file}" test_core
-        core_file=test_core
-    fi
-
-    ${RM} -f hs_err_pid*.log
-}
-