annotate test/gc/6941923/Test6941923.java @ 14909:4ca6dc0799b6

Backout jdk9 merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 01 Apr 2014 13:57:07 +0200
parents de6a9e811145
children 89152779163c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9074
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
1 /*
14909
4ca6dc0799b6 Backout jdk9 merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14223
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
9074
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
4 *
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
7 * published by the Free Software Foundation.
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
8 *
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
13 * accompanied this code).
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
14 *
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
18 *
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
21 * questions.
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
22 */
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
23
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
24 /*
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
25 * @test Test6941923.java
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
26 * @bug 6941923
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
27 * @summary test flags for gc log rotation
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
28 * @library /testlibrary
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
29 * @run main/othervm/timeout=600 Test6941923
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
30 *
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
31 */
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
32 import com.oracle.java.testlibrary.*;
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
33 import java.io.File;
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
34 import java.io.FilenameFilter;
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
35 import java.util.ArrayList;
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
36 import java.util.Arrays;
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
37
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
38 class GCLoggingGenerator {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
39
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
40 public static void main(String[] args) throws Exception {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
41
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
42 long sizeOfLog = Long.parseLong(args[0]);
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
43 long lines = sizeOfLog / 80;
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
44 // full.GC generates ad least 1-line which is not shorter then 80 chars
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
45 // for some GC 2 shorter lines are generated
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
46 for (long i = 0; i < lines; i++) {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
47 System.gc();
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
48 }
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
49 }
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
50 }
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
51
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
52 public class Test6941923 {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
53
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
54 static final File currentDirectory = new File(".");
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
55 static final String logFileName = "test.log";
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
56 static final int logFileSizeK = 16;
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
57 static FilenameFilter logFilter = new FilenameFilter() {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
58 @Override
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
59 public boolean accept(File dir, String name) {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
60 return name.startsWith(logFileName);
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
61 }
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
62 };
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
63
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
64 public static void cleanLogs() {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
65 for (File log : currentDirectory.listFiles(logFilter)) {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
66 if (!log.delete()) {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
67 throw new Error("Unable to delete " + log.getAbsolutePath());
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
68 }
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
69 }
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
70 }
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
71
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
72 public static void runTest(int numberOfFiles) throws Exception {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
73
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
74 ArrayList<String> args = new ArrayList();
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
75 String[] logOpts = new String[]{
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
76 "-cp", System.getProperty("java.class.path"),
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
77 "-Xloggc:" + logFileName,
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
78 "-XX:-DisableExplicitGC", // to sure that System.gc() works
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
79 "-XX:+PrintGC", "-XX:+PrintGCDetails", "-XX:+UseGCLogFileRotation",
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
80 "-XX:NumberOfGCLogFiles=" + numberOfFiles,
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
81 "-XX:GCLogFileSize=" + logFileSizeK + "K", "-Xmx128M"};
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
82 // System.getProperty("test.java.opts") is '' if no options is set
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
83 // need to skip such empty
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
84 String[] externalVMopts = System.getProperty("test.java.opts").length() == 0
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
85 ? new String[0]
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
86 : System.getProperty("test.java.opts").split(" ");
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
87 args.addAll(Arrays.asList(externalVMopts));
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
88 args.addAll(Arrays.asList(logOpts));
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
89 args.add(GCLoggingGenerator.class.getName());
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
90 args.add(String.valueOf(numberOfFiles * logFileSizeK * 1024));
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
91 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(new String[0]));
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
92 pb.redirectErrorStream(true);
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
93 pb.redirectOutput(new File(GCLoggingGenerator.class.getName() + ".log"));
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
94 Process process = pb.start();
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
95 int result = process.waitFor();
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
96 if (result != 0) {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
97 throw new Error("Unexpected exit code = " + result);
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
98 }
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
99 File[] logs = currentDirectory.listFiles(logFilter);
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
100 int smallFilesNumber = 0;
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
101 for (File log : logs) {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
102 if (log.length() < logFileSizeK * 1024) {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
103 smallFilesNumber++;
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
104 }
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
105 }
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
106 if (logs.length != numberOfFiles) {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
107 throw new Error("There are only " + logs.length + " logs instead " + numberOfFiles);
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
108 }
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
109 if (smallFilesNumber > 1) {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
110 throw new Error("There should maximum one log with size < " + logFileSizeK + "K");
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
111 }
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
112 }
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
113
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
114 public static void main(String[] args) throws Exception {
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
115 cleanLogs();
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
116 runTest(1);
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
117 cleanLogs();
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
118 runTest(3);
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
119 cleanLogs();
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
120 }
63f57a8c5283 8009808: TEST-BUG : test case is using bash style tests. Default shell for jtreg is bourne. thus failure
mgerdin
parents:
diff changeset
121 }