jdk/test/tools/launcher/VersionCheck.java
author ksrini
Fri, 26 Jun 2015 15:15:41 -0700
changeset 33987 24ecd3c83f33
parent 30789 9eca83469588
child 34011 b1ce08dd7f17
permissions -rw-r--r--
8129601: [launcher] test VersionCheck.java fails with new version string Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22613
4492f0cfdd38 8027175: Existing regression tests in tl/langtools and tl/jdk need to be updated for @bug keyword
sogoel
parents: 21399
diff changeset
     2
 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
22613
4492f0cfdd38 8027175: Existing regression tests in tl/langtools and tl/jdk need to be updated for @bug keyword
sogoel
parents: 21399
diff changeset
    26
 * @bug 6545058 6611182 8016209
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    27
 * @summary validate and test -version, -fullversion, and internal, as well as
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    28
 *          sanity checks if a tool can be launched.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * @compile VersionCheck.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * @run main VersionCheck
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.File;
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    34
import java.io.FileFilter;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.ArrayList;
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    37
import java.util.HashMap;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    40
public class VersionCheck extends TestHelper {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    42
    // tools that do not accept -J-option
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    43
    static final String[] BLACKLIST_JOPTION = {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    44
        "controlpanel",
15529
8112eb76bda3 8007135: tools/launcher/VersionCheck.java failing with new tool jabswitch
ksrini
parents: 14998
diff changeset
    45
        "jabswitch",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    46
        "java-rmi",
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    47
        "java-rmi.cgi",
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    48
        "java",
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 27190
diff changeset
    49
        "javacpl",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    50
        "javaw",
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    51
        "javaws",
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    52
        "jcontrol",
18152
804f7c54faa6 8016209: TEST_BUG: non-compliant jmc in the bin directory hangs testing
ksrini
parents: 16029
diff changeset
    53
        "jmc",
21327
9fc34e0b2a47 8026873: tools/launcher/VersionCheck.java fails in jprt because of jmc.ini
kizune
parents: 18152
diff changeset
    54
        "jmc.ini",
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 27190
diff changeset
    55
        "jp2launcher",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    56
        "jvisualvm",
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    57
        "packager",
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 27190
diff changeset
    58
        "ssvagent",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    59
        "unpack200",
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    60
        "wsimport"
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    61
    };
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    63
    // tools that do not accept -version
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    64
    static final String[] BLACKLIST_VERSION = {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        "appletviewer",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    66
        "controlpanel",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        "jar",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        "jarsigner",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    69
        "java-rmi",
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    70
        "java-rmi.cgi",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        "javadoc",
27942
b43cb0ec4975 8066841: Need to exclude javacpl in tools/launcher/VersionCheck.java
ksrini
parents: 27565
diff changeset
    72
        "javacpl",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    73
        "javaws",
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    74
        "jcmd",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        "jconsole",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    76
        "jcontrol",
14998
b9a99aac309e 8005634: tools/launcher/VersionCheck.java fails version check on jdeps
chegar
parents: 12301
diff changeset
    77
        "jdeps",
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 27190
diff changeset
    78
        "jimage",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        "jinfo",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        "jmap",
18152
804f7c54faa6 8016209: TEST_BUG: non-compliant jmc in the bin directory hangs testing
ksrini
parents: 16029
diff changeset
    81
        "jmc",
21327
9fc34e0b2a47 8026873: tools/launcher/VersionCheck.java fails in jprt because of jmc.ini
kizune
parents: 18152
diff changeset
    82
        "jmc.ini",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        "jps",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    84
        "jrunscript",
16029
4e88242da117 8008914: Add nashorn to the tl build
jjg
parents: 15529
diff changeset
    85
        "jjs",
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 27190
diff changeset
    86
        "jp2launcher",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    87
        "jsadebugd",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        "jstack",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        "jstat",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        "jstatd",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    91
        "jvisualvm",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        "keytool",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    93
        "kinit",
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    94
        "klist",
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    95
        "ktab",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        "orbd",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        "pack200",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
    98
        "packager",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        "policytool",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        "rmic",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        "rmid",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        "rmiregistry",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   103
        "schemagen", // returns error code 127
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        "serialver",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        "servertool",
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 27190
diff changeset
   106
        "ssvagent",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        "tnameserv",
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   108
        "unpack200",
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        "wsgen",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        "wsimport",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        "xjc"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    // expected reference strings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    static String refVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    static String refFullVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    static String getVersion(String... argv) {
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   119
        TestHelper.TestResult tr = doExec(argv);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        StringBuilder out = new StringBuilder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        // remove the HotSpot line
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   122
        for (String x : tr.testOutput) {
10053
43930b0d0564 7043125: TEST: tools/launcher/VersionCheck.java fails just against openjdk7 (b141 & b138-nightly) promoted
ksrini
parents: 5506
diff changeset
   123
            if (!x.matches(".*Client.*VM.*|.*Server.*VM.*")) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                out = out.append(x + "\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        return out.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   130
    /*
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   131
     * this tests if the tool can take a version string and returns
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   132
     * a 0 exit code, it is not possible to validate the contents
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   133
     * of the -version output as they are inconsistent.
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   134
     */
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   135
    static boolean testToolVersion() {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   136
        TestResult tr = null;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   137
        TestHelper.testExitValue = 0;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   138
        for (File f : new File(JAVA_BIN).listFiles(new ToolFilter(BLACKLIST_VERSION))) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   139
            String x = f.getAbsolutePath();
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   140
            System.out.println("Testing (-version): " + x);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   141
            tr = doExec(x, "-version");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   142
            tr.checkPositive();
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   143
        }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   144
        return TestHelper.testExitValue == 0;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   145
    }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   146
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   147
    static boolean compareJVersionStrings() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        int failcount = 0;
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   149
        for (File f : new File(JAVA_BIN).listFiles(new ToolFilter(BLACKLIST_JOPTION))) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   150
            String x = f.getAbsolutePath();
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   151
            System.out.println("Testing (-J-version): " + x);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            String testStr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            testStr = getVersion(x, "-J-version");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            if (refVersion.compareTo(testStr) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                failcount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                System.out.println("Error: " + x +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                                   " fails -J-version comparison");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                System.out.println("Expected:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                System.out.print(refVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                System.out.println("Actual:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                System.out.print(testStr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            testStr = getVersion(x, "-J-fullversion");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            if (refFullVersion.compareTo(testStr) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                failcount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                System.out.println("Error: " + x +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                                   " fails -J-fullversion comparison");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                System.out.println("Expected:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                System.out.print(refFullVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                System.out.println("Actual:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                System.out.print(testStr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        System.out.println("Version Test: " + failcount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        return failcount == 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    static boolean compareInternalStrings() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        int failcount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        String bStr = refVersion.substring(refVersion.lastIndexOf("build") +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                                           "build".length() + 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                                           refVersion.lastIndexOf(")"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        String expectedFullVersion = "fullversion:" + bStr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   188
        Map<String, String> envMap = new HashMap<>();
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   189
        envMap.put(TestHelper.JLDEBUG_KEY, "true");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   190
        TestHelper.TestResult tr = doExec(envMap, javaCmd, "-version");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   191
        List<String> alist = new ArrayList<>();
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   192
        alist.addAll(tr.testOutput);
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   193
        for (String x : tr.testOutput) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   194
            alist.add(x.trim());
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   195
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        if (!alist.contains(expectedFullVersion)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            System.out.println("Error: could not find " + expectedFullVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            failcount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        System.out.println("Internal Strings Test: " + failcount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        return failcount == 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    // Initialize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    static void init() {
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   207
        refVersion = getVersion(javaCmd, "-version");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   208
        refFullVersion = getVersion(javaCmd, "-fullversion");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    public static void main(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        init();
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   213
        if (compareJVersionStrings() &&
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   214
                compareInternalStrings() &&
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   215
                testToolVersion()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            System.out.println("All Version string comparisons: PASS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            throw new AssertionError("Some tests failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   221
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   222
    static class ToolFilter implements FileFilter {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   223
        final Iterable<String> exclude ;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   224
        protected ToolFilter(String... exclude) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   225
            List<String> tlist = new ArrayList<>();
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   226
            this.exclude = tlist;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   227
            for (String x : exclude) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   228
                String str = x + ((isWindows) ? EXE_FILE_EXT : "");
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   229
                tlist.add(str.toLowerCase());
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   230
            }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   231
        }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   232
        @Override
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   233
        public boolean accept(File pathname) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   234
            if (!pathname.isFile() || !pathname.canExecute()) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   235
                return false;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   236
            }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   237
            String name = pathname.getName().toLowerCase();
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   238
            if (isWindows && !name.endsWith(EXE_FILE_EXT)) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   239
                return false;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   240
            }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   241
            for (String x : exclude) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   242
                if (name.endsWith(x)) {
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   243
                    return false;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   244
                }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   245
            }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   246
            return true;
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   247
        }
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 10053
diff changeset
   248
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
}