6950237: Test java/nio/file/Path/CopyAndMove.java does not work correctly when test dir in on VFAT
Reviewed-by: alanb
This commit is contained in:
parent
7ffcd7343f
commit
f41a30cb5c
@ -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 @@ class LinuxFileStore
|
||||
}
|
||||
return xattrEnabled;
|
||||
}
|
||||
// POSIX attributes not supported on FAT
|
||||
if (type == PosixFileAttributeView.class && entry().fstype().equals("vfat"))
|
||||
return false;
|
||||
return super.supportsFileAttributeView(type);
|
||||
}
|
||||
|
||||
|
@ -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 @@ import java.util.*;
|
||||
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 @@ public class CopyAndMove {
|
||||
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 @@ public class CopyAndMove {
|
||||
|
||||
// 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 @@ public class CopyAndMove {
|
||||
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 @@ public class CopyAndMove {
|
||||
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 @@ public class CopyAndMove {
|
||||
|
||||
// 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));
|
||||
|
Loading…
Reference in New Issue
Block a user