test/hotspot/jtreg/runtime/logging/BiasedLockingTest.java
author stefank
Tue, 05 Jun 2018 15:56:07 +0200
changeset 50402 42ed6e9af319
parent 47216 71c04702a3d5
permissions -rw-r--r--
8204160: BiasedLockingTest needs -XX:+UseBiasedLocking Reviewed-by: eosterlund, dholmes
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
41705
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
36186
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 {
50402
42ed6e9af319 8204160: BiasedLockingTest needs -XX:+UseBiasedLocking
stefank
parents: 47216
diff changeset
    51
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseBiasedLocking",
42ed6e9af319 8204160: BiasedLockingTest needs -XX:+UseBiasedLocking
stefank
parents: 47216
diff changeset
    52
                                                                  "-Xlog:biasedlocking",
36186
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
50402
42ed6e9af319 8204160: BiasedLockingTest needs -XX:+UseBiasedLocking
stefank
parents: 47216
diff changeset
    57
        pb = ProcessTools.createJavaProcessBuilder("-XX:+UseBiasedLocking",
42ed6e9af319 8204160: BiasedLockingTest needs -XX:+UseBiasedLocking
stefank
parents: 47216
diff changeset
    58
                                                   "-XX:+TraceBiasedLocking",
36186
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    59
                                                   "-XX:BiasedLockingStartupDelay=0",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    60
                                                   InnerClass.class.getName());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    61
        analyzeOutputOn(pb);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    62
50402
42ed6e9af319 8204160: BiasedLockingTest needs -XX:+UseBiasedLocking
stefank
parents: 47216
diff changeset
    63
        pb = ProcessTools.createJavaProcessBuilder("-XX:+UseBiasedLocking",
42ed6e9af319 8204160: BiasedLockingTest needs -XX:+UseBiasedLocking
stefank
parents: 47216
diff changeset
    64
                                                   "-Xlog:biasedlocking=off",
36186
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    65
                                                   "-XX:BiasedLockingStartupDelay=0",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    66
                                                   InnerClass.class.getName());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    67
        analyzeOutputOff(pb);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    68
50402
42ed6e9af319 8204160: BiasedLockingTest needs -XX:+UseBiasedLocking
stefank
parents: 47216
diff changeset
    69
        pb = ProcessTools.createJavaProcessBuilder("-XX:+UseBiasedLocking",
42ed6e9af319 8204160: BiasedLockingTest needs -XX:+UseBiasedLocking
stefank
parents: 47216
diff changeset
    70
                                                   "-XX:-TraceBiasedLocking",
36186
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    71
                                                   "-XX:BiasedLockingStartupDelay=0",
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    72
                                                   InnerClass.class.getName());
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    73
        analyzeOutputOff(pb);
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    74
    }
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    75
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    76
    public static class InnerClass {
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    77
        public static void main(String[] args) {
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    78
            System.out.println("Biased Locking test");
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    79
        }
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    80
    }
06763de0d7ad 8149383: Convert TraceBiasedLocking to Unified Logging
rprotacio
parents:
diff changeset
    81
}