8171441: tools/launcher/VersionCheck.java doesn't report names of tools which failed checks
Reviewed-by: stsmirno, iignatyev, anazarov
This commit is contained in:
parent
367c06b7f8
commit
fff8c7e7da
@ -36,6 +36,8 @@ import java.util.Map;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class VersionCheck extends TestHelper {
|
public class VersionCheck extends TestHelper {
|
||||||
|
|
||||||
@ -148,31 +150,44 @@ public class VersionCheck extends TestHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* this tests if the tool can take a version string and returns
|
* Checks if the tools accept "-version" option (exit code is zero).
|
||||||
* a 0 exit code, it is not possible to validate the contents
|
* The output of the tools run with "-version" is not verified.
|
||||||
* of the -version output as they are inconsistent.
|
|
||||||
*/
|
*/
|
||||||
static boolean testToolVersion() {
|
static String testToolVersion() {
|
||||||
TestHelper.testExitValue = 0;
|
System.out.println("=== testToolVersion === ");
|
||||||
|
Set<String> failed = new HashSet<>();
|
||||||
for (File f : new File(JAVA_BIN).listFiles(new ToolFilter(BLACKLIST_VERSION))) {
|
for (File f : new File(JAVA_BIN).listFiles(new ToolFilter(BLACKLIST_VERSION))) {
|
||||||
String x = f.getAbsolutePath();
|
String x = f.getAbsolutePath();
|
||||||
System.out.println("Testing (-version): " + x);
|
|
||||||
TestResult tr = doExec(x, "-version");
|
TestResult tr = doExec(x, "-version");
|
||||||
tr.checkPositive();
|
System.out.println("Testing " + f.getName());
|
||||||
|
System.out.println("#> " + x + " -version");
|
||||||
|
tr.testOutput.forEach(System.out::println);
|
||||||
|
System.out.println("#> echo $?");
|
||||||
|
System.out.println(tr.exitValue);
|
||||||
|
if (!tr.isOK()) {
|
||||||
|
System.out.println("failed");
|
||||||
|
failed.add(f.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return TestHelper.testExitValue == 0;
|
if (failed.isEmpty()) {
|
||||||
|
System.out.println("testToolVersion passed");
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
System.out.println("testToolVersion failed");
|
||||||
|
return "testToolVersion: " + failed + "; ";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean compareJVersionStrings() {
|
static String testJVersionStrings() {
|
||||||
int failcount = 0;
|
System.out.println("=== testJVersionStrings === ");
|
||||||
|
Set<String> failed = new HashSet<>();
|
||||||
for (File f : new File(JAVA_BIN).listFiles(new ToolFilter(BLACKLIST_JOPTION))) {
|
for (File f : new File(JAVA_BIN).listFiles(new ToolFilter(BLACKLIST_JOPTION))) {
|
||||||
|
System.out.println("Testing " + f.getName());
|
||||||
String x = f.getAbsolutePath();
|
String x = f.getAbsolutePath();
|
||||||
System.out.println("Testing (-J-version): " + x);
|
String testStr = getVersion(x, "-J-version");
|
||||||
String testStr;
|
|
||||||
|
|
||||||
testStr = getVersion(x, "-J-version");
|
|
||||||
if (refVersion.compareTo(testStr) != 0) {
|
if (refVersion.compareTo(testStr) != 0) {
|
||||||
failcount++;
|
failed.add(f.getName());
|
||||||
System.out.println("Error: " + x +
|
System.out.println("Error: " + x +
|
||||||
" fails -J-version comparison");
|
" fails -J-version comparison");
|
||||||
System.out.println("Expected:");
|
System.out.println("Expected:");
|
||||||
@ -183,7 +198,7 @@ public class VersionCheck extends TestHelper {
|
|||||||
|
|
||||||
testStr = getVersion(x, "-J-fullversion");
|
testStr = getVersion(x, "-J-fullversion");
|
||||||
if (refFullVersion.compareTo(testStr) != 0) {
|
if (refFullVersion.compareTo(testStr) != 0) {
|
||||||
failcount++;
|
failed.add(f.getName());
|
||||||
System.out.println("Error: " + x +
|
System.out.println("Error: " + x +
|
||||||
" fails -J-fullversion comparison");
|
" fails -J-fullversion comparison");
|
||||||
System.out.println("Expected:");
|
System.out.println("Expected:");
|
||||||
@ -192,12 +207,17 @@ public class VersionCheck extends TestHelper {
|
|||||||
System.out.print(testStr);
|
System.out.print(testStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("Version Test: " + failcount);
|
if (failed.isEmpty()) {
|
||||||
return failcount == 0;
|
System.out.println("testJVersionStrings passed");
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
System.out.println("testJVersionStrings failed");
|
||||||
|
return "testJVersionStrings: " + failed + "; ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean compareInternalStrings() {
|
static String testInternalStrings() {
|
||||||
int failcount = 0;
|
System.out.println("=== testInternalStrings === ");
|
||||||
String bStr = refVersion.substring(refVersion.indexOf("build") +
|
String bStr = refVersion.substring(refVersion.indexOf("build") +
|
||||||
"build".length() + 1,
|
"build".length() + 1,
|
||||||
refVersion.lastIndexOf(")"));
|
refVersion.lastIndexOf(")"));
|
||||||
@ -208,20 +228,21 @@ public class VersionCheck extends TestHelper {
|
|||||||
envMap.put(TestHelper.JLDEBUG_KEY, "true");
|
envMap.put(TestHelper.JLDEBUG_KEY, "true");
|
||||||
TestHelper.TestResult tr = doExec(envMap, javaCmd, "-version");
|
TestHelper.TestResult tr = doExec(envMap, javaCmd, "-version");
|
||||||
List<String> alist = new ArrayList<>();
|
List<String> alist = new ArrayList<>();
|
||||||
alist.addAll(tr.testOutput);
|
tr.testOutput.stream().map(String::trim).forEach(alist::add);
|
||||||
for (String x : tr.testOutput) {
|
|
||||||
alist.add(x.trim());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!alist.contains(expectedFullVersion)) {
|
if (alist.contains(expectedFullVersion)) {
|
||||||
|
System.out.println("testInternalStrings passed");
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
System.out.println("Error: could not find " + expectedFullVersion);
|
System.out.println("Error: could not find " + expectedFullVersion);
|
||||||
failcount++;
|
tr.testOutput.forEach(System.out::println);
|
||||||
|
System.out.println("testInternalStrings failed");
|
||||||
|
return "testInternalStrings; ";
|
||||||
}
|
}
|
||||||
System.out.println("Internal Strings Test: " + failcount);
|
|
||||||
return failcount == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean testDebugVersion() {
|
static String testDebugVersion() {
|
||||||
|
System.out.println("=== testInternalStrings === ");
|
||||||
String jdkType = System.getProperty("jdk.debug", "release");
|
String jdkType = System.getProperty("jdk.debug", "release");
|
||||||
String versionLines = getAllVersionLines(javaCmd, "-version");
|
String versionLines = getAllVersionLines(javaCmd, "-version");
|
||||||
if ("release".equals(jdkType)) {
|
if ("release".equals(jdkType)) {
|
||||||
@ -229,18 +250,23 @@ public class VersionCheck extends TestHelper {
|
|||||||
} else {
|
} else {
|
||||||
jdkType = jdkType + " ";
|
jdkType = jdkType + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
String tofind = "(" + jdkType + "build";
|
String tofind = "(" + jdkType + "build";
|
||||||
|
|
||||||
int idx = versionLines.indexOf(tofind);
|
int idx = versionLines.indexOf(tofind);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
|
System.out.println("versionLines " + versionLines);
|
||||||
System.out.println("Did not find first instance of " + tofind);
|
System.out.println("Did not find first instance of " + tofind);
|
||||||
return false;
|
return "testDebugVersion; ";
|
||||||
}
|
}
|
||||||
idx = versionLines.indexOf(tofind, idx + 1);
|
idx = versionLines.indexOf(tofind, idx + 1);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
System.out.println("Did not find first instance of " + tofind);
|
System.out.println("versionLines " + versionLines);
|
||||||
return false;
|
System.out.println("Did not find second instance of " + tofind);
|
||||||
|
return "testDebugVersion; ";
|
||||||
}
|
}
|
||||||
return true;
|
System.out.println("testDebugVersion passed");
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
@ -251,13 +277,15 @@ public class VersionCheck extends TestHelper {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
init();
|
init();
|
||||||
if (compareJVersionStrings() &&
|
String errorMessage = "";
|
||||||
compareInternalStrings() &&
|
errorMessage += testJVersionStrings();
|
||||||
testToolVersion() &&
|
errorMessage += testInternalStrings();
|
||||||
testDebugVersion()) {
|
errorMessage += testToolVersion();
|
||||||
|
errorMessage += testDebugVersion();
|
||||||
|
if (errorMessage.isEmpty()) {
|
||||||
System.out.println("All Version string comparisons: PASS");
|
System.out.println("All Version string comparisons: PASS");
|
||||||
} else {
|
} else {
|
||||||
throw new AssertionError("Some tests failed");
|
throw new AssertionError("VersionCheck failed: " + errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user