Path: blob/master/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java
41152 views
/*1* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.util.HashMap;24import java.util.List;25import java.util.Map;2627import jdk.test.lib.apps.LingeredApp;28import jdk.test.lib.Utils;29import jtreg.SkippedException;3031/**32* @test33* @bug 819019834* @bug 821761235* @bug 821784536* @summary Test clhsdb flags command37* @requires vm.hasSA38* @library /test/lib39* @run main/othervm ClhsdbFlags40*/4142public class ClhsdbFlags {4344public static void runBasicTest() throws Exception {45System.out.println("Starting ClhsdbFlags basic test");4647LingeredApp theApp = null;48try {49ClhsdbLauncher test = new ClhsdbLauncher();50theApp = LingeredApp.startApp(51"-XX:+UnlockExperimentalVMOptions",52"-XX:+UnlockDiagnosticVMOptions",53"-XX:-MaxFDLimit");54System.out.println("Started LingeredApp with pid " + theApp.getPid());5556List<String> cmds = List.of(57"flags", "flags -nd",58"flags UnlockDiagnosticVMOptions", "flags MaxFDLimit",59"flags MaxJavaStackTraceDepth");6061Map<String, List<String>> expStrMap = new HashMap<>();62expStrMap.put("flags", List.of(63"command line", "ergonomic", "default",64"UnlockDiagnosticVMOptions = true",65"MaxFDLimit = false",66"MaxJavaStackTraceDepth = 1024",67"ConcGCThreads", "UseThreadPriorities",68"ShowHiddenFrames"));69expStrMap.put("flags -nd", List.of(70"UnlockDiagnosticVMOptions = true",71"MaxFDLimit = false",72"InitialHeapSize",73"MaxHeapSize"));74expStrMap.put("flags UnlockDiagnosticVMOptions", List.of(75"UnlockDiagnosticVMOptions = true"));76expStrMap.put("flags MaxFDLimit", List.of(77"MaxFDLimit = false"));78expStrMap.put("flags MaxJavaStackTraceDepth", List.of(79"MaxJavaStackTraceDepth = 1024"));8081test.run(theApp.getPid(), cmds, expStrMap, null);82} catch (SkippedException se) {83throw se;84} catch (Exception ex) {85throw new RuntimeException("Test ERROR " + ex, ex);86} finally {87LingeredApp.stopApp(theApp);88}89System.out.println("Test PASSED");90}9192public static void runAllTypesTest() throws Exception {93System.out.println("Starting ClhsdbFlags all types test");9495LingeredApp theApp = null;96try {97ClhsdbLauncher test = new ClhsdbLauncher();98// *Prepend* options to prevent interference with flags below99String[] vmArgs = Utils.prependTestJavaOpts(100"-XX:+UnlockDiagnosticVMOptions", // bool101"-XX:ActiveProcessorCount=1", // int102"-XX:ParallelGCThreads=1", // uint103"-XX:MaxJavaStackTraceDepth=1024", // intx104"-XX:LogEventsBufferEntries=10", // uintx105"-XX:HeapSizePerGCThread=32m", // size_t106"-XX:NativeMemoryTracking=off", // ccstr107"-XX:OnError='echo error'", // ccstrlist108"-XX:CompileThresholdScaling=1.0", // double109"-XX:ErrorLogTimeout=120"); // uint64_t110theApp = new LingeredApp();111LingeredApp.startAppExactJvmOpts(theApp, vmArgs);112System.out.println("Started LingeredApp with pid " + theApp.getPid());113114List<String> cmds = List.of("flags");115116Map<String, List<String>> expStrMap = new HashMap<>();117expStrMap.put("flags", List.of(118"UnlockDiagnosticVMOptions = true",119"ActiveProcessorCount = 1",120"ParallelGCThreads = 1",121"MaxJavaStackTraceDepth = 1024",122"LogEventsBufferEntries = 10",123"HeapSizePerGCThread = 3",124"NativeMemoryTracking = \"off\"",125"OnError = \"'echo error'\"",126"CompileThresholdScaling = 1.0",127"ErrorLogTimeout = 120"));128129test.run(theApp.getPid(), cmds, expStrMap, null);130} catch (Exception ex) {131throw new RuntimeException("Test ERROR " + ex, ex);132} finally {133LingeredApp.stopApp(theApp);134}135System.out.println("Test PASSED");136}137138public static void main(String[] args) throws Exception {139runBasicTest();140runAllTypesTest();141}142}143144145