8005202: java/util/logging/CheckLockLocationTest.java fail on solars_10
This test has been seen failing on Solaris 10, presumably because it was run as root. The fix will skip the non-writable case if it can't make a non-writable dir. Reviewed-by: mchung
This commit is contained in:
parent
b33443f947
commit
c430720e0a
@ -33,7 +33,10 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.AccessDeniedException;
|
import java.nio.file.AccessDeniedException;
|
||||||
import java.nio.file.FileSystemException;
|
import java.nio.file.FileSystemException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.NoSuchFileException;
|
import java.nio.file.NoSuchFileException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.attribute.UserPrincipal;
|
||||||
import java.util.logging.FileHandler;
|
import java.util.logging.FileHandler;
|
||||||
public class CheckLockLocationTest {
|
public class CheckLockLocationTest {
|
||||||
|
|
||||||
@ -169,14 +172,19 @@ public class CheckLockLocationTest {
|
|||||||
nonWritableDir.deleteOnExit();
|
nonWritableDir.deleteOnExit();
|
||||||
|
|
||||||
// make it non-writable
|
// make it non-writable
|
||||||
if (nonWritableDir.setWritable(false)) {
|
Path path = nonWritableDir.toPath();
|
||||||
|
final boolean nonWritable = nonWritableDir.setWritable(false);
|
||||||
|
final boolean isWritable = Files.isWritable(path);
|
||||||
|
if (nonWritable && !isWritable) {
|
||||||
runNonWritableDirTest = true;
|
runNonWritableDirTest = true;
|
||||||
|
System.out.println("Created non writable dir for "
|
||||||
|
+ getOwner(path) + " at: " + path.toString());
|
||||||
} else {
|
} else {
|
||||||
runNonWritableDirTest = false;
|
runNonWritableDirTest = false;
|
||||||
System.out.println( "Test Setup WARNING: unable to make"
|
System.out.println( "Test Setup WARNING: unable to make"
|
||||||
+ " working directory " + nonWritableDir.getAbsolutePath()
|
+ " working directory " + nonWritableDir.getAbsolutePath()
|
||||||
+ " non-writable on platform " + System.getProperty("os.name"));
|
+ "\n\t non-writable for " + getOwner(path)
|
||||||
|
+ " on platform " + System.getProperty("os.name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure non-existent directory really doesn't exist
|
// make sure non-existent directory really doesn't exist
|
||||||
@ -184,9 +192,21 @@ public class CheckLockLocationTest {
|
|||||||
if (nonExistentDir.exists()) {
|
if (nonExistentDir.exists()) {
|
||||||
nonExistentDir.delete();
|
nonExistentDir.delete();
|
||||||
}
|
}
|
||||||
|
System.out.println("Setup completed - writableDir is: " + writableDir.getPath());
|
||||||
return writableDir;
|
return writableDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getOwner(Path path) {
|
||||||
|
UserPrincipal user = null;
|
||||||
|
try {
|
||||||
|
user = Files.getOwner(path);
|
||||||
|
} catch (Exception x) {
|
||||||
|
System.err.println("Failed to get owner of: " + path);
|
||||||
|
System.err.println("\terror is: " + x);
|
||||||
|
}
|
||||||
|
return user == null ? "???" : user.getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param newFile
|
* @param newFile
|
||||||
* @return true if file already exists or creation succeeded
|
* @return true if file already exists or creation succeeded
|
||||||
|
Loading…
x
Reference in New Issue
Block a user