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     }
  82 
  83     @Test
  84     public void testDefault() throws Exception {
  85         String[] args = {
  86             logFile
  87         };
  88 
  89         LogCompilation.main(args);
  90     }
  91 
  92     @Test
  93     public void testDashS() throws Exception {
  94         String[] args = {"-S",
  95             logFile
  96         };
  97 
  98         LogCompilation.main(args);
  99     }
 100 
 101     @Test
 102     public void testDashU() throws Exception {
 103         String[] args = {"-U",
 104             logFile
 105         };
 106 
 107         LogCompilation.main(args);
 108     }
 109 
 110     @Test
 111     public void testDashe() throws Exception {
 112         String[] args = {"-e",
 113             logFile
 114         };
 115 
 116         LogCompilation.main(args);
 117     }
 118 
 119     @Test
 120     public void testDashn() throws Exception {
 121         String[] args = {"-n",
 122             logFile
 123         };
 124 
 125         LogCompilation.main(args);
 126     }
 127 }