src/utils/LogCompilation/src/test/java/com/sun/hotspot/tools/compiler/TestLogCompilation.java
author ecaspole
Wed, 31 Jan 2018 17:45:48 -0500
changeset 48828 5fcc602d36b6
child 52883 094d91e25943
permissions -rw-r--r--
8195069: LogCompilation - add basic unit tests Summary: Framework and simple junits with static input Reviewed-by: kvn, thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48828
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
     1
/*
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
     4
 *
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
     8
 *
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    13
 * accompanied this code).
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    14
 *
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    18
 *
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    21
 * questions.
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    22
 *
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    23
 */
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    24
package com.sun.hotspot.tools.compiler;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    25
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    26
import java.util.Arrays;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    27
import java.util.Collection;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    28
import org.junit.Test;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    29
import org.junit.BeforeClass;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    30
import org.junit.experimental.categories.Category;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    31
import junit.framework.Assert;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    32
import org.junit.After;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    33
import org.junit.Before;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    34
import org.junit.Test;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    35
import org.junit.runner.RunWith;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    36
import org.junit.runners.Parameterized;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    37
import org.junit.runners.Parameterized.Parameters;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    38
import static org.junit.Assert.*;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    39
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    40
@RunWith(value = Parameterized.class)
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    41
public class TestLogCompilation {
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    42
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    43
    String logFile;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    44
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    45
    public TestLogCompilation(String logFile) {
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    46
        this.logFile = logFile;
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    47
    }
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    48
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    49
    @Parameters
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    50
    public static Collection data() {
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    51
        Object[][] data = new Object[][]{
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    52
            // Simply running this jar with jdk-9 no args,
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    53
            // no file (just prints the help)
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    54
            {"./src/test/resources/hotspot_pid23756.log"},
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    55
            // LogCompilation output of running on above file
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    56
            {"./src/test/resources/hotspot_pid25109.log"}
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    57
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    58
        };
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    59
        return Arrays.asList(data);
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    60
    }
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    61
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    62
    @Test
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    63
    public void testDashi() throws Exception {
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    64
        String[] args = {"-i",
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    65
            logFile
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    66
        };
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    67
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    68
        LogCompilation.main(args);
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    69
    }
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    70
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    71
    @Test
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    72
    public void testDashiDasht() throws Exception {
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    73
        String[] args = {"-i",
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    74
            "-t",
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    75
            logFile
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    76
        };
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    77
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    78
        LogCompilation.main(args);
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    79
    }
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    80
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    81
    @Test
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    82
    public void testDefault() throws Exception {
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    83
        String[] args = {
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    84
            logFile
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    85
        };
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    86
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    87
        LogCompilation.main(args);
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    88
    }
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    89
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    90
    @Test
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    91
    public void testDashS() throws Exception {
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    92
        String[] args = {"-S",
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    93
            logFile
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    94
        };
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    95
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    96
        LogCompilation.main(args);
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    97
    }
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    98
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
    99
    @Test
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   100
    public void testDashU() throws Exception {
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   101
        String[] args = {"-U",
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   102
            logFile
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   103
        };
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   104
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   105
        LogCompilation.main(args);
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   106
    }
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   107
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   108
    @Test
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   109
    public void testDashe() throws Exception {
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   110
        String[] args = {"-e",
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   111
            logFile
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   112
        };
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   113
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   114
        LogCompilation.main(args);
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   115
    }
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   116
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   117
    @Test
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   118
    public void testDashn() throws Exception {
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   119
        String[] args = {"-n",
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   120
            logFile
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   121
        };
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   122
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   123
        LogCompilation.main(args);
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   124
    }
5fcc602d36b6 8195069: LogCompilation - add basic unit tests
ecaspole
parents:
diff changeset
   125
}