jdk/test/tools/launcher/VersionCheck.java
changeset 34011 b1ce08dd7f17
parent 33987 24ecd3c83f33
child 34392 ae4033cd28f4
--- a/jdk/test/tools/launcher/VersionCheck.java	Sun Nov 01 09:49:05 2015 -0800
+++ b/jdk/test/tools/launcher/VersionCheck.java	Wed Nov 04 16:02:53 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 6545058 6611182 8016209
+ * @bug 6545058 6611182 8016209 8139986
  * @summary validate and test -version, -fullversion, and internal, as well as
  *          sanity checks if a tool can be launched.
  * @compile VersionCheck.java
@@ -115,12 +115,20 @@
     static String refVersion;
     static String refFullVersion;
 
+    static String getAllVersionLines(String... argv) {
+        return getVersion0(true, argv);
+    }
+
     static String getVersion(String... argv) {
+        return getVersion0(false, argv);
+    }
+
+    static String getVersion0(boolean allLines, String... argv) {
         TestHelper.TestResult tr = doExec(argv);
         StringBuilder out = new StringBuilder();
         // remove the HotSpot line
         for (String x : tr.testOutput) {
-            if (!x.matches(".*Client.*VM.*|.*Server.*VM.*")) {
+            if (allLines || !x.matches(".*Client.*VM.*|.*Server.*VM.*")) {
                 out = out.append(x + "\n");
             }
         }
@@ -202,6 +210,28 @@
         return failcount == 0;
     }
 
+    static boolean testDebugVersion() {
+        String jdkType = System.getProperty("jdk.debug", "release");
+        String versionLines = getAllVersionLines(javaCmd, "-version");
+        if ("release".equals(jdkType)) {
+            jdkType = "";
+        } else {
+            jdkType = jdkType + " ";
+        }
+        String tofind = "(" + jdkType + "build";
+        int idx = versionLines.indexOf(tofind);
+        if (idx < 0) {
+            System.out.println("Did not find first instance of " + tofind);
+            return false;
+        }
+        idx =  versionLines.indexOf(tofind, idx + 1);
+        if (idx < 0) {
+            System.out.println("Did not find first instance of " + tofind);
+            return false;
+        }
+        return true;
+    }
+
     // Initialize
     static void init() {
         refVersion = getVersion(javaCmd, "-version");
@@ -212,7 +242,8 @@
         init();
         if (compareJVersionStrings() &&
                 compareInternalStrings() &&
-                testToolVersion()) {
+                testToolVersion() &&
+                testDebugVersion()) {
             System.out.println("All Version string comparisons: PASS");
         } else {
             throw new AssertionError("Some tests failed");
@@ -220,7 +251,7 @@
     }
 
     static class ToolFilter implements FileFilter {
-        final Iterable<String> exclude ;
+        final Iterable<String> exclude;
         protected ToolFilter(String... exclude) {
             List<String> tlist = new ArrayList<>();
             this.exclude = tlist;