author | iignatyev |
Thu, 02 Aug 2018 14:40:55 -0700 | |
changeset 51287 | 7b1ddbafa134 |
parent 47216 | 71c04702a3d5 |
child 53557 | 4cfe0e5a3b79 |
permissions | -rw-r--r-- |
35171
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
1 |
/* |
35858
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35221
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
35171
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
4 |
* |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
8 |
* |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation 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 |
35171
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
13 |
* accompanied this code). |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
14 |
* |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
18 |
* |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
21 |
* questions. |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
22 |
*/ |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
23 |
|
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
24 |
/* |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
25 |
* @test |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
26 |
* @bug 8133885 |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
27 |
* @summary monitorinflation=debug should have logging from each of the statements in the code |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
28 |
* @library /test/lib |
36851 | 29 |
* @modules java.base/jdk.internal.misc |
35171
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
30 |
* java.management |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
31 |
* @run driver MonitorInflationTest |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
32 |
*/ |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation 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; |
35171
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
36 |
|
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
37 |
public class MonitorInflationTest { |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
38 |
static void analyzeOutputOn(ProcessBuilder pb) throws Exception { |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
39 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
40 |
output.shouldContain("Inflating object"); |
35221
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
41 |
output.shouldContain("type MonitorInflationTest$Waiter"); |
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
42 |
output.shouldContain("I've been waiting."); |
35171
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
43 |
output.shouldHaveExitValue(0); |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
44 |
} |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
45 |
|
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
46 |
static void analyzeOutputOff(ProcessBuilder pb) throws Exception { |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
47 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
48 |
output.shouldNotContain("[monitorinflation]"); |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
49 |
output.shouldHaveExitValue(0); |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
50 |
} |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
51 |
|
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
52 |
public static void main(String[] args) throws Exception { |
35858
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35221
diff
changeset
|
53 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:monitorinflation=debug", |
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35221
diff
changeset
|
54 |
InnerClass.class.getName()); |
35171
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
55 |
analyzeOutputOn(pb); |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
56 |
|
35858
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35221
diff
changeset
|
57 |
pb = ProcessTools.createJavaProcessBuilder("-XX:+TraceMonitorInflation", |
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35221
diff
changeset
|
58 |
InnerClass.class.getName()); |
35171
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
59 |
analyzeOutputOn(pb); |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
60 |
|
35858
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35221
diff
changeset
|
61 |
pb = ProcessTools.createJavaProcessBuilder("-Xlog:monitorinflation=off", |
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35221
diff
changeset
|
62 |
InnerClass.class.getName()); |
35171
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
63 |
analyzeOutputOff(pb); |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
64 |
|
35858
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35221
diff
changeset
|
65 |
pb = ProcessTools.createJavaProcessBuilder("-XX:-TraceMonitorInflation", |
6e704583a38f
8146435: [TESTBUG] Logging tests are failing intermittently on windows when executed by JPRT
rprotacio
parents:
35221
diff
changeset
|
66 |
InnerClass.class.getName()); |
35171
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
67 |
analyzeOutputOff(pb); |
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
68 |
} |
35221
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
69 |
|
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
70 |
public static class Waiter { |
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
71 |
public static void foo() { |
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
72 |
System.out.println("I've been waiting."); |
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
73 |
} |
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
74 |
} |
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
75 |
public static class InnerClass { |
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
76 |
public static void main(String[] args) throws Exception { |
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
77 |
Waiter w = new Waiter(); |
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
78 |
synchronized (w) { |
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
79 |
w.wait(100); |
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
80 |
w.foo(); |
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
81 |
} |
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
82 |
} |
9d8ada7b9fee
8145606: [TESTBUG] MonitorInflationTest.java should be rewritten to be more predictable
rprotacio
parents:
35193
diff
changeset
|
83 |
} |
35171
cf7d5a1d0662
8145153: Convert TraceMonitorInflation to Unified Logging
rprotacio
parents:
diff
changeset
|
84 |
} |