|
| 1 | +/* |
| 2 | + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * 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 | +/* |
| 26 | + * @test |
| 27 | + * |
| 28 | + * @summary converted from VM Testbase jit/tiered. |
| 29 | + * VM Testbase keywords: [jit, quick] |
| 30 | + * VM Testbase readme: |
| 31 | + * Description |
| 32 | + * The test verifies that JVM prints tiered events with -XX:+PrintTieredEvents |
| 33 | + * for tiered compilation explicitly enabled with -XX:+TieredCompilation. |
| 34 | + * If tiered compilation is explicitly disabled the test verifies that there are no |
| 35 | + * output from PrintTieredEvents. |
| 36 | + * |
| 37 | + * @library /vmTestbase |
| 38 | + * /test/lib |
| 39 | + * @run driver vmTestbase.jit.tiered.Test |
| 40 | + */ |
| 41 | + |
| 42 | +package vmTestbase.jit.tiered; |
| 43 | + |
| 44 | +import jtreg.SkippedException; |
| 45 | +import jdk.test.lib.process.OutputAnalyzer; |
| 46 | +import jdk.test.lib.process.ProcessTools; |
| 47 | + |
| 48 | +public class Test { |
| 49 | + private static String UNSUPPORTED_OPTION_MESSAGE = "-XX:TieredCompilation not supported in this VM"; |
| 50 | + private static String REGEXP = "^[0-9.]+: \\[compile level=\\d"; |
| 51 | + public static void main(String[] args) throws Exception { |
| 52 | + { |
| 53 | + System.out.println("TieredCompilation is enabled"); |
| 54 | + var pb = ProcessTools.createJavaProcessBuilder(true, |
| 55 | + "-XX:+TieredCompilation", |
| 56 | + "-XX:+PrintTieredEvents", |
| 57 | + "-version"); |
| 58 | + var output = new OutputAnalyzer(pb.start()); |
| 59 | + if (output.getStdout().contains(UNSUPPORTED_OPTION_MESSAGE)) { |
| 60 | + throw new SkippedException(UNSUPPORTED_OPTION_MESSAGE); |
| 61 | + } |
| 62 | + output.shouldHaveExitValue(0) |
| 63 | + .stdoutShouldMatch(REGEXP); |
| 64 | + } |
| 65 | + { |
| 66 | + System.out.println("TieredCompilation is disabled"); |
| 67 | + var pb = ProcessTools.createJavaProcessBuilder(true, |
| 68 | + "-XX:-TieredCompilation", |
| 69 | + "-XX:+PrintTieredEvents", |
| 70 | + "-version"); |
| 71 | + var output = new OutputAnalyzer(pb.start()) |
| 72 | + .shouldHaveExitValue(0) |
| 73 | + .stdoutShouldNotMatch(REGEXP); |
| 74 | + } |
| 75 | + } |
| 76 | +} |
0 commit comments