hotspot/test/runtime/logging/BiasedLockingTest.java
author chegar
Sat, 09 Apr 2016 23:03:39 +0100
changeset 36851 03e2f4d0a421
parent 36186 06763de0d7ad
child 40631 ed82623d7831
permissions -rw-r--r--
8153737: Unsupported Module Reviewed-by: alanb, mchung, psandoz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36186
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
     1
/*
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
     4
 *
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
     7
 * published by the Free Software Foundation.
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
     8
 *
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.    See the GNU General Public License
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    13
 * accompanied this code).
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    14
 *
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    18
 *
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    21
 * questions.
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    22
 */
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    23
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    24
/*
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    25
 * @test
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    26
 * @bug 8149383
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    27
 * @summary -Xlog:biasedlocking should have logging from statements in the source code
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    28
 * @library /testlibrary
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 36186
diff changeset
    29
 * @modules java.base/jdk.internal.misc
36186
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    30
 *          java.management
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    31
 * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    32
 * @run driver BiasedLockingTest
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    33
 */
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    34
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    35
import jdk.test.lib.OutputAnalyzer;
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    36
import jdk.test.lib.ProcessTools;
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    37
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    38
public class BiasedLockingTest {
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    39
    static void analyzeOutputOn(ProcessBuilder pb) throws Exception {
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    40
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    41
        output.shouldContain("Biased locking enabled");
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    42
        output.shouldHaveExitValue(0);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    43
    }
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    44
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    45
    static void analyzeOutputOff(ProcessBuilder pb) throws Exception {
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    46
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    47
        output.shouldNotContain("[biasedlocking]");
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    48
        output.shouldHaveExitValue(0);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    49
    }
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    50
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    51
    public static void main(String[] args) throws Exception {
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    52
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:biasedlocking",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    53
                                                                  "-XX:BiasedLockingStartupDelay=0",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    54
                                                                  InnerClass.class.getName());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    55
        analyzeOutputOn(pb);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    56
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    57
        pb = ProcessTools.createJavaProcessBuilder("-XX:+TraceBiasedLocking",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    58
                                                   "-XX:BiasedLockingStartupDelay=0",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    59
                                                   InnerClass.class.getName());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    60
        analyzeOutputOn(pb);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    61
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    62
        pb = ProcessTools.createJavaProcessBuilder("-Xlog:biasedlocking=off",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    63
                                                   "-XX:BiasedLockingStartupDelay=0",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    64
                                                   InnerClass.class.getName());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    65
        analyzeOutputOff(pb);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    66
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    67
        pb = ProcessTools.createJavaProcessBuilder("-XX:-TraceBiasedLocking",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    68
                                                   "-XX:BiasedLockingStartupDelay=0",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    69
                                                   InnerClass.class.getName());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    70
        analyzeOutputOff(pb);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    71
    }
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    72
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    73
    public static class InnerClass {
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    74
        public static void main(String[] args) {
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    75
            System.out.println("Biased Locking test");
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    76
        }
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    77
    }
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    78
}