Merge
authorvinnie
Tue, 19 Nov 2013 15:42:59 +0000
changeset 21815 9613e4a03175
parent 21814 b2e66390b8b2 (current diff)
parent 21813 f7e97f5bb5a2 (diff)
child 21816 1fa16478977c
Merge
--- a/jdk/test/Makefile	Tue Nov 19 15:39:58 2013 +0000
+++ b/jdk/test/Makefile	Tue Nov 19 15:42:59 2013 +0000
@@ -250,7 +250,7 @@
 
 # ------------------------------------------------------------------
 
-jdk_%:
+jdk_% core_% svc_%:
 	$(ECHO) "Running tests: $@"
 	for each in $@; do \
 	        $(MAKE) -j 1 TEST_SELECTION=":$$each" UNIQUE_DIR=$$each jtreg_tests; \
--- a/jdk/test/ProblemList.txt	Tue Nov 19 15:39:58 2013 +0000
+++ b/jdk/test/ProblemList.txt	Tue Nov 19 15:42:59 2013 +0000
@@ -176,9 +176,6 @@
 # Filed 7036666
 com/sun/net/httpserver/Test9a.java                              generic-all
 
-# 7102670
-java/net/InetAddress/CheckJNI.java                              linux-all
-
 # failing on vista 32/64 on nightly
 # 7102702
 java/net/PortUnreachableException/OneExceptionOnly.java         windows-all
@@ -293,6 +290,9 @@
 # 7132203
 sun/jvmstat/monitor/MonitoredVm/CR6672135.java                  generic-all
 
+# 8028474
+sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh      generic-all
+
 # Tests take too long, on sparcs see 7143279
 tools/pack200/CommandLineTests.java                             solaris-all, macosx-all
 tools/pack200/Pack200Test.java                                  solaris-all, macosx-all
--- a/jdk/test/java/lang/ProcessBuilder/Basic.java	Tue Nov 19 15:39:58 2013 +0000
+++ b/jdk/test/java/lang/ProcessBuilder/Basic.java	Tue Nov 19 15:42:59 2013 +0000
@@ -2016,6 +2016,7 @@
                 && new File("/bin/bash").exists()
                 && new File("/bin/sleep").exists()) {
                 final String[] cmd = { "/bin/bash", "-c", "(/bin/sleep 6666)" };
+                final String[] cmdkill = { "/bin/bash", "-c", "(/usr/bin/pkill -f \"sleep 6666\")" };
                 final ProcessBuilder pb = new ProcessBuilder(cmd);
                 final Process p = pb.start();
                 final InputStream stdout = p.getInputStream();
@@ -2043,6 +2044,7 @@
                 stdout.close();
                 stderr.close();
                 stdin.close();
+                new ProcessBuilder(cmdkill).start();
                 //----------------------------------------------------------
                 // There remain unsolved issues with asynchronous close.
                 // Here's a highly non-portable experiment to demonstrate:
--- a/jdk/test/java/rmi/testlibrary/TestLibrary.java	Tue Nov 19 15:39:58 2013 +0000
+++ b/jdk/test/java/rmi/testlibrary/TestLibrary.java	Tue Nov 19 15:42:59 2013 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -127,6 +127,33 @@
         bomb(null, e);
     }
 
+    /**
+     * Helper method to determine if registry has started
+     *
+     * @param port The port number to check
+     * @param msTimeout The amount of milliseconds to spend checking
+     */
+
+    public static boolean checkIfRegistryRunning(int port, int msTimeout) {
+        long stopTime = System.currentTimeMillis() + msTimeout;
+        do {
+            try {
+                Registry r = LocateRegistry.getRegistry(port);
+                String[] s = r.list();
+                // no exception. We're now happy that registry is running
+                return true;
+            } catch (RemoteException e) {
+                // problem - not ready ? Try again
+                try {
+                    Thread.sleep(500);
+                } catch (InterruptedException ie) {
+                    // not expected
+                }
+            }
+        } while (stopTime > System.currentTimeMillis());
+        return false;
+    }
+
     public static String getProperty(String property, String defaultVal) {
         final String prop = property;
         final String def = defaultVal;
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/FileUtils.java	Tue Nov 19 15:39:58 2013 +0000
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/FileUtils.java	Tue Nov 19 15:42:59 2013 +0000
@@ -68,6 +68,31 @@
         }
     }
 
+    /**
+     * Deletes a file, retrying if necessary.
+     * No exception thrown if file doesn't exist.
+     *
+     * @param path  the file to delete
+     *
+     * @throws NoSuchFileException
+     *         if the file does not exist (optional specific exception)
+     * @throws DirectoryNotEmptyException
+     *         if the file is a directory and could not otherwise be deleted
+     *         because the directory is not empty (optional specific exception)
+     * @throws IOException
+     *         if an I/O error occurs
+     */
+    public static void deleteFileIfExistsWithRetry(Path path)
+        throws IOException
+    {
+        try {
+            if(Files.exists(path))
+                deleteFileWithRetry0(path);
+        } catch (InterruptedException x) {
+            throw new IOException("Interrupted while deleting.", x);
+        }
+    }
+
     private static void deleteFileWithRetry0(Path path)
         throws IOException, InterruptedException
     {
--- a/jdk/test/tools/jar/JarEntryTime.java	Tue Nov 19 15:39:58 2013 +0000
+++ b/jdk/test/tools/jar/JarEntryTime.java	Tue Nov 19 15:42:59 2013 +0000
@@ -29,10 +29,15 @@
 
 import java.io.File;
 import java.io.PrintWriter;
-import java.util.Date;
+import java.nio.file.attribute.FileTime;
 import sun.tools.jar.Main;
 
 public class JarEntryTime {
+
+    // ZipEntry's mod date has 2 seconds precision: give extra time to
+    // allow for e.g. rounding/truncation and networked/samba drives.
+    static final long PRECISION = 10000L;
+
     static boolean cleanup(File dir) throws Throwable {
         boolean rc = true;
         File[] x = dir.listFiles();
@@ -88,9 +93,9 @@
         check(dirOuter.mkdir());
         check(dirInner.mkdir());
         File fileInner = new File(dirInner, "foo.txt");
-        PrintWriter pw = new PrintWriter(fileInner);
-        pw.println("hello, world");
-        pw.close();
+        try (PrintWriter pw = new PrintWriter(fileInner)) {
+            pw.println("hello, world");
+        }
 
         // Get the "now" from the "last-modified-time" of the last file we
         // just created, instead of the "System.currentTimeMillis()", to
@@ -98,13 +103,10 @@
         final long now = fileInner.lastModified();
         final long earlier = now - (60L * 60L * 6L * 1000L);
         final long yesterday = now - (60L * 60L * 24L * 1000L);
-        // ZipEntry's mod date has 2 seconds precision: give extra time to
-        // allow for e.g. rounding/truncation and networked/samba drives.
-        final long PRECISION = 10000L;
 
-        dirOuter.setLastModified(now);
-        dirInner.setLastModified(yesterday);
-        fileInner.setLastModified(earlier);
+        check(dirOuter.setLastModified(now));
+        check(dirInner.setLastModified(yesterday));
+        check(fileInner.setLastModified(earlier));
 
         // Make a jar file from that directory structure
         Main jartool = new Main(System.out, System.err, "jar");
@@ -122,9 +124,9 @@
         check(dirOuter.exists());
         check(dirInner.exists());
         check(fileInner.exists());
-        check(Math.abs(dirOuter.lastModified() - now) <= PRECISION);
-        check(Math.abs(dirInner.lastModified() - yesterday) <= PRECISION);
-        check(Math.abs(fileInner.lastModified() - earlier) <= PRECISION);
+        checkFileTime(dirOuter.lastModified(), now);
+        checkFileTime(dirInner.lastModified(), yesterday);
+        checkFileTime(fileInner.lastModified(), earlier);
 
         check(cleanup(dirInner));
         check(cleanup(dirOuter));
@@ -135,9 +137,9 @@
         check(dirOuter.exists());
         check(dirInner.exists());
         check(fileInner.exists());
-        check(Math.abs(dirOuter.lastModified() - now) <= PRECISION);
-        check(Math.abs(dirInner.lastModified() - now) <= PRECISION);
-        check(Math.abs(fileInner.lastModified() - now) <= PRECISION);
+        checkFileTime(dirOuter.lastModified(), now);
+        checkFileTime(dirInner.lastModified(), now);
+        checkFileTime(fileInner.lastModified(), now);
 
         check(cleanup(dirInner));
         check(cleanup(dirOuter));
@@ -145,6 +147,14 @@
         check(jarFile.delete());
     }
 
+    static void checkFileTime(long now, long original) {
+        if (Math.abs(now - original) > PRECISION) {
+            System.out.format("Extracted to %s, expected to be close to %s%n",
+                FileTime.fromMillis(now), FileTime.fromMillis(original));
+            fail();
+        }
+    }
+
     //--------------------- Infrastructure ---------------------------
     static volatile int passed = 0, failed = 0;
     static void pass() {passed++;}
--- a/jdk/test/tools/launcher/ExecutionEnvironment.java	Tue Nov 19 15:39:58 2013 +0000
+++ b/jdk/test/tools/launcher/ExecutionEnvironment.java	Tue Nov 19 15:42:59 2013 +0000
@@ -89,10 +89,6 @@
 
     static final File testJarFile = new File("EcoFriendly.jar");
 
-    static final String LIBJVM = TestHelper.isWindows
-            ? "jvm.dll"
-            : "libjvm" + (TestHelper.isMacOSX ? ".dylib" : ".so");
-
     public ExecutionEnvironment() {
         createTestJar();
     }
@@ -192,7 +188,7 @@
 
             tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
             verifyJavaLibraryPathGeneric(tr);
-        } else {
+        } else { // Solaris
             // no override
             env.clear();
             env.put(LD_LIBRARY_PATH, LD_LIBRARY_PATH_VALUE);
@@ -236,23 +232,24 @@
     }
 
     /*
-     * ensures we have indeed exec'ed the correct vm of choice, all VMs support
-     * -server, however 32-bit VMs support -client and -server.
+     * ensures we have indeed exec'ed the correct vm of choice if it exists
      */
     @Test
     void testVmSelection() {
 
         TestResult tr = null;
 
-        if (is32Bit) {
+        if (haveClientVM) {
             tr = doExec(javaCmd, "-client", "-version");
             if (!tr.matches(".*Client VM.*")) {
                 flagError(tr, "the expected vm -client did not launch");
             }
         }
-        tr = doExec(javaCmd, "-server", "-version");
-        if (!tr.matches(".*Server VM.*")) {
-            flagError(tr, "the expected vm -server did not launch");
+        if (haveServerVM) {
+            tr = doExec(javaCmd, "-server", "-version");
+            if (!tr.matches(".*Server VM.*")) {
+                flagError(tr, "the expected vm -server did not launch");
+            }
         }
     }
 
--- a/jdk/test/tools/launcher/Test7029048.java	Tue Nov 19 15:39:58 2013 +0000
+++ b/jdk/test/tools/launcher/Test7029048.java	Tue Nov 19 15:42:59 2013 +0000
@@ -208,6 +208,10 @@
             System.out.println("Note: applicable on neither Windows nor MacOSX");
             return;
         }
+        if (!TestHelper.haveServerVM) {
+            System.out.println("Note: test relies on server vm, not found, exiting");
+            return;
+        }
         // create our test jar first
         ExecutionEnvironment.createTestJar();
 
--- a/jdk/test/tools/launcher/TestHelper.java	Tue Nov 19 15:39:58 2013 +0000
+++ b/jdk/test/tools/launcher/TestHelper.java	Tue Nov 19 15:42:59 2013 +0000
@@ -67,11 +67,15 @@
     static final String JAVAHOME = System.getProperty("java.home");
     static final String JAVA_BIN;
     static final String JAVA_JRE_BIN;
+    static final String JAVA_LIB;
+    static final String JAVA_JRE_LIB;
     static final boolean isSDK = JAVAHOME.endsWith("jre");
     static final String javaCmd;
     static final String javawCmd;
     static final String javacCmd;
     static final String jarCmd;
+    static final boolean haveServerVM;
+    static final boolean haveClientVM;
 
     static final JavaCompiler compiler;
 
@@ -88,6 +92,9 @@
             System.getProperty("os.name", "unknown").startsWith("SunOS");
     static final boolean isLinux =
             System.getProperty("os.name", "unknown").startsWith("Linux");
+    static final String LIBJVM = isWindows
+                        ? "jvm.dll"
+                        : "libjvm" + (isMacOSX ? ".dylib" : ".so");
 
     static final boolean isSparc = System.getProperty("os.arch").startsWith("sparc");
 
@@ -124,12 +131,19 @@
             throw new RuntimeException("arch model is not 32 or 64 bit ?");
         }
         compiler = ToolProvider.getSystemJavaCompiler();
+
         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();
+        JAVA_JRE_BIN = new File(JAVAHOME, "bin").getAbsolutePath();
+
+        File libDir = (isSDK)
+                ? new File((new File(JAVAHOME)).getParentFile(), "lib")
+                : new File(JAVAHOME, "lib");
+        JAVA_LIB = libDir.getAbsolutePath();
+        JAVA_JRE_LIB = new File(JAVAHOME, "lib").getAbsolutePath();
+
         File javaCmdFile = (isWindows)
                 ? new File(binDir, "java.exe")
                 : new File(binDir, "java");
@@ -168,6 +182,21 @@
             throw new RuntimeException("java <" + javacCmd +
                     "> must exist and should be executable");
         }
+
+        haveClientVM = haveVmVariant("client");
+        haveServerVM = haveVmVariant("server");
+    }
+    private static boolean haveVmVariant(String type) {
+        if (isWindows) {
+            File vmDir = new File(JAVA_JRE_BIN, type);
+            File jvmFile = new File(vmDir, LIBJVM);
+            return jvmFile.exists();
+        } else {
+            File vmDir = new File(JAVA_JRE_LIB, type);
+            File vmArchDir = new File(vmDir, getJreArch());
+            File jvmFile = new File(vmArchDir, LIBJVM);
+            return jvmFile.exists();
+        }
     }
     void run(String[] args) throws Exception {
         int passed = 0, failed = 0;