author | dtitov |
Mon, 08 Apr 2019 17:09:02 +0000 | |
changeset 54460 | 6733a9176cce |
parent 53707 | test/hotspot/jtreg/serviceability/dcmd/framework/TestJavaProcess.java@67537bbafd7f |
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 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
4 |
* |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
5 |
* 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
|
6 |
* 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
|
7 |
* published by the Free Software Foundation. |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
8 |
* |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
9 |
* 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
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
12 |
* 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
|
13 |
* accompanied this code). |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
14 |
* |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
15 |
* 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
|
16 |
* 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
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
18 |
* |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
20 |
* 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
|
21 |
* questions. |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
22 |
*/ |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
23 |
|
54460 | 24 |
package process; |
25 |
||
26 |
import nsk.share.jdi.ArgumentHandler; |
|
27 |
import nsk.share.jpda.IOPipe; |
|
53707
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 |
* A simple process that connects to a pipe and waits for command "quit" to |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
31 |
* be received. |
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 |
* Usage: java TestJavaProcess -pipe.port <PIPE_PORT_NUMBER> |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
34 |
*/ |
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 |
public class TestJavaProcess { |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
37 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
38 |
static final int PASSED = 0; |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
39 |
static final int FAILED = 2; |
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 static void main(String argv[]) { |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
42 |
|
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
43 |
log("Test Java process started!"); |
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 |
ArgumentHandler argHandler = new ArgumentHandler(argv); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
46 |
IOPipe pipe = argHandler.createDebugeeIOPipe(); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
47 |
pipe.println("ready"); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
48 |
log("Waiting for the quit command from the test ..."); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
49 |
String cmd = pipe.readln(); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
50 |
int exitCode = PASSED; |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
51 |
if (cmd.equals("quit")) { |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
52 |
log("'quit' received"); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
53 |
} else { |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
54 |
log("Invalid command received " + cmd); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
55 |
exitCode = FAILED; |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
56 |
} |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
57 |
System.exit(exitCode); |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
58 |
} |
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 |
private static void log(String message) { |
67537bbafd7f
8205654: serviceability/dcmd/framework/HelpTest.java timed out
dtitov
parents:
diff
changeset
|
61 |
System.out.println(message); |
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 |
} |