author | ihse |
Tue, 20 Feb 2018 21:47:54 +0100 | |
changeset 48923 | b75c9e2e3b1f |
parent 48160 | 599f67f3c6d6 |
child 50791 | b1e90a8a876c |
permissions | -rw-r--r-- |
48160
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
1 |
/* |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
4 |
* |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
8 |
* |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
13 |
* accompanied this code). |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
14 |
* |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
18 |
* |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
21 |
* questions. |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
22 |
*/ |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
23 |
|
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
24 |
import java.util.HashMap; |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
25 |
import java.util.List; |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
26 |
import java.util.Map; |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
27 |
|
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
28 |
import jdk.test.lib.apps.LingeredApp; |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
29 |
|
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
30 |
/* |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
31 |
* @test |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
32 |
* @bug 8191658 |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
33 |
* @summary Test clhsdb attach, detach, reattach commands |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
34 |
* @library /test/lib |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
35 |
* @run main/othervm ClhsdbAttach |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
36 |
*/ |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
37 |
|
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
38 |
public class ClhsdbAttach { |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
39 |
|
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
40 |
public static void main(String[] args) throws Exception { |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
41 |
System.out.println("Starting ClhsdbAttach test"); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
42 |
|
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
43 |
LingeredApp theApp = null; |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
44 |
try { |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
45 |
ClhsdbLauncher test = new ClhsdbLauncher(); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
46 |
theApp = LingeredApp.startApp(); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
47 |
System.out.println("Started LingeredApp with pid " + theApp.getPid()); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
48 |
String attach = "attach " + theApp.getPid(); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
49 |
|
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
50 |
List<String> cmds = List.of( |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
51 |
"where", |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
52 |
attach, |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
53 |
"flags MaxJavaStackTraceDepth", |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
54 |
"detach", |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
55 |
"universe", |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
56 |
"reattach", |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
57 |
"longConstant markOopDesc::locked_value"); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
58 |
|
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
59 |
Map<String, List<String>> expStrMap = new HashMap<>(); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
60 |
expStrMap.put("where", List.of( |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
61 |
"Command not valid until attached to a VM")); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
62 |
expStrMap.put("flags MaxJavaStackTraceDepth", List.of( |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
63 |
"MaxJavaStackTraceDepth = ")); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
64 |
expStrMap.put("universe", List.of( |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
65 |
"Command not valid until attached to a VM")); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
66 |
expStrMap.put("longConstant markOopDesc::locked_value", List.of( |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
67 |
"longConstant markOopDesc::locked_value")); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
68 |
|
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
69 |
test.run(-1, cmds, expStrMap, null); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
70 |
} catch (Exception ex) { |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
71 |
throw new RuntimeException("Test ERROR " + ex, ex); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
72 |
} finally { |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
73 |
LingeredApp.stopApp(theApp); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
74 |
} |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
75 |
System.out.println("Test PASSED"); |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
76 |
} |
599f67f3c6d6
8191658: SA: Testcases for attach, detach, reattach and Jhisto commands
sballal
parents:
diff
changeset
|
77 |
} |