Sat, 07 Nov 2020 10:30:02 +0800
Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f
poonam@8308 | 1 | /* |
poonam@8308 | 2 | * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
poonam@8308 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
poonam@8308 | 4 | * |
poonam@8308 | 5 | * This code is free software; you can redistribute it and/or modify it |
poonam@8308 | 6 | * under the terms of the GNU General Public License version 2 only, as |
poonam@8308 | 7 | * published by the Free Software Foundation. |
poonam@8308 | 8 | * |
poonam@8308 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
poonam@8308 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
poonam@8308 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
poonam@8308 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
poonam@8308 | 13 | * accompanied this code). |
poonam@8308 | 14 | * |
poonam@8308 | 15 | * You should have received a copy of the GNU General Public License version |
poonam@8308 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
poonam@8308 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
poonam@8308 | 18 | * |
poonam@8308 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
poonam@8308 | 20 | * or visit www.oracle.com if you need additional information or have any |
poonam@8308 | 21 | * questions. |
poonam@8308 | 22 | */ |
poonam@8308 | 23 | |
poonam@8308 | 24 | /* @test TestVerifySubSet.java |
poonam@8308 | 25 | * @key gc |
poonam@8308 | 26 | * @bug 8072725 |
poonam@8308 | 27 | * @summary Test VerifySubSet option |
poonam@8308 | 28 | * @library /testlibrary |
poonam@8308 | 29 | */ |
poonam@8308 | 30 | |
poonam@8308 | 31 | import com.oracle.java.testlibrary.OutputAnalyzer; |
poonam@8308 | 32 | import com.oracle.java.testlibrary.ProcessTools; |
poonam@8308 | 33 | import java.util.ArrayList; |
poonam@8308 | 34 | import java.util.Collections; |
poonam@8308 | 35 | |
poonam@8308 | 36 | class RunSystemGC { |
poonam@8308 | 37 | public static void main(String args[]) throws Exception { |
poonam@8308 | 38 | System.gc(); |
poonam@8308 | 39 | } |
poonam@8308 | 40 | } |
poonam@8308 | 41 | |
poonam@8308 | 42 | public class TestVerifySubSet { |
poonam@8308 | 43 | private static String[] getTestJavaOpts() { |
poonam@8308 | 44 | String testVmOptsStr = System.getProperty("test.java.opts"); |
poonam@8308 | 45 | if (!testVmOptsStr.isEmpty()) { |
poonam@8308 | 46 | return testVmOptsStr.split(" "); |
poonam@8308 | 47 | } else { |
poonam@8308 | 48 | return new String[] {}; |
poonam@8308 | 49 | } |
poonam@8308 | 50 | } |
poonam@8308 | 51 | |
poonam@8308 | 52 | private static OutputAnalyzer runTest(String subset) throws Exception { |
poonam@8308 | 53 | ArrayList<String> vmOpts = new ArrayList(); |
poonam@8308 | 54 | |
poonam@8308 | 55 | Collections.addAll(vmOpts, getTestJavaOpts()); |
poonam@8308 | 56 | Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions", |
poonam@8308 | 57 | "-XX:+VerifyBeforeGC", |
poonam@8308 | 58 | "-XX:+VerifyAfterGC", |
poonam@8308 | 59 | "-XX:VerifySubSet="+subset, |
poonam@8308 | 60 | RunSystemGC.class.getName()}); |
poonam@8308 | 61 | ProcessBuilder pb = |
poonam@8308 | 62 | ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()])); |
poonam@8308 | 63 | OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
poonam@8308 | 64 | |
poonam@8308 | 65 | System.out.println("Output:\n" + output.getOutput()); |
poonam@8308 | 66 | return output; |
poonam@8308 | 67 | } |
poonam@8308 | 68 | |
poonam@8308 | 69 | public static void main(String args[]) throws Exception { |
poonam@8308 | 70 | |
poonam@8308 | 71 | OutputAnalyzer output; |
poonam@8308 | 72 | |
poonam@8308 | 73 | output = runTest("heap, threads, codecache, metaspace"); |
poonam@8308 | 74 | output.shouldContain("Heap"); |
poonam@8308 | 75 | output.shouldContain("Threads"); |
poonam@8308 | 76 | output.shouldContain("CodeCache"); |
poonam@8308 | 77 | output.shouldContain("MetaspaceAux"); |
poonam@8308 | 78 | output.shouldNotContain("SymbolTable"); |
poonam@8308 | 79 | output.shouldNotContain("StringTable"); |
poonam@8308 | 80 | output.shouldNotContain("SystemDictionary"); |
poonam@8308 | 81 | output.shouldNotContain("CodeCache Oops"); |
poonam@8308 | 82 | output.shouldHaveExitValue(0); |
poonam@8308 | 83 | |
poonam@8308 | 84 | output = runTest("hello, threads, codecache, metaspace"); |
poonam@8308 | 85 | output.shouldContain("memory sub-system is unknown, please correct it"); |
poonam@8308 | 86 | output.shouldNotContain("Threads"); |
poonam@8308 | 87 | output.shouldNotContain("CodeCache"); |
poonam@8308 | 88 | output.shouldNotContain("MetaspaceAux"); |
poonam@8308 | 89 | output.shouldHaveExitValue(1); |
poonam@8308 | 90 | } |
poonam@8308 | 91 | } |