Path: blob/master/test/hotspot/jtreg/serviceability/dcmd/vm/TrimLibcHeapTest.java
64507 views
/*1* Copyright (c) 2021 SAP SE. All rights reserved.2* Copyright (c) 2021, 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 it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 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 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*/2324import org.testng.annotations.Test;25import jdk.test.lib.dcmd.CommandExecutor;26import jdk.test.lib.dcmd.JMXExecutor;27import jdk.test.lib.process.OutputAnalyzer;2829/*30* @test31* @summary Test of diagnostic command VM.trim_libc_heap32* @library /test/lib33* @requires os.family == "linux"34* @modules java.base/jdk.internal.misc35* java.compiler36* java.management37* jdk.internal.jvmstat/sun.jvmstat.monitor38* @run testng TrimLibcHeapTest39*/40public class TrimLibcHeapTest {41public void run(CommandExecutor executor) {42OutputAnalyzer output = executor.execute("System.trim_native_heap");43output.reportDiagnosticSummary();44output.shouldMatch("(Done|Not available)"); // Not available could happen on Linux + non-glibc (eg. muslc)45if (output.firstMatch("Done") != null) {46output.shouldMatch("(Virtual size before|RSS before|Swap before|No details available)");47}48}4950@Test51public void jmx() {52run(new JMXExecutor());53}54}555657