1 /* 2 * Copyright (c) 2013, 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package jdk.jfr.event.gc.configuration; 27 28 import jdk.jfr.consumer.RecordedEvent; 29 import jdk.testlibrary.jfr.EventVerifier; 30 import jdk.testlibrary.OutputAnalyzer; 31 import jdk.testlibrary.ProcessTools; 32 33 /* 34 * @test 35 * @key jfr 36 * @library /lib/testlibrary 37 * @build jdk.jfr.event.gc.configuration.GCHeapConfigurationEventVerifier 38 * @build jdk.jfr.event.gc.configuration.GCHeapConfigurationEventTester 39 * @build jdk.jfr.event.gc.configuration.GCYoungGenerationConfigurationEventTester 40 * @run driver jdk.jfr.event.gc.configuration.TestGCYoungGenerationConfigurationEventWithMinAndMaxSize 41 */ 42 public class TestGCYoungGenerationConfigurationEventWithMinAndMaxSize { 43 public static void main(String[] args) throws Exception { 44 String[] jvm_args = {"-XX:+EnableJFR", 45 "-XX:+UnlockExperimentalVMOptions", 46 "-XX:-UseFastUnorderedTimeStamps", 47 "-XX:NewSize=12m", 48 "-cp", 49 System.getProperty("java.class.path"), 50 "-XX:MaxNewSize=16m", 51 "-Xms32m", 52 "-Xmx64m", 53 Tester.class.getName()}; 54 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(jvm_args); 55 try { 56 OutputAnalyzer analyzer = ProcessTools.executeProcess(pb); 57 analyzer.shouldHaveExitValue(0); 58 } catch (Throwable t) { 59 throw new Exception(t); 60 } 61 } 62 } 63 64 class Tester extends GCYoungGenerationConfigurationEventTester { 65 public static void main(String[] args) throws Exception { 66 new Tester().run(); 67 } 68 69 @Override protected EventVerifier createVerifier(RecordedEvent e) { 70 return new MinAndMaxSizeVerifier(e); 71 } 72 } 73 74 class MinAndMaxSizeVerifier extends EventVerifier { 75 public MinAndMaxSizeVerifier(RecordedEvent e) { 76 super(e); 77 } 78 79 @Override public void verify() throws Exception { 80 verifyMinSizeIs(megabytes(12)); 81 verifyMaxSizeIs(megabytes(16)); 82 83 // Can't test newRatio at the same time as minSize and maxSize, 84 // because the NewRatio flag can't be set when the flags NewSize and 85 // MaxNewSize are set. 86 } 87 88 private void verifyMinSizeIs(long expected) throws Exception { 89 verifyEquals("minSize", expected); 90 } 91 92 private void verifyMaxSizeIs(long expected) throws Exception { 93 verifyEquals("maxSize", expected); 94 } 95 }