1 /* |
1 /* |
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @key nmt jcmd |
26 * @key nmt jcmd |
27 * @library /testlibrary /testlibrary/whitebox |
27 * @library /testlibrary /testlibrary/whitebox |
28 * @build ThreadedVirtualAllocTestType |
28 * @build ThreadedVirtualAllocTestType |
|
29 * @ignore |
29 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
30 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
30 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ThreadedVirtualAllocTestType |
31 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail ThreadedVirtualAllocTestType |
31 */ |
32 */ |
32 |
33 |
33 import com.oracle.java.testlibrary.*; |
34 import com.oracle.java.testlibrary.*; |
58 } |
59 } |
59 }; |
60 }; |
60 reserveThread.start(); |
61 reserveThread.start(); |
61 reserveThread.join(); |
62 reserveThread.join(); |
62 |
63 |
63 mergeData(); |
|
64 |
|
65 pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"}); |
64 pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"}); |
66 output = new OutputAnalyzer(pb.start()); |
65 output = new OutputAnalyzer(pb.start()); |
67 output.shouldContain("Test (reserved=512KB, committed=0KB)"); |
66 output.shouldContain("Test (reserved=512KB, committed=0KB)"); |
68 if (has_nmt_detail) { |
67 if (has_nmt_detail) { |
69 output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved 512KB for Test"); |
68 output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved 512KB for Test"); |
91 } |
88 } |
92 }; |
89 }; |
93 uncommitThread.start(); |
90 uncommitThread.start(); |
94 uncommitThread.join(); |
91 uncommitThread.join(); |
95 |
92 |
96 mergeData(); |
|
97 |
|
98 output = new OutputAnalyzer(pb.start()); |
93 output = new OutputAnalyzer(pb.start()); |
99 output.shouldContain("Test (reserved=512KB, committed=0KB)"); |
94 output.shouldContain("Test (reserved=512KB, committed=0KB)"); |
100 output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed"); |
95 output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed"); |
101 |
96 |
102 Thread releaseThread = new Thread() { |
97 Thread releaseThread = new Thread() { |
105 } |
100 } |
106 }; |
101 }; |
107 releaseThread.start(); |
102 releaseThread.start(); |
108 releaseThread.join(); |
103 releaseThread.join(); |
109 |
104 |
110 mergeData(); |
|
111 |
|
112 output = new OutputAnalyzer(pb.start()); |
105 output = new OutputAnalyzer(pb.start()); |
113 output.shouldNotContain("Test (reserved="); |
106 output.shouldNotContain("Test (reserved="); |
114 output.shouldNotContain("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved"); |
107 output.shouldNotContain("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved"); |
115 } |
108 } |
116 |
109 |
117 public static void mergeData() throws Exception { |
|
118 // Use WB API to ensure that all data has been merged before we continue |
|
119 if (!wb.NMTWaitForDataMerge()) { |
|
120 throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); |
|
121 } |
110 } |
122 } |
|
123 } |
|