7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import org.testng.annotations.Test; 25 import org.testng.Assert; 26 27 import com.oracle.java.testlibrary.OutputAnalyzer; 28 29 import com.oracle.java.testlibrary.dcmd.CommandExecutor; 30 import com.oracle.java.testlibrary.dcmd.JMXExecutor; 31 32 import java.util.concurrent.BrokenBarrierException; 33 import java.util.concurrent.CyclicBarrier; 34 import java.util.concurrent.locks.ReentrantLock; 35 import java.util.regex.Pattern; 36 37 /* 38 * @test 39 * @summary Test of diagnostic command Thread.print 40 * @library /testlibrary 41 * @modules java.base/sun.misc 42 * java.compiler 43 * java.management 44 * jdk.jvmstat/sun.jvmstat.monitor 45 * @build com.oracle.java.testlibrary.* 46 * @build com.oracle.java.testlibrary.dcmd.* 47 * @run testng PrintTest 48 */ 49 public class PrintTest { 50 protected boolean jucLocks = false; 51 52 CyclicBarrier readyBarrier = new CyclicBarrier(3); 53 CyclicBarrier doneBarrier = new CyclicBarrier(3); 54 55 private void waitForBarrier(CyclicBarrier b) { 56 try { 57 b.await(); 58 } catch (InterruptedException | BrokenBarrierException e) { 59 Assert.fail("Test error: Caught unexpected exception:", e); 60 } 61 } 62 63 class MonitorThread extends Thread { 64 Object lock = new Object(); 65 66 public void run() { 132 * - parking to wait for <0x000000071a0868a8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) 133 * at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) 134 * at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) 135 * at java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:234) 136 * at java.util.concurrent.CyclicBarrier.await(CyclicBarrier.java:362) 137 * at Print.waitForBarrier(Print.java:26) 138 * at Print.access$000(Print.java:18) 139 * at Print$MonitorThread.run(Print.java:42) 140 * --> - locked <0x000000071a294390> (a java.lang.Object) 141 * 142 * Locked ownable synchronizers: 143 * - None 144 * 145 * "MainThread" #22 prio=5 os_prio=0 tid=0x00007f923015b000 nid=0x4fc7 in Object.wait() [0x00007f9200840000] 146 * java.lang.Thread.State: WAITING (on object monitor) 147 * at java.lang.Object.wait(Native Method) 148 * - waiting on <0x000000071a70ad98> (a java.lang.UNIXProcess) 149 * at java.lang.Object.wait(Object.java:502) 150 * at java.lang.UNIXProcess.waitFor(UNIXProcess.java:397) 151 * - locked <0x000000071a70ad98> (a java.lang.UNIXProcess) 152 * at com.oracle.java.testlibrary.dcmd.JcmdExecutor.executeImpl(JcmdExecutor.java:32) 153 * at com.oracle.java.testlibrary.dcmd.CommandExecutor.execute(CommandExecutor.java:24) 154 * --> at Print.run(Print.java:74) 155 * at Print.file(Print.java:112) 156 * ... 157 158 */ 159 output.shouldMatch(".*at " + Pattern.quote(PrintTest.class.getName()) + "\\.run.*"); 160 output.shouldMatch(".*- locked <0x\\p{XDigit}+> \\(a " + Pattern.quote(mThread.lock.getClass().getName()) + "\\).*"); 161 162 String jucLockPattern1 = ".*Locked ownable synchronizers:.*"; 163 String jucLockPattern2 = ".*- <0x\\p{XDigit}+> \\(a " + Pattern.quote(lThread.lock.getClass().getName()) + ".*"; 164 165 if (jucLocks) { 166 output.shouldMatch(jucLockPattern1); 167 output.shouldMatch(jucLockPattern2); 168 } else { 169 output.shouldNotMatch(jucLockPattern1); 170 output.shouldNotMatch(jucLockPattern2); 171 } 172 } 173 | 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import org.testng.annotations.Test; 25 import org.testng.Assert; 26 27 import jdk.test.lib.OutputAnalyzer; 28 29 import jdk.test.lib.dcmd.CommandExecutor; 30 import jdk.test.lib.dcmd.JMXExecutor; 31 32 import java.util.concurrent.BrokenBarrierException; 33 import java.util.concurrent.CyclicBarrier; 34 import java.util.concurrent.locks.ReentrantLock; 35 import java.util.regex.Pattern; 36 37 /* 38 * @test 39 * @summary Test of diagnostic command Thread.print 40 * @library /testlibrary 41 * @modules java.base/sun.misc 42 * java.compiler 43 * java.management 44 * jdk.jvmstat/sun.jvmstat.monitor 45 * @build jdk.test.lib.* 46 * @build jdk.test.lib.dcmd.* 47 * @run testng PrintTest 48 */ 49 public class PrintTest { 50 protected boolean jucLocks = false; 51 52 CyclicBarrier readyBarrier = new CyclicBarrier(3); 53 CyclicBarrier doneBarrier = new CyclicBarrier(3); 54 55 private void waitForBarrier(CyclicBarrier b) { 56 try { 57 b.await(); 58 } catch (InterruptedException | BrokenBarrierException e) { 59 Assert.fail("Test error: Caught unexpected exception:", e); 60 } 61 } 62 63 class MonitorThread extends Thread { 64 Object lock = new Object(); 65 66 public void run() { 132 * - parking to wait for <0x000000071a0868a8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) 133 * at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) 134 * at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) 135 * at java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:234) 136 * at java.util.concurrent.CyclicBarrier.await(CyclicBarrier.java:362) 137 * at Print.waitForBarrier(Print.java:26) 138 * at Print.access$000(Print.java:18) 139 * at Print$MonitorThread.run(Print.java:42) 140 * --> - locked <0x000000071a294390> (a java.lang.Object) 141 * 142 * Locked ownable synchronizers: 143 * - None 144 * 145 * "MainThread" #22 prio=5 os_prio=0 tid=0x00007f923015b000 nid=0x4fc7 in Object.wait() [0x00007f9200840000] 146 * java.lang.Thread.State: WAITING (on object monitor) 147 * at java.lang.Object.wait(Native Method) 148 * - waiting on <0x000000071a70ad98> (a java.lang.UNIXProcess) 149 * at java.lang.Object.wait(Object.java:502) 150 * at java.lang.UNIXProcess.waitFor(UNIXProcess.java:397) 151 * - locked <0x000000071a70ad98> (a java.lang.UNIXProcess) 152 * at jdk.test.lib.dcmd.JcmdExecutor.executeImpl(JcmdExecutor.java:32) 153 * at jdk.test.lib.dcmd.CommandExecutor.execute(CommandExecutor.java:24) 154 * --> at Print.run(Print.java:74) 155 * at Print.file(Print.java:112) 156 * ... 157 158 */ 159 output.shouldMatch(".*at " + Pattern.quote(PrintTest.class.getName()) + "\\.run.*"); 160 output.shouldMatch(".*- locked <0x\\p{XDigit}+> \\(a " + Pattern.quote(mThread.lock.getClass().getName()) + "\\).*"); 161 162 String jucLockPattern1 = ".*Locked ownable synchronizers:.*"; 163 String jucLockPattern2 = ".*- <0x\\p{XDigit}+> \\(a " + Pattern.quote(lThread.lock.getClass().getName()) + ".*"; 164 165 if (jucLocks) { 166 output.shouldMatch(jucLockPattern1); 167 output.shouldMatch(jucLockPattern2); 168 } else { 169 output.shouldNotMatch(jucLockPattern1); 170 output.shouldNotMatch(jucLockPattern2); 171 } 172 } 173 |