提交 1ef21670 编写于 作者: S sherman

6969651: TEST_BUG: tools/jar/JarEntryTime.java failed on JDK7 when run on NFS

Summary: changed to use more appropriate nfs file time
Reviewed-by: martin
上级 26d9ae85
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/** /**
* @test * @test
* @bug 4225317 * @bug 4225317 6969651
* @summary Check extracted files have date as per those in the .jar file * @summary Check extracted files have date as per those in the .jar file
*/ */
...@@ -68,17 +68,9 @@ public class JarEntryTime { ...@@ -68,17 +68,9 @@ public class JarEntryTime {
} }
public static void realMain(String[] args) throws Throwable { public static void realMain(String[] args) throws Throwable {
final long now = System.currentTimeMillis();
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;
File dirOuter = new File("outer"); File dirOuter = new File("outer");
File dirInner = new File(dirOuter, "inner"); File dirInner = new File(dirOuter, "inner");
File jarFile = new File("JarEntryTime.jar"); File jarFile = new File("JarEntryTime.jar");
// Remove any leftovers from prior run // Remove any leftovers from prior run
...@@ -99,6 +91,17 @@ public class JarEntryTime { ...@@ -99,6 +91,17 @@ public class JarEntryTime {
PrintWriter pw = new PrintWriter(fileInner); PrintWriter pw = new PrintWriter(fileInner);
pw.println("hello, world"); pw.println("hello, world");
pw.close(); pw.close();
// Get the "now" from the "last-modified-time" of the last file we
// just created, instead of the "System.currentTimeMillis()", to
// workaround the possible "time difference" due to nfs.
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); dirOuter.setLastModified(now);
dirInner.setLastModified(yesterday); dirInner.setLastModified(yesterday);
fileInner.setLastModified(earlier); fileInner.setLastModified(earlier);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册