test/runtime/EnableTracing/TestEnableTracing.java

Fri, 14 Sep 2018 07:58:22 -0700

author
phh
date
Fri, 14 Sep 2018 07:58:22 -0700
changeset 9483
16b9bbfaa450
child 9893
be5266057dda
permissions
-rw-r--r--

8209863: Add a test to verify that -XX:+EnableTracing works
Summary: A new test verifies that tracing output occurs with the switch enabled.
Reviewed-by: dholmes, phh
Contributed-by: Xin Liu <xxinliu@amazon.com>

phh@9483 1 /*
phh@9483 2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
phh@9483 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
phh@9483 4 *
phh@9483 5 * This code is free software; you can redistribute it and/or modify it
phh@9483 6 * under the terms of the GNU General Public License version 2 only, as
phh@9483 7 * published by the Free Software Foundation.
phh@9483 8 *
phh@9483 9 * This code is distributed in the hope that it will be useful, but WITHOUT
phh@9483 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
phh@9483 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
phh@9483 12 * version 2 for more details (a copy is included in the LICENSE file that
phh@9483 13 * accompanied this code).
phh@9483 14 *
phh@9483 15 * You should have received a copy of the GNU General Public License version
phh@9483 16 * 2 along with this work; if not, write to the Free Software Foundation,
phh@9483 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
phh@9483 18 *
phh@9483 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
phh@9483 20 * or visit www.oracle.com if you need additional information or have any
phh@9483 21 * questions.
phh@9483 22 */
phh@9483 23
phh@9483 24 /*
phh@9483 25 * @test TestEnableTracing
phh@9483 26 * @summary Test if tracing produces the expected output when enabled.
phh@9483 27 * @bug 8209863 8145788
phh@9483 28 * @library /testlibrary
phh@9483 29 * @run main TestEnableTracing
phh@9483 30 */
phh@9483 31
phh@9483 32 import com.oracle.java.testlibrary.ProcessTools;
phh@9483 33 import com.oracle.java.testlibrary.OutputAnalyzer;
phh@9483 34
phh@9483 35 public class TestEnableTracing {
phh@9483 36 public static final String OPENJDK_MARK = "OpenJDK";
phh@9483 37
phh@9483 38 public static void main(String[] args) throws Exception {
phh@9483 39 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+EnableTracing", "-version");
phh@9483 40 OutputAnalyzer output = new OutputAnalyzer(pb.start());
phh@9483 41 if (output.getStderr().contains(OPENJDK_MARK)) {
phh@9483 42 output.shouldMatch("^Class Load");
phh@9483 43 output.shouldContain("Loaded Class ="); // verify TraceStream print_val Klass*
phh@9483 44 }
phh@9483 45 output.shouldHaveExitValue(0);
phh@9483 46
phh@9483 47 pb = ProcessTools.createJavaProcessBuilder("-XX:+EnableTracing", "-XX:+UseLockedTracing", "-Xcomp ", "-version");
phh@9483 48 output = new OutputAnalyzer(pb.start());
phh@9483 49 if (output.getStderr().contains(OPENJDK_MARK)) {
phh@9483 50 output.shouldMatch("^Class Load");
phh@9483 51 output.shouldMatch("^Compilation");
phh@9483 52 output.shouldContain("Java Method ="); // verify TraceStream print_val Method*
phh@9483 53 }
phh@9483 54 output.shouldHaveExitValue(0);
phh@9483 55 }
phh@9483 56 }

mercurial