test/runtime/NMT/ThreadedVirtualAllocTestType.java

changeset 7075
ac12996df59b
parent 5586
5fd8e2fbafd4
child 7110
6640f982c1be
equal deleted inserted replaced
7074:833b0f92429a 7075:ac12996df59b
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");
75 } 74 }
76 }; 75 };
77 commitThread.start(); 76 commitThread.start();
78 commitThread.join(); 77 commitThread.join();
79 78
80 mergeData();
81
82 output = new OutputAnalyzer(pb.start()); 79 output = new OutputAnalyzer(pb.start());
83 output.shouldContain("Test (reserved=512KB, committed=128KB)"); 80 output.shouldContain("Test (reserved=512KB, committed=128KB)");
84 if (has_nmt_detail) { 81 if (has_nmt_detail) {
85 output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed 128KB"); 82 output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed 128KB");
86 } 83 }
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 }

mercurial