hotspot/test/runtime/logging/BiasedLockingTest.java
author ctornqvi
Fri, 19 Aug 2016 10:06:30 -0400
changeset 40631 ed82623d7831
parent 36851 03e2f4d0a421
child 41705 332239c052cc
permissions -rw-r--r--
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder Reviewed-by: coleenp, gtriantafill, mseledtsov, iignatyev, dholmes, dsamersoff
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
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    28
 * @library /test/lib
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
 * @run driver BiasedLockingTest
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    32
 */
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    33
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    34
import jdk.test.lib.process.OutputAnalyzer;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    35
import jdk.test.lib.process.ProcessTools;
36186
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    36
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    37
public class BiasedLockingTest {
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    38
    static void analyzeOutputOn(ProcessBuilder pb) throws Exception {
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    39
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    40
        output.shouldContain("Biased locking enabled");
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    41
        output.shouldHaveExitValue(0);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    42
    }
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    43
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    44
    static void analyzeOutputOff(ProcessBuilder pb) throws Exception {
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    45
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    46
        output.shouldNotContain("[biasedlocking]");
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    47
        output.shouldHaveExitValue(0);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    48
    }
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    49
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    50
    public static void main(String[] args) throws Exception {
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    51
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:biasedlocking",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    52
                                                                  "-XX:BiasedLockingStartupDelay=0",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    53
                                                                  InnerClass.class.getName());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    54
        analyzeOutputOn(pb);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    55
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    56
        pb = ProcessTools.createJavaProcessBuilder("-XX:+TraceBiasedLocking",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    57
                                                   "-XX:BiasedLockingStartupDelay=0",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    58
                                                   InnerClass.class.getName());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    59
        analyzeOutputOn(pb);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    60
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    61
        pb = ProcessTools.createJavaProcessBuilder("-Xlog:biasedlocking=off",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    62
                                                   "-XX:BiasedLockingStartupDelay=0",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    63
                                                   InnerClass.class.getName());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    64
        analyzeOutputOff(pb);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    65
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    66
        pb = ProcessTools.createJavaProcessBuilder("-XX:-TraceBiasedLocking",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    67
                                                   "-XX:BiasedLockingStartupDelay=0",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    68
                                                   InnerClass.class.getName());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    69
        analyzeOutputOff(pb);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    70
    }
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    71
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    72
    public static class InnerClass {
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    73
        public static void main(String[] args) {
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    74
            System.out.println("Biased Locking test");
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    75
        }
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    76
    }
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    77
}