blob: 8e2e6a1d663a4b53bdd777e6d558bf1fce3359ad [file] [log] [blame]
Albert Nollaef0d742013-10-10 15:44:12 +02001/*
Christian Tornqvistad85e182016-08-19 10:06:30 -04002 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
Albert Nollaef0d742013-10-10 15:44:12 +02003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24/*
25 * @test
26 * @bug 8023014
Tobias Hartmannf9806ff2014-12-04 09:52:15 +010027 * @summary Test ensures that there is no crash if there is not enough ReservedCodeCacheSize
Albert Noll39b5a042014-02-26 07:44:59 +010028 * to initialize all compiler threads. The option -Xcomp gives the VM more time to
Tobias Hartmannf9806ff2014-12-04 09:52:15 +010029 * trigger the old bug.
Christian Tornqvistad85e182016-08-19 10:06:30 -040030 * @library /test/lib
Chris Hegartyb7075c22016-04-09 23:03:39 +010031 * @modules java.base/jdk.internal.misc
Alexander Kulyakthin01b99712015-03-26 16:36:56 +010032 * java.management
Igor Ignatyeva0381422016-07-12 18:24:48 +030033 *
Igor Ignatyeva0381422016-07-12 18:24:48 +030034 * @run driver compiler.startup.SmallCodeCacheStartup
Albert Nollaef0d742013-10-10 15:44:12 +020035 */
Igor Ignatyeva0381422016-07-12 18:24:48 +030036
37package compiler.startup;
38
Christian Tornqvistad85e182016-08-19 10:06:30 -040039import jdk.test.lib.process.OutputAnalyzer;
40import jdk.test.lib.process.ProcessTools;
Igor Ignatyeva0381422016-07-12 18:24:48 +030041
Alexander Kulyakthin462f7352015-05-04 16:30:07 +020042import static jdk.test.lib.Asserts.assertTrue;
Albert Noll65203202014-10-24 14:25:46 +020043
Albert Nollaef0d742013-10-10 15:44:12 +020044public class SmallCodeCacheStartup {
Tobias Hartmannf9806ff2014-12-04 09:52:15 +010045 public static void main(String[] args) throws Exception {
46 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:ReservedCodeCacheSize=3m",
47 "-XX:CICompilerCount=64",
48 "-Xcomp",
49 "-version");
50 OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
51 try {
52 analyzer.shouldHaveExitValue(0);
53 } catch (RuntimeException e) {
54 // Error occurred during initialization, did we run out of adapter space?
55 assertTrue(analyzer.getOutput().contains("VirtualMachineError: Out of space in CodeCache"),
56 "Expected VirtualMachineError");
57 }
Albert Noll65203202014-10-24 14:25:46 +020058
Tobias Hartmannf9806ff2014-12-04 09:52:15 +010059 System.out.println("TEST PASSED");
Albert Nollaef0d742013-10-10 15:44:12 +020060 }
61}