1 /* 2 * Copyright (c) 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 * 23 */ 24 package com.sun.hotspot.tools.compiler; 25 26 import java.util.Arrays; 27 import java.util.Collection; 28 import org.junit.Test; 29 import org.junit.BeforeClass; 30 import org.junit.experimental.categories.Category; 31 import junit.framework.Assert; 32 import org.junit.After; 33 import org.junit.Before; 34 import org.junit.Test; 35 import org.junit.runner.RunWith; 36 import org.junit.runners.Parameterized; 37 import org.junit.runners.Parameterized.Parameters; 38 import static org.junit.Assert.*; 39 40 @RunWith(value = Parameterized.class) 41 public class TestLogCompilation { 42 43 String logFile; 44 45 public TestLogCompilation(String logFile) { 46 this.logFile = logFile; 47 } 48 49 @Parameters 50 public static Collection data() { 51 Object[][] data = new Object[][]{ 52 // Simply running this jar with jdk-9 no args, 53 // no file (just prints the help) 54 {"./src/test/resources/hotspot_pid23756.log"}, 55 // LogCompilation output of running on above file 56 {"./src/test/resources/hotspot_pid25109.log"}, 57 {"./src/test/resources/no_tiered_short.log"}, 58 {"./src/test/resources/tiered_short.log"} 59 60 }; 61 return Arrays.asList(data); 62 } 63 64 @Test 65 public void testDashi() throws Exception { 66 String[] args = {"-i", 67 logFile 68 }; 69 70 LogCompilation.main(args); 71 } 72 73 @Test 74 public void testDashiDasht() throws Exception { 75 String[] args = {"-i", 76 "-t", 77 logFile 78 }; 79 80 LogCompilation.main(args); 81 } | 1 /* 2 * Copyright (c) 2018, 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. 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 * 23 */ 24 package com.sun.hotspot.tools.compiler; 25 26 import java.util.Arrays; 27 import java.util.Collection; 28 import org.junit.BeforeClass; 29 import org.junit.Test; 30 import org.junit.runner.RunWith; 31 import org.junit.runners.Parameterized; 32 import org.junit.runners.Parameterized.Parameters; 33 34 @RunWith(value = Parameterized.class) 35 public class TestLogCompilation { 36 37 String logFile; 38 39 static final String setupArgsTiered[] = { 40 "java", 41 "-XX:+UnlockDiagnosticVMOptions", 42 "-XX:+LogCompilation", 43 "-XX:LogFile=target/tiered_short.log", 44 "-version" 45 }; 46 47 static final String setupArgsNoTiered[] = { 48 "java", 49 "-XX:-TieredCompilation", 50 "-XX:+UnlockDiagnosticVMOptions", 51 "-XX:+LogCompilation", 52 "-XX:LogFile=target/no_tiered_short.log", 53 "-version" 54 }; 55 56 static final String allSetupArgs[][] = { 57 setupArgsTiered, 58 setupArgsNoTiered 59 }; 60 61 @Parameters 62 public static Collection data() { 63 Object[][] data = new Object[][]{ 64 // Take care these match whats created in the setup method 65 {"./target/tiered_short.log"}, 66 {"./target/no_tiered_short.log"} 67 }; 68 return Arrays.asList(data); 69 } 70 71 @BeforeClass 72 public static void setup() { 73 try { 74 for (String[] setupArgs : allSetupArgs) { 75 Process p = Runtime.getRuntime().exec(setupArgs); 76 p.waitFor(); 77 assert p.exitValue() == 0 : "setup failed on " + setupArgs; 78 } 79 } catch (Exception e) { 80 System.out.println(e + ": exec failed:" + setupArgsNoTiered[0]); 81 } 82 } 83 84 public TestLogCompilation(String logFile) { 85 this.logFile = logFile; 86 } 87 88 @Test 89 public void testDashi() throws Exception { 90 String[] args = {"-i", 91 logFile 92 }; 93 94 LogCompilation.main(args); 95 } 96 97 @Test 98 public void testDashiDasht() throws Exception { 99 String[] args = {"-i", 100 "-t", 101 logFile 102 }; 103 104 LogCompilation.main(args); 105 } |