1 /*
2 * Copyright (c) 2015, 2016, 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 */
63 "-XX:G1MixedGCCountTarget=4",
64 "-XX:MaxGCPauseMillis=30000", // to have enough time
65 "-XX:G1HeapRegionSize=1m", "-XX:G1HeapWastePercent=0",
66 "-XX:G1MixedGCLiveThresholdPercent=100"};
67
68 public static final int ALLOCATION_SIZE = 20000;
69 public static final int ALLOCATION_COUNT = 15;
70
71 public static void main(String args[]) throws Exception {
72 // Test turns logging on by giving -Xlog:gc flag
73 test("-Xlog:gc");
74 // Test turns logging on by giving -Xlog:gc=debug flag
75 test("-Xlog:gc=debug");
76 }
77
78 private static void test(String vmFlag) throws Exception {
79 System.out.println(String.format("%s: running with %s flag", TestLogging.class.getSimpleName(), vmFlag));
80 OutputAnalyzer output = spawnMixedGCProvoker(vmFlag);
81 System.out.println(output.getStdout());
82 output.shouldHaveExitValue(0);
83 output.shouldContain("Pause Mixed (G1 Evacuation Pause)");
84 }
85
86 /**
87 * Method spawns MixedGCProvoker with addition flags set
88 *
89 * @parameter extraFlags -flags to be added to the common options set
90 */
91 private static OutputAnalyzer spawnMixedGCProvoker(String... extraFlags)
92 throws Exception {
93 List<String> testOpts = new ArrayList<>();
94 Collections.addAll(testOpts, COMMON_OPTIONS);
95 Collections.addAll(testOpts, extraFlags);
96 testOpts.add(MixedGCProvoker.class.getName());
97 System.out.println(testOpts);
98 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false,
99 testOpts.toArray(new String[testOpts.size()]));
100 return new OutputAnalyzer(pb.start());
101 }
102 }
103
|
1 /*
2 * Copyright (c) 2015, 2018, 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 */
63 "-XX:G1MixedGCCountTarget=4",
64 "-XX:MaxGCPauseMillis=30000", // to have enough time
65 "-XX:G1HeapRegionSize=1m", "-XX:G1HeapWastePercent=0",
66 "-XX:G1MixedGCLiveThresholdPercent=100"};
67
68 public static final int ALLOCATION_SIZE = 20000;
69 public static final int ALLOCATION_COUNT = 15;
70
71 public static void main(String args[]) throws Exception {
72 // Test turns logging on by giving -Xlog:gc flag
73 test("-Xlog:gc");
74 // Test turns logging on by giving -Xlog:gc=debug flag
75 test("-Xlog:gc=debug");
76 }
77
78 private static void test(String vmFlag) throws Exception {
79 System.out.println(String.format("%s: running with %s flag", TestLogging.class.getSimpleName(), vmFlag));
80 OutputAnalyzer output = spawnMixedGCProvoker(vmFlag);
81 System.out.println(output.getStdout());
82 output.shouldHaveExitValue(0);
83 output.shouldContain("Pause Young (Mixed) (G1 Evacuation Pause)");
84 }
85
86 /**
87 * Method spawns MixedGCProvoker with addition flags set
88 *
89 * @parameter extraFlags -flags to be added to the common options set
90 */
91 private static OutputAnalyzer spawnMixedGCProvoker(String... extraFlags)
92 throws Exception {
93 List<String> testOpts = new ArrayList<>();
94 Collections.addAll(testOpts, COMMON_OPTIONS);
95 Collections.addAll(testOpts, extraFlags);
96 testOpts.add(MixedGCProvoker.class.getName());
97 System.out.println(testOpts);
98 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false,
99 testOpts.toArray(new String[testOpts.size()]));
100 return new OutputAnalyzer(pb.start());
101 }
102 }
103
|