Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
fdd391e7
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fdd391e7
编写于
6月 17, 2019
作者:
A
andrew
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
056b2456
67332dee
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
109 addition
and
37 deletion
+109
-37
.hgtags
.hgtags
+1
-0
test/java/nio/file/FileStore/Basic.java
test/java/nio/file/FileStore/Basic.java
+35
-26
test/java/nio/file/FileSystem/Basic.java
test/java/nio/file/FileSystem/Basic.java
+36
-11
test/lib/testlibrary/jdk/testlibrary/FileUtils.java
test/lib/testlibrary/jdk/testlibrary/FileUtils.java
+37
-0
未找到文件。
.hgtags
浏览文件 @
fdd391e7
...
...
@@ -993,3 +993,4 @@ e880f2d161bf23a09f8c1a19861d7df7d2ed126f jdk8u222-b01
7ecf0b6b46aea31bcf2641fcd526d9b211db2420 jdk8u222-b03
8119ddcb3eecd4d3bd4aa6bde441f88d1fd6f999 jdk8u222-b04
887c8314411dd461ec4b1e14cd6368ed3d9a7a3b jdk8u222-b05
63b345c88831be5a690b857adfa84bd20ad376e1 jdk8u222-b06
test/java/nio/file/FileStore/Basic.java
浏览文件 @
fdd391e7
/*
* Copyright (c) 2008, 201
6
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 201
9
, 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
...
...
@@ -24,7 +24,10 @@
/* @test
* @bug 4313887 6873621 6979526 7006126 7020517
* @summary Unit test for java.nio.file.FileStore
* @library ..
* @key intermittent
* @library .. /lib/testlibrary
* @build jdk.testlibrary.FileUtils
* @run main Basic
*/
import
java.nio.file.*
;
...
...
@@ -32,6 +35,7 @@ import java.nio.file.attribute.*;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.*
;
import
jdk.testlibrary.FileUtils
;
public
class
Basic
{
...
...
@@ -109,31 +113,36 @@ public class Basic {
/**
* Test: Enumerate all FileStores
*/
FileStore
prev
=
null
;
for
(
FileStore
store:
FileSystems
.
getDefault
().
getFileStores
())
{
System
.
out
.
format
(
"%s (name=%s type=%s)\n"
,
store
,
store
.
name
(),
store
.
type
());
// check space attributes are accessible
try
{
store
.
getTotalSpace
();
store
.
getUnallocatedSpace
();
store
.
getUsableSpace
();
}
catch
(
NoSuchFileException
nsfe
)
{
// ignore exception as the store could have been
// deleted since the iterator was instantiated
System
.
err
.
format
(
"%s was not found\n"
,
store
);
}
catch
(
AccessDeniedException
ade
)
{
// ignore exception as the lack of ability to access the
// store due to lack of file permission or similar does not
// reflect whether the space attributes would be accessible
// were access to be permitted
System
.
err
.
format
(
"%s is inaccessible\n"
,
store
);
if
(
FileUtils
.
areFileSystemsAccessible
())
{
FileStore
prev
=
null
;
for
(
FileStore
store:
FileSystems
.
getDefault
().
getFileStores
())
{
System
.
out
.
format
(
"%s (name=%s type=%s)\n"
,
store
,
store
.
name
(),
store
.
type
());
// check space attributes are accessible
try
{
store
.
getTotalSpace
();
store
.
getUnallocatedSpace
();
store
.
getUsableSpace
();
}
catch
(
NoSuchFileException
nsfe
)
{
// ignore exception as the store could have been
// deleted since the iterator was instantiated
System
.
err
.
format
(
"%s was not found\n"
,
store
);
}
catch
(
AccessDeniedException
ade
)
{
// ignore exception as the lack of ability to access the
// store due to lack of file permission or similar does not
// reflect whether the space attributes would be accessible
// were access to be permitted
System
.
err
.
format
(
"%s is inaccessible\n"
,
store
);
}
// two distinct FileStores should not be equal
assertTrue
(!
store
.
equals
(
prev
));
prev
=
store
;
}
// two distinct FileStores should not be equal
assertTrue
(!
store
.
equals
(
prev
));
prev
=
store
;
}
else
{
System
.
err
.
println
(
"Skipping FileStore check due to file system access failure"
);
}
}
}
test/java/nio/file/FileSystem/Basic.java
浏览文件 @
fdd391e7
/*
* Copyright (c) 2008, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 201
9
, 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
...
...
@@ -24,12 +24,25 @@
/* @test
* @bug 4313887 6838333
* @summary Unit test for java.nio.file.FileSystem
* @library ..
* @library .. /lib/testlibrary
* @build jdk.testlibrary.FileUtils
* @run main Basic
*/
import
java.nio.file.*
;
import
java.nio.file.attribute.*
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.nio.file.Files
;
import
java.nio.file.FileStore
;
import
java.nio.file.FileSystem
;
import
java.nio.file.FileSystems
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.ProviderNotFoundException
;
import
java.util.HashMap
;
import
java.util.concurrent.TimeUnit
;
import
jdk.testlibrary.FileUtils
;
/**
* Simple santity checks for java.nio.file.FileSystem
...
...
@@ -41,6 +54,20 @@ public class Basic {
throw
new
RuntimeException
(
msg
);
}
static
void
checkFileStores
(
FileSystem
fs
)
throws
IOException
{
// sanity check method
if
(
FileUtils
.
areFileSystemsAccessible
())
{
System
.
out
.
println
(
"\n--- Begin FileStores ---"
);
for
(
FileStore
store:
fs
.
getFileStores
())
{
System
.
out
.
println
(
store
);
}
System
.
out
.
println
(
"--- EndFileStores ---\n"
);
}
else
{
System
.
err
.
println
(
"Skipping FileStore check due to file system access failure"
);
}
}
static
void
checkSupported
(
FileSystem
fs
,
String
...
views
)
{
for
(
String
view:
views
)
{
check
(
fs
.
supportedFileAttributeViews
().
contains
(
view
),
...
...
@@ -48,7 +75,9 @@ public class Basic {
}
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
public
static
void
main
(
String
[]
args
)
throws
IOException
,
URISyntaxException
{
String
os
=
System
.
getProperty
(
"os.name"
);
FileSystem
fs
=
FileSystems
.
getDefault
();
// close should throw UOE
...
...
@@ -63,15 +92,11 @@ public class Basic {
check
(
fs
.
provider
().
getScheme
().
equals
(
"file"
),
"should use 'file' scheme"
);
// santity check method - need to re-visit this in future as I/O errors
// are possible
for
(
FileStore
store:
fs
.
getFileStores
())
{
System
.
out
.
println
(
store
);
}
// sanity check FileStores
checkFileStores
(
fs
);
// sanity check supportedFileAttributeViews
checkSupported
(
fs
,
"basic"
);
String
os
=
System
.
getProperty
(
"os.name"
);
if
(
os
.
equals
(
"SunOS"
))
checkSupported
(
fs
,
"posix"
,
"unix"
,
"owner"
,
"acl"
,
"user"
);
if
(
os
.
equals
(
"Linux"
))
...
...
test/lib/testlibrary/jdk/testlibrary/FileUtils.java
浏览文件 @
fdd391e7
...
...
@@ -33,6 +33,7 @@ import java.nio.file.SimpleFileVisitor;
import
java.nio.file.attribute.BasicFileAttributes
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
/**
...
...
@@ -190,5 +191,41 @@ public final class FileUtils {
}
return
excs
;
}
/**
* Checks whether all file systems are accessible. This is performed
* by checking free disk space on all mounted file systems via a
* separate, spawned process. File systems are considered to be
* accessible if this process completes successfully before a given
* fixed duration has elapsed.
*
* @implNote On Unix this executes the {@code df} command in a separate
* process and on Windows always returns {@code true}.
*/
public
static
boolean
areFileSystemsAccessible
()
throws
IOException
{
boolean
areFileSystemsAccessible
=
true
;
if
(!
isWindows
)
{
// try to check whether 'df' hangs
System
.
out
.
println
(
"\n--- df output ---"
);
System
.
out
.
flush
();
Process
proc
=
new
ProcessBuilder
(
"df"
).
inheritIO
().
start
();
try
{
proc
.
waitFor
(
90
,
TimeUnit
.
SECONDS
);
}
catch
(
InterruptedException
ignored
)
{
}
try
{
int
exitValue
=
proc
.
exitValue
();
if
(
exitValue
!=
0
)
{
System
.
err
.
printf
(
"df process exited with %d != 0%n"
,
exitValue
);
areFileSystemsAccessible
=
false
;
}
}
catch
(
IllegalThreadStateException
ignored
)
{
System
.
err
.
println
(
"df command apparently hung"
);
areFileSystemsAccessible
=
false
;
}
}
return
areFileSystemsAccessible
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录