jdk/test/tools/launcher/ToolsOpts.java
author prr
Tue, 01 Jul 2014 10:20:56 -0700
changeset 25211 2476da7d73bf
parent 16091 4eb1062acb5b
child 36511 9d0388c6b336
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
     1
/*
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
     4
 *
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
     7
 * published by the Free Software Foundation.
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
     8
 *
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    13
 * accompanied this code).
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    14
 *
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    18
 *
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    21
 * questions.
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    22
 */
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    23
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    24
/*
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    25
 * @test
16091
4eb1062acb5b 8002091: tools/launcher/ToolsOpts.java test started to fail since 7u11 b01 on Windows
ksrini
parents: 13411
diff changeset
    26
 * @bug 8002091
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    27
 * @summary Test options patterns for javac,javah,javap and javadoc using
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    28
 * javac as a test launcher. Create a dummy javac and intercept options to check
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    29
 * reception of options as passed through the launcher without having to launch
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    30
 * javac. Only -J and -cp ./* options should be consumed by the launcher.
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    31
 * @run main ToolsOpts
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    32
 * @author ssides
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    33
 */
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    34
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    35
import java.io.File;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    36
import java.io.IOException;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    37
import java.util.ArrayList;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    38
import java.util.List;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    39
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    40
public class ToolsOpts extends TestHelper {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    41
    static final String JBCP_PREPEND = "-J-Xbootclasspath/p:";
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    42
    private static File testJar = null;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    43
    static String[][] optionPatterns = {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    44
        {"-J-Xmx128m"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    45
        {"-J-version"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    46
        {"-J-XshowSettings:vm"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    47
        {"-J-Xdiag"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    48
        {"-J-showversion"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    49
        {"-J-version", "-option"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    50
        {"-option"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    51
        {"-option:sub"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    52
        {"-option:sub-"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    53
        {"-option:sub1,sub2"}, // -option:list
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    54
        {"-option:{sub1,sub2,sub3}"}, // -option:{list}
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    55
        {"-option:{{sub1,sub2,sub3}}"},// -option:{{list}}
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    56
        {"-option/c:/export/date/tmp"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    57
        {"-option=value"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    58
        {"-Dpk1.pk2.pk3"}, // dot in option
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    59
        {"-Dpk1.pk2=value"}, // dot in option followed by =value
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    60
        {"@<filename>"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    61
        {"-option", "http://site.com", "http://site.org"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    62
        {"-option", "name", "p1:p2.."},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    63
        {"-All these non-options show launchers pass options as is to tool."},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    64
        {"-option"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    65
        {"-option:sub"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    66
        {"-option:sub-"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    67
        {"-option", "<path>"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    68
        {"-option", "<file>"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    69
        {"-option", "<dir>"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    70
        {"-option", "http://a/b/c/g;x?y#s"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    71
        {"-option", "<html code>"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    72
        {"-option", "name1:name2"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    73
        {"-option", "3"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    74
        {"option1", "-J-version", "option2"},
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    75
        {"option1", "-J-version", "-J-XshowSettings:vm", "option2"},};
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    76
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    77
    static void init() throws IOException {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    78
        if (testJar != null) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    79
            return;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    80
        }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    81
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    82
        // A tool which simulates com.sun.tools.javac.Main argument processing,
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    83
        // intercepts options passed via the javac launcher.
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    84
        final String mainJava = "Main" + JAVA_FILE_EXT;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    85
        testJar = new File("test" + JAR_FILE_EXT);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    86
        List<String> contents = new ArrayList<>();
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    87
        contents.add("package com.sun.tools.javac;");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    88
        contents.add("public class Main {");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    89
        contents.add("    public static void main(String... args) {\n");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    90
        contents.add("       for (String x : args) {\n");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    91
        contents.add("           if(x.compareTo(\" \")!=0)\n");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    92
        contents.add("               System.out.println(x);\n");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    93
        contents.add("       }\n");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    94
        contents.add("    }\n");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    95
        contents.add("}\n");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    96
        createFile(new File(mainJava), contents);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    97
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    98
        // compile and jar Main.java into test.jar
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
    99
        compile("-d", ".", mainJava);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   100
            createJar("cvf", testJar.getAbsolutePath(), "com");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   101
        }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   102
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   103
    static void pass(String msg) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   104
        System.out.println("pass: " + msg);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   105
    }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   106
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   107
    static void errout(String msg) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   108
        System.err.println(msg);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   109
    }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   110
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   111
    // Return position of -J option or -1 is does not contain a -J option.
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   112
    static int indexOfJoption(String[] opts) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   113
        for (int i = 0; i < opts.length; i++) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   114
            if (opts[i].startsWith("-J")) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   115
                return i;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   116
            }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   117
        }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   118
        return -1;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   119
    }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   120
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   121
    /*
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   122
     * Check that J options a) are not passed to tool, and b) do the right thing,
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   123
     * that is, they should be passed to java launcher and work as expected.
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   124
     */
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   125
    static void checkJoptionOutput(TestResult tr, String[] opts) throws IOException {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   126
        // Check -J-version options are not passed but do what they should.
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   127
        String jopts = "";
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   128
        for (String pat : opts) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   129
            jopts = jopts.concat(pat + " ");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   130
            if (tr.contains("-J")) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   131
                throw new RuntimeException(
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   132
                        "failed: output should not contain option " + pat);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   133
            }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   134
            if (pat.compareTo("-J-version") == 0 ||
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   135
                    pat.compareTo("-J-showversion") == 0) {
12303
498f8b38423b 7158090: (launcher) newly added ToolsOpts.java fails on openjdk builds
ksrini
parents: 12301
diff changeset
   136
                if (!tr.contains("java version") &&
498f8b38423b 7158090: (launcher) newly added ToolsOpts.java fails on openjdk builds
ksrini
parents: 12301
diff changeset
   137
                        !tr.contains("openjdk version")) {
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   138
                    throw new RuntimeException("failed: " + pat +
12303
498f8b38423b 7158090: (launcher) newly added ToolsOpts.java fails on openjdk builds
ksrini
parents: 12301
diff changeset
   139
                            " should display a version string.");
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   140
                }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   141
            } else if (pat.compareTo("-J-XshowSettings:VM") == 0) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   142
                if (!tr.contains("VM settings")) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   143
                    throw new RuntimeException("failed: " + pat +
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   144
                            " should have display VM settings.");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   145
                }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   146
            }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   147
        }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   148
        pass("Joption check: " + jopts);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   149
    }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   150
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   151
    /*
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   152
     * Feed each option pattern in optionPatterns array to javac launcher with
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   153
     * checking program preempting javac. Check that option received by 'dummy'
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   154
     * javac is the one passed on the command line.
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   155
     */
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   156
    static void runTestOptions() throws IOException {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   157
        init();
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   158
        TestResult tr = null;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   159
        String sTestJar = testJar.getAbsolutePath();
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   160
        int jpos = -1;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   161
        for (String arg[] : optionPatterns) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   162
            jpos = indexOfJoption(arg);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   163
            //Build a cmd string for output in results reporting.
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12303
diff changeset
   164
            String cmdString = javacCmd + " " + JBCP_PREPEND + sTestJar;
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   165
            for (String opt : arg) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   166
                cmdString = cmdString.concat(" " + opt);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   167
            }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   168
            switch (arg.length) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   169
                case 1:
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   170
                    tr = doExec(javacCmd, JBCP_PREPEND + sTestJar,
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   171
                            arg[0]);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   172
                    break;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   173
                case 2:
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   174
                    tr = doExec(javacCmd, JBCP_PREPEND + sTestJar,
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   175
                            arg[0], arg[1]);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   176
                    break;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   177
                case 3:
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   178
                    tr = doExec(javacCmd, JBCP_PREPEND + sTestJar,
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   179
                            arg[0], arg[1], arg[2]);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   180
                    break;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   181
                case 4:
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   182
                    tr = doExec(javacCmd, JBCP_PREPEND + sTestJar,
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   183
                            arg[0], arg[1], arg[2], arg[3]);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   184
                    break;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   185
                default:
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   186
                    tr = null;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   187
                    break;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   188
            }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   189
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   190
            String[] output = tr.testOutput.toArray(new String[tr.testOutput.size()]);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   191
            //-Joptions should not be passed to tool
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   192
            if (jpos > -1) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   193
                checkJoptionOutput(tr, arg);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   194
                if (tr.contains(arg[jpos])) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   195
                    throw new RuntimeException(
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   196
                            "failed! Should not have passed -J option to tool.\n"
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   197
                            + "CMD: " + cmdString);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   198
                }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   199
            } else {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   200
                //check that each non -J option was passed to tool.
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   201
                for (int i = 0; i < arg.length; i++) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   202
                    if (output[i].compareTo(arg[i]) != 0) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   203
                        throw new RuntimeException(
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   204
                                "failed! CMD: " + cmdString + "\n   case:" +
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   205
                                output[i] + " != " + arg[i]);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   206
                    } else {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   207
                        pass("check " + output[i] + " == " + arg[i]);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   208
                    }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   209
                }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   210
            }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   211
            pass(cmdString);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   212
        }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   213
    }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   214
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   215
    public static void main(String... args) throws IOException {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   216
        runTestOptions();
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   217
    }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents:
diff changeset
   218
}