author | dtitov |
Fri, 08 Feb 2019 09:41:45 -0800 | |
changeset 53707 | 67537bbafd7f |
child 54460 | 6733a9176cce |
permissions | -rw-r--r-- |
53707
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
1 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
2 |
/* |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
3 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
5 |
* |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
9 |
* |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
14 |
* accompanied this code). |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
15 |
* |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
19 |
* |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
22 |
* questions. |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
23 |
*/ |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
24 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
25 |
import nsk.share.*; |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
26 |
import nsk.share.jpda.*; |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
27 |
import nsk.share.jdi.*; |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
28 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
29 |
/** |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
30 |
* Launches a new Java process that uses a communication pipe to interact |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
31 |
* with the test. |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
32 |
*/ |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
33 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
34 |
public class TestProcessLauncher { |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
35 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
36 |
private final String className; |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
37 |
private final ArgumentHandler argHandler; |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
38 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
39 |
private IOPipe pipe; |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
40 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
41 |
public TestProcessLauncher(String className, ArgumentHandler argHandler) { |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
42 |
this.className = className; |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
43 |
this.argHandler = argHandler; |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
44 |
} |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
45 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
46 |
public TestProcessLauncher(String className) { |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
47 |
this(className, new ArgumentHandler(new String[0])); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
48 |
} |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
49 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
50 |
public Process launch() { |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
51 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
52 |
String java = argHandler.getLaunchExecPath(); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
53 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
54 |
Log log = new Log(System.out, argHandler); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
55 |
Binder binder = new Binder(argHandler, log); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
56 |
binder.prepareForPipeConnection(argHandler); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
57 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
58 |
String cmd = java + " " + className + " -pipe.port=" + argHandler.getPipePort(); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
59 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
60 |
Debugee debuggee = binder.startLocalDebugee(cmd); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
61 |
debuggee.redirectOutput(log); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
62 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
63 |
pipe = new IOPipe(debuggee); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
64 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
65 |
String line = pipe.readln(); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
66 |
if (!"ready".equals(line)) { |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
67 |
System.out.println("Wrong reply received:" + line); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
68 |
} |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
69 |
return debuggee.getProcess(); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
70 |
} |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
71 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
72 |
public void quit() { |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
73 |
if (pipe != null) { |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
74 |
pipe.println("quit"); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
75 |
} |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
76 |
} |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
77 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
78 |
} |