MixedSuspendTest.sh revision 17113:d17577d4839b
1#!/bin/sh 2 3# 4# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. 5# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6# 7# This code is free software; you can redistribute it and/or modify it 8# under the terms of the GNU General Public License version 2 only, as 9# published by the Free Software Foundation. 10# 11# This code is distributed in the hope that it will be useful, but WITHOUT 12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14# version 2 for more details (a copy is included in the LICENSE file that 15# accompanied this code). 16# 17# You should have received a copy of the GNU General Public License version 18# 2 along with this work; if not, write to the Free Software Foundation, 19# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20# 21# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22# or visit www.oracle.com if you need additional information or have any 23# questions. 24# 25 26# @test 27# @bug 6224859 28# @key intermittent 29# @summary JDWP: Mixing application suspends and debugger suspends can cause hangs 30# @author Jim Holmlund 31# 32# @run build TestScaffold VMConnection TargetListener TargetAdapter 33# @run shell MixedSuspendTest.sh 34 35classname=MixedSuspendTarg 36 37createJavaFile() 38{ 39 cat <<EOF > $classname.java.1 40 41import java.util.*; 42 43public class $classname extends Thread { 44 45 static volatile boolean started = true; 46 static String lock = "startLock"; 47 48 public static void main(String[] args){ 49 System.out.println("Howdy from MixedSuspendTarg"); 50 51 MixedSuspendTarg mytarg = new MixedSuspendTarg(); 52 53 synchronized(lock) { 54 mytarg.start(); 55 try { 56 lock.wait(); 57 } catch(InterruptedException ee) { 58 } 59 } 60 mytarg.suspend(); 61 bkpt(); 62 System.out.println("Debuggee: resuming thread"); 63 64 // If the bug occurs, this resume hangs in the back-end 65 mytarg.resume(); 66 System.out.println("Debuggee: resumed thread"); 67 synchronized(lock) { 68 started = false; 69 } 70 System.out.println("Debuggee: exitting, started = " + started); 71 } 72 73 public void run() { 74 synchronized(lock) { 75 lock.notifyAll(); 76 } 77 while (true) { 78 synchronized(lock) { 79 if (!started) { 80 break; 81 } 82 int i = 0; 83 } 84 } 85 86 System.out.println("Debuggee: end of thread"); 87 } 88 89 static void bkpt() { 90 //System.out.println("bkpt reached, thread = " + this.getName()); 91 int i = 0; // @1 breakpoint 92 } 93} 94 95EOF 96} 97 98dojdbCmds() 99{ 100 setBkpts @1 101 runToBkpt @1 102 cmd allowExit cont 103} 104 105 106mysetup() 107{ 108 if [ -z "$TESTSRC" ] ; then 109 TESTSRC=. 110 fi 111 112 for ii in . $TESTSRC $TESTSRC/.. ; do 113 if [ -r "$ii/ShellScaffold.sh" ] ; then 114 . $ii/ShellScaffold.sh 115 break 116 fi 117 done 118} 119 120# You could replace this next line with the contents 121# of ShellScaffold.sh and this script will run just the same. 122mysetup 123 124runit 125## This test fails by timing out. 126pass 127