1 /* 2 * Copyright (c) 2017, 2020, 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 import java.util.HashMap; 25 import java.util.List; 26 import java.util.Map; 27 28 import jdk.test.lib.apps.LingeredApp; 29 import jdk.test.lib.Utils; 30 import jtreg.SkippedException; 31 32 /** 33 * @test 34 * @bug 8190198 35 * @bug 8217612 36 * @bug 8217845 37 * @summary Test clhsdb flags command 38 * @requires vm.hasSA 39 * @library /test/lib 40 * @run main/othervm ClhsdbFlags 41 */ 42 43 public class ClhsdbFlags { 44 runBasicTest()45 public static void runBasicTest() throws Exception { 46 System.out.println("Starting ClhsdbFlags basic test"); 47 48 LingeredApp theApp = null; 49 try { 50 ClhsdbLauncher test = new ClhsdbLauncher(); 51 theApp = LingeredApp.startApp( 52 "-XX:+UnlockExperimentalVMOptions", 53 "-XX:+UnlockDiagnosticVMOptions", 54 "-XX:-MaxFDLimit"); 55 System.out.println("Started LingeredApp with pid " + theApp.getPid()); 56 57 List<String> cmds = List.of( 58 "flags", "flags -nd", 59 "flags UnlockDiagnosticVMOptions", "flags MaxFDLimit", 60 "flags MaxJavaStackTraceDepth"); 61 62 Map<String, List<String>> expStrMap = new HashMap<>(); 63 expStrMap.put("flags", List.of( 64 "command line", "ergonomic", "default", 65 "UnlockDiagnosticVMOptions = true", 66 "MaxFDLimit = false", 67 "MaxJavaStackTraceDepth = 1024", 68 "VerifyMergedCPBytecodes", 69 "ConcGCThreads", "UseThreadPriorities", 70 "ShowHiddenFrames")); 71 expStrMap.put("flags -nd", List.of( 72 "UnlockDiagnosticVMOptions = true", 73 "MaxFDLimit = false", 74 "InitialHeapSize", 75 "MaxHeapSize")); 76 expStrMap.put("flags UnlockDiagnosticVMOptions", List.of( 77 "UnlockDiagnosticVMOptions = true")); 78 expStrMap.put("flags MaxFDLimit", List.of( 79 "MaxFDLimit = false")); 80 expStrMap.put("flags MaxJavaStackTraceDepth", List.of( 81 "MaxJavaStackTraceDepth = 1024")); 82 83 test.run(theApp.getPid(), cmds, expStrMap, null); 84 } catch (SkippedException se) { 85 throw se; 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 runAllTypesTest()94 public static void runAllTypesTest() throws Exception { 95 System.out.println("Starting ClhsdbFlags all types test"); 96 97 LingeredApp theApp = null; 98 try { 99 ClhsdbLauncher test = new ClhsdbLauncher(); 100 // *Prepend* options to prevent interference with flags below 101 String[] vmArgs = Utils.prependTestJavaOpts( 102 "-XX:+UnlockDiagnosticVMOptions", // bool 103 "-XX:ActiveProcessorCount=1", // int 104 "-XX:ParallelGCThreads=1", // uint 105 "-XX:MaxJavaStackTraceDepth=1024", // intx 106 "-XX:LogEventsBufferEntries=10", // uintx 107 "-XX:HeapSizePerGCThread=32m", // size_t 108 "-XX:NativeMemoryTracking=off", // ccstr 109 "-XX:OnError='echo error'", // ccstrlist 110 "-XX:CompileThresholdScaling=1.0", // double 111 "-XX:ErrorLogTimeout=120"); // uint64_t 112 theApp = new LingeredApp(); 113 LingeredApp.startAppExactJvmOpts(theApp, vmArgs); 114 System.out.println("Started LingeredApp with pid " + theApp.getPid()); 115 116 List<String> cmds = List.of("flags"); 117 118 Map<String, List<String>> expStrMap = new HashMap<>(); 119 expStrMap.put("flags", List.of( 120 "UnlockDiagnosticVMOptions = true", 121 "ActiveProcessorCount = 1", 122 "ParallelGCThreads = 1", 123 "MaxJavaStackTraceDepth = 1024", 124 "LogEventsBufferEntries = 10", 125 "HeapSizePerGCThread = 3", 126 "NativeMemoryTracking = \"off\"", 127 "OnError = \"'echo error'\"", 128 "CompileThresholdScaling = 1.0", 129 "ErrorLogTimeout = 120")); 130 131 test.run(theApp.getPid(), cmds, expStrMap, null); 132 } catch (Exception ex) { 133 throw new RuntimeException("Test ERROR " + ex, ex); 134 } finally { 135 LingeredApp.stopApp(theApp); 136 } 137 System.out.println("Test PASSED"); 138 } 139 main(String[] args)140 public static void main(String[] args) throws Exception { 141 runBasicTest(); 142 runAllTypesTest(); 143 } 144 } 145