1 /* |
|
2 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
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 8175312 |
|
27 * @summary Test clhsdb 'g1regiondetails' and 'scanoops' commands for G1GC |
|
28 * @requires vm.hasSA & (vm.bits == "64" & os.maxMemory > 8g) |
|
29 * @library /test/lib |
|
30 * @run main/othervm/timeout=2400 ClhsdbRegionDetailsScanOopsForG1 |
|
31 */ |
|
32 |
|
33 import java.util.HashMap; |
|
34 import java.util.List; |
|
35 import java.util.ArrayList; |
|
36 import java.util.Map; |
|
37 import jdk.test.lib.apps.LingeredApp; |
|
38 import jtreg.SkippedException; |
|
39 |
|
40 public class ClhsdbRegionDetailsScanOopsForG1 { |
|
41 |
|
42 public static void main(String[] args) throws Exception { |
|
43 System.out.println("Starting ClhsdbRegionDetailsScanOopsForG1 test"); |
|
44 |
|
45 LingeredAppWithLargeStringArray theApp = null; |
|
46 try { |
|
47 ClhsdbLauncher test = new ClhsdbLauncher(); |
|
48 List<String> vmArgs = new ArrayList<String>(); |
|
49 vmArgs.add("-XX:+UseG1GC"); |
|
50 vmArgs.add("-Xmx8g"); |
|
51 vmArgs.add("-XX:G1HeapRegionSize=2m"); |
|
52 |
|
53 theApp = new LingeredAppWithLargeStringArray(); |
|
54 LingeredApp.startApp(vmArgs, theApp); |
|
55 System.out.println("Started LingeredAppWithLargeStringArray with pid " + theApp.getPid()); |
|
56 |
|
57 List<String> cmds = List.of("g1regiondetails"); |
|
58 Map<String, List<String>> expStrMap = new HashMap<>(); |
|
59 Map<String, List<String>> unExpStrMap = new HashMap<>(); |
|
60 |
|
61 // Test that the various types of regions are listed with the |
|
62 // 'g1regiondetails' command |
|
63 expStrMap.put("g1regiondetails", List.of( |
|
64 "Region", |
|
65 "Eden", |
|
66 "Survivor", |
|
67 "StartsHumongous", |
|
68 "ContinuesHumongous", |
|
69 "Free")); |
|
70 unExpStrMap.put("g1regiondetails", List.of("Unknown Region Type")); |
|
71 String regionDetailsOutput = test.run(theApp.getPid(), cmds, |
|
72 expStrMap, unExpStrMap); |
|
73 // Test the output of 'scanoops' -- get the start and end addresses |
|
74 // from the StartsHumongous region. Ensure that it contains an |
|
75 // array of Strings. |
|
76 String[] snippets = regionDetailsOutput.split(":StartsHumongous"); |
|
77 snippets = snippets[0].split("Region: "); |
|
78 String[] words = snippets[snippets.length - 1].split(","); |
|
79 // words[0] and words[1] represent the start and end addresses |
|
80 String cmd = "scanoops " + words[0] + " " + words[1]; |
|
81 expStrMap = new HashMap<>(); |
|
82 expStrMap.put(cmd, List.of("\\[Ljava/lang/String")); |
|
83 test.run(theApp.getPid(), List.of(cmd), expStrMap, null); |
|
84 } catch (SkippedException e) { |
|
85 throw e; |
|
86 } catch (Exception ex) { |
|
87 throw new RuntimeException("Test ERROR " + ex, ex); |
|
88 } finally { |
|
89 LingeredApp.stopApp(theApp); |
|
90 } |
|
91 System.out.println("Test PASSED"); |
|
92 } |
|
93 } |
|