7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8174994
27 * @summary Test the clhsdb commands 'jstack', 'printall' with CDS enabled
28 * @requires vm.cds
29 * @library /test/lib
30 * @run main/othervm/timeout=2400 -Xmx1g ClhsdbCDSJstackPrintAll
31 */
32
33 import java.util.List;
34 import java.util.Arrays;
35 import java.util.Map;
36 import java.util.HashMap;
37 import jdk.test.lib.cds.CDSTestUtils;
38 import jdk.test.lib.cds.CDSOptions;
39 import jdk.test.lib.apps.LingeredApp;
40
41 public class ClhsdbCDSJstackPrintAll {
42
43 public static void main(String[] args) throws Exception {
44 System.out.println("Starting ClhsdbCDSJstackPrintAll test");
45 String sharedArchiveName = "ArchiveForClhsdbJstackPrintAll.jsa";
46 LingeredApp theApp = null;
47
60 // Ensure that UseSharedSpaces is turned on.
61 List<String> cmds = List.of("flags UseSharedSpaces");
62
63 String useSharedSpacesOutput = test.run(theApp.getPid(), cmds,
64 null, null);
65
66 if (useSharedSpacesOutput == null) {
67 // Attach permission issues.
68 System.out.println("Could not determine the UseSharedSpaces value - test skipped.");
69 LingeredApp.stopApp(theApp);
70 return;
71 }
72
73 if (!useSharedSpacesOutput.contains("true")) {
74 // CDS archive is not mapped. Skip the rest of the test.
75 System.out.println("The CDS archive is not mapped - test skipped.");
76 LingeredApp.stopApp(theApp);
77 return;
78 }
79
80 cmds = List.of("jstack -v", "printall");
81
82 Map<String, List<String>> expStrMap = new HashMap<>();
83 Map<String, List<String>> unExpStrMap = new HashMap<>();
84 expStrMap.put("jstack -v", List.of(
85 "No deadlocks found",
86 "Common-Cleaner",
87 "Signal Dispatcher",
88 "Method*",
89 "LingeredApp.main"));
90 unExpStrMap.put("jstack -v", List.of(
91 "sun.jvm.hotspot.types.WrongTypeException",
92 "No suitable match for type of address"));
93 expStrMap.put("printall", List.of(
94 "aload_0",
95 "Constant Pool of",
96 "public static void main(java.lang.String[])",
97 "Bytecode",
98 "invokevirtual",
99 "checkcast",
100 "Exception Table",
101 "invokedynamic"));
102 unExpStrMap.put("printall", List.of(
103 "No suitable match for type of address"));
104 test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);
105 } catch (Exception ex) {
106 throw new RuntimeException("Test ERROR " + ex, ex);
107 } finally {
108 LingeredApp.stopApp(theApp);
109 }
110 System.out.println("Test PASSED");
111 }
112 }
|
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8174994
27 * @summary Test the clhsdb commands 'jstack', 'printall', 'where' with CDS enabled
28 * @requires vm.cds
29 * @library /test/lib
30 * @run main/othervm/timeout=2400 -Xmx1g ClhsdbCDSJstackPrintAll
31 */
32
33 import java.util.List;
34 import java.util.Arrays;
35 import java.util.Map;
36 import java.util.HashMap;
37 import jdk.test.lib.cds.CDSTestUtils;
38 import jdk.test.lib.cds.CDSOptions;
39 import jdk.test.lib.apps.LingeredApp;
40
41 public class ClhsdbCDSJstackPrintAll {
42
43 public static void main(String[] args) throws Exception {
44 System.out.println("Starting ClhsdbCDSJstackPrintAll test");
45 String sharedArchiveName = "ArchiveForClhsdbJstackPrintAll.jsa";
46 LingeredApp theApp = null;
47
60 // Ensure that UseSharedSpaces is turned on.
61 List<String> cmds = List.of("flags UseSharedSpaces");
62
63 String useSharedSpacesOutput = test.run(theApp.getPid(), cmds,
64 null, null);
65
66 if (useSharedSpacesOutput == null) {
67 // Attach permission issues.
68 System.out.println("Could not determine the UseSharedSpaces value - test skipped.");
69 LingeredApp.stopApp(theApp);
70 return;
71 }
72
73 if (!useSharedSpacesOutput.contains("true")) {
74 // CDS archive is not mapped. Skip the rest of the test.
75 System.out.println("The CDS archive is not mapped - test skipped.");
76 LingeredApp.stopApp(theApp);
77 return;
78 }
79
80 cmds = List.of("jstack -v", "printall", "where -a");
81
82 Map<String, List<String>> expStrMap = new HashMap<>();
83 Map<String, List<String>> unExpStrMap = new HashMap<>();
84 expStrMap.put("jstack -v", List.of(
85 "No deadlocks found",
86 "Common-Cleaner",
87 "Signal Dispatcher",
88 "Method*",
89 "LingeredApp.main"));
90 unExpStrMap.put("jstack -v", List.of(
91 "sun.jvm.hotspot.types.WrongTypeException",
92 "No suitable match for type of address"));
93 expStrMap.put("printall", List.of(
94 "aload_0",
95 "_nofast_aload_0",
96 "Constant Pool of",
97 "public static void main(java.lang.String[])",
98 "Bytecode",
99 "invokevirtual",
100 "checkcast",
101 "Exception Table",
102 "invokedynamic"));
103 unExpStrMap.put("printall", List.of(
104 "No suitable match for type of address",
105 "illegal code",
106 "Failure occurred at bci"));
107 expStrMap.put("where -a", List.of(
108 "Java Stack Trace for main",
109 "public static void main"));
110 unExpStrMap.put("where -a", List.of(
111 "illegal code",
112 "Failure occurred at bci"));
113 test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);
114 } catch (Exception ex) {
115 throw new RuntimeException("Test ERROR " + ex, ex);
116 } finally {
117 LingeredApp.stopApp(theApp);
118 }
119 System.out.println("Test PASSED");
120 }
121 }
|