blob: 35a397f2c00fa09d21e60528cc72bf8375bf9d95 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001#!/bin/sh
2
3#
4# Copyright 2003 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22# CA 95054 USA or visit www.sun.com if you need additional information or
23# have any questions.
24#
25
26# @test
27# @bug 4847812
28# @summary TTY: jdb lock command displays incorrect data
29# @author Jim Holmlund
30# @run shell JdbLockTest.sh
31
32# These are variables that can be set to control execution
33
34#pkg=untitled7
35classname=JdbLockTest
36compileOptions=-g
37#java="java_g"
38
39createJavaFile()
40{
41 cat <<EOF > $classname.java.1
42public class $classname {
43 static String jj = "jj";
44 public static void main(String args[]) {
45 synchronized(jj) {
46 sleeper xx = new sleeper();
47 xx.start();
48 // Give the sleeper a chance to run and get to
49 // the synchronized statement.
50 while(sleeper.started == 0) {
51 try {
52 Thread.sleep(100);
53 } catch(InterruptedException ee) {
54 }
55 }
56 // At this bkpt, sleeper should be waiting on $classname.jj
57 System.out.println("Hello sailor"); // @1 breakpoint
58 }
59 }
60}
61
62class sleeper extends Thread {
63 public static int started = 0;
64 public void run() {
65 started = 1;
66 System.out.println(" sleeper starts sleeping");
67 synchronized($classname.jj) {
68 System.out.println(" sleeper got the lock");
69 }
70 System.out.println(" sleeper awakes");
71 }
72}
73
74EOF
75}
76
77
78# drive jdb by sending cmds to it and examining its output
79dojdbCmds()
80{
81 setBkpts @1
82 runToBkpt @1
83 # This should say that main owns the lock
84 # and the sleeper thread is waiting for it.
85 cmd lock $classname.jj
86 cmd quit
87}
88
89
90mysetup()
91{
92 if [ -z "$TESTSRC" ] ; then
93 TESTSRC=.
94 fi
95
96 for ii in . $TESTSRC $TESTSRC/.. ; do
97 if [ -r "$ii/ShellScaffold.sh" ] ; then
98 . $ii/ShellScaffold.sh
99 break
100 fi
101 done
102}
103
104# You could replace this next line with the contents
105# of ShellScaffold.sh and this script will run just the same.
106mysetup
107
108runit
109jdbFailIfPresent "Waiting thread: main"
110pass