test/tools/launcher/TestHelper.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -64,14 +64,14 @@
     static final File TEST_CLASSES_DIR;
     static final File TEST_SOURCES_DIR;
 
     static final String JAVAHOME = System.getProperty("java.home");
     static final String JAVA_BIN;
+    static final String JAVA_JRE_BIN;
     static final boolean isSDK = JAVAHOME.endsWith("jre");
     static final String javaCmd;
     static final String javawCmd;
-    static final String java64Cmd;
     static final String javacCmd;
     static final String jarCmd;
 
     static final JavaCompiler compiler;
 

@@ -86,11 +86,11 @@
             System.getProperty("sun.arch.data.model").equals("32");
     static final boolean isSolaris =
             System.getProperty("os.name", "unknown").startsWith("SunOS");
     static final boolean isLinux =
             System.getProperty("os.name", "unknown").startsWith("Linux");
-    static final boolean isDualMode = isSolaris;
+
     static final boolean isSparc = System.getProperty("os.arch").startsWith("sparc");
 
     // make a note of the golden default locale
     static final Locale DefaultLocale = Locale.getDefault();
 

@@ -122,13 +122,16 @@
         }
         if (!is64Bit && !is32Bit) {
             throw new RuntimeException("arch model is not 32 or 64 bit ?");
         }
         compiler = ToolProvider.getSystemJavaCompiler();
-        File binDir = (isSDK) ? new File((new File(JAVAHOME)).getParentFile(), "bin")
+        File binDir = (isSDK)
+                ? new File((new File(JAVAHOME)).getParentFile(), "bin")
             : new File(JAVAHOME, "bin");
         JAVA_BIN = binDir.getAbsolutePath();
+        JAVA_JRE_BIN = new File((new File(JAVAHOME)).getParentFile(),
+                        (isSDK) ? "jre/bin" : "bin").getAbsolutePath();
         File javaCmdFile = (isWindows)
                 ? new File(binDir, "java.exe")
                 : new File(binDir, "java");
         javaCmd = javaCmdFile.getAbsolutePath();
         if (!javaCmdFile.canExecute()) {

@@ -163,22 +166,11 @@
 
         if (!javacCmdFile.canExecute()) {
             throw new RuntimeException("java <" + javacCmd +
                     "> must exist and should be executable");
         }
-        if (isSolaris) {
-            File sparc64BinDir = new File(binDir,isSparc ? "sparcv9" : "amd64");
-            File java64CmdFile= new File(sparc64BinDir, "java");
-            if (java64CmdFile.exists() && java64CmdFile.canExecute()) {
-                java64Cmd = java64CmdFile.getAbsolutePath();
-            } else {
-                java64Cmd = null;
             }
-        } else {
-            java64Cmd = null;
-        }
-    }
     void run(String[] args) throws Exception {
         int passed = 0, failed = 0;
         final Pattern p = (args != null && args.length > 0)
                 ? Pattern.compile(args[0])
                 : null;

@@ -192,11 +184,17 @@
                     System.out.println(m.getName() + ": OK");
                     passed++;
                     System.out.printf("Passed: %d, Failed: %d, ExitValue: %d%n",
                                       passed, failed, testExitValue);
                 } catch (Throwable ex) {
-                    System.out.printf("Test %s failed: %s %n", m, ex.getCause());
+                    System.out.printf("Test %s failed: %s %n", m, ex);
+                    System.out.println("----begin detailed exceptions----");
+                    ex.printStackTrace(System.out);
+                    for (Throwable t : ex.getSuppressed()) {
+                        t.printStackTrace(System.out);
+                    }
+                    System.out.println("----end detailed exceptions----");
                     failed++;
                 }
             }
         }
         System.out.printf("Total: Passed: %d, Failed %d%n", passed, failed);

@@ -208,45 +206,19 @@
                     passed + ", failed = " + failed + " ??????????");
         }
     }
 
     /*
-     * is a dual mode available in the test jdk
-     */
-    static boolean dualModePresent() {
-        return isDualMode && java64Cmd != null;
-    }
-
-    /*
      * usually the jre/lib/arch-name is the same as os.arch, except for x86.
      */
     static String getJreArch() {
         String arch = System.getProperty("os.arch");
         return arch.equals("x86") ? "i386" : arch;
     }
-
-    /*
-     * get the complementary jre arch ie. if sparc then return sparcv9 and
-     * vice-versa.
-     */
-    static String getComplementaryJreArch() {
-        String arch = System.getProperty("os.arch");
-        if (arch != null) {
-            switch (arch) {
-                case "sparc":
-                    return "sparcv9";
-                case "sparcv9":
-                    return "sparc";
-                case "x86":
-                    return "amd64";
-                case "amd64":
-                    return "i386";
+    static String getArch() {
+        return System.getProperty("os.arch");
             }
-        }
-        return null;
-    }
-
     static File getClassFile(File javaFile) {
         String s = javaFile.getAbsolutePath().replace(JAVA_FILE_EXT, CLASS_FILE_EXT);
         return new File(s);
     }
 

@@ -621,10 +593,20 @@
                 }
             }
             appendError("string <" + stringToMatch + "> not found");
             return false;
         }
+
+        boolean notMatches(String stringToMatch) {
+            for (String x : testOutput) {
+                if (!x.matches(stringToMatch)) {
+                    return true;
+                }
+            }
+            appendError("string <" + stringToMatch + "> found");
+            return false;
+        }
     }
     /**
     * Indicates that the annotated method is a test method.
     */
     @Retention(RetentionPolicy.RUNTIME)