changeset 14011:3d24d5dcf602

6950237: Test java/nio/file/Path/CopyAndMove.java does not work correctly when test dir in on VFAT Reviewed-by: alanb
author dxu
date Fri, 28 Sep 2012 11:14:20 +0100
parents 24f9f29d5532
children 5eb69af39af2
files jdk/src/solaris/classes/sun/nio/fs/LinuxFileStore.java jdk/test/java/nio/file/Files/CopyAndMove.java
diffstat 2 files changed, 25 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/solaris/classes/sun/nio/fs/LinuxFileStore.java	Fri Sep 28 17:15:48 2012 +0800
+++ b/jdk/src/solaris/classes/sun/nio/fs/LinuxFileStore.java	Fri Sep 28 11:14:20 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2012, 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
@@ -145,6 +145,9 @@
             }
             return xattrEnabled;
         }
+        // POSIX attributes not supported on FAT
+        if (type == PosixFileAttributeView.class && entry().fstype().equals("vfat"))
+            return false;
         return super.supportsFileAttributeView(type);
     }
 
--- a/jdk/test/java/nio/file/Files/CopyAndMove.java	Fri Sep 28 17:15:48 2012 +0800
+++ b/jdk/test/java/nio/file/Files/CopyAndMove.java	Fri Sep 28 11:14:20 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2012, 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
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4313887 6838333 6917021 7006126
+ * @bug 4313887 6838333 6917021 7006126 6950237
  * @summary Unit test for java.nio.file.Files copy and move methods
  * @library ..
  * @build CopyAndMove PassThroughFileSystem
@@ -41,12 +41,14 @@
 public class CopyAndMove {
     static final Random rand = new Random();
     static boolean heads() { return rand.nextBoolean(); }
+    private static boolean testPosixAttributes = false;
 
     public static void main(String[] args) throws Exception {
         Path dir1 = TestUtil.createTemporaryDirectory();
         try {
 
             // Same directory
+            testPosixAttributes = getFileStore(dir1).supportsFileAttributeView("posix");
             testCopyFileToFile(dir1, dir1, TestUtil.supportsLinks(dir1));
             testMove(dir1, dir1, TestUtil.supportsLinks(dir1));
 
@@ -57,6 +59,8 @@
             try {
                 boolean testSymbolicLinks =
                     TestUtil.supportsLinks(dir1) && TestUtil.supportsLinks(dir2);
+                testPosixAttributes = getFileStore(dir1).supportsFileAttributeView("posix") &&
+                                      getFileStore(dir2).supportsFileAttributeView("posix");
                 testCopyFileToFile(dir1, dir2, testSymbolicLinks);
                 testMove(dir1, dir2, testSymbolicLinks);
             } finally {
@@ -65,6 +69,8 @@
 
             // Target is location associated with custom provider
             Path dir3 = PassThroughFileSystem.create().getPath(dir1.toString());
+            testPosixAttributes = getFileStore(dir1).supportsFileAttributeView("posix") &&
+                                  getFileStore(dir3).supportsFileAttributeView("posix");
             testCopyFileToFile(dir1, dir3, false);
             testMove(dir1, dir3, false);
 
@@ -90,7 +96,12 @@
         if (!attrs1.isSymbolicLink()) {
             long time1 = attrs1.lastModifiedTime().toMillis();
             long time2 = attrs2.lastModifiedTime().toMillis();
-            assertTrue(time1 == time2);
+
+            if (time1 != time2) {
+                System.err.format("File time for %s is %s\n", attrs1.fileKey(), attrs1.lastModifiedTime());
+                System.err.format("File time for %s is %s\n", attrs2.fileKey(), attrs2.lastModifiedTime());
+                assertTrue(false);
+            }
         }
 
         // check size
@@ -207,7 +218,10 @@
         if (source.getFileSystem().provider() == target.getFileSystem().provider()) {
 
             // verify POSIX attributes
-            if (posixAttributes != null && !basicAttributes.isSymbolicLink()) {
+            if (posixAttributes != null &&
+                !basicAttributes.isSymbolicLink() &&
+                testPosixAttributes)
+            {
                 checkPosixAttributes(posixAttributes,
                     readAttributes(target, PosixFileAttributes.class, NOFOLLOW_LINKS));
             }
@@ -636,7 +650,9 @@
 
                 // check POSIX attributes are copied
                 String os = System.getProperty("os.name");
-                if (os.equals("SunOS") || os.equals("Linux")) {
+                if ((os.equals("SunOS") || os.equals("Linux")) &&
+                    testPosixAttributes)
+                {
                     checkPosixAttributes(
                         readAttributes(source, PosixFileAttributes.class, linkOptions),
                         readAttributes(target, PosixFileAttributes.class, linkOptions));