Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
20f32c94
D
dragonwell8_hotspot
项目概览
openanolis
/
dragonwell8_hotspot
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_hotspot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
20f32c94
编写于
12月 18, 2014
作者:
K
kevinw
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
e03ef29a
344efc3b
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
91 addition
and
2 deletion
+91
-2
test/serviceability/sa/jmap-hashcode/Test8028623.java
test/serviceability/sa/jmap-hashcode/Test8028623.java
+7
-2
test/testlibrary/com/oracle/java/testlibrary/Platform.java
test/testlibrary/com/oracle/java/testlibrary/Platform.java
+55
-0
test/testlibrary/com/oracle/java/testlibrary/Utils.java
test/testlibrary/com/oracle/java/testlibrary/Utils.java
+29
-0
未找到文件。
test/serviceability/sa/jmap-hashcode/Test8028623.java
浏览文件 @
20f32c94
...
...
@@ -33,20 +33,25 @@
import
com.oracle.java.testlibrary.JDKToolLauncher
;
import
com.oracle.java.testlibrary.OutputBuffer
;
import
com.oracle.java.testlibrary.Platform
;
import
com.oracle.java.testlibrary.ProcessTools
;
import
java.io.File
;
public
class
Test8028623
{
public
static
int
Ã
=
1
;
public
static
int
\
u00CB
=
1
;
public
static
String
dumpFile
=
"heap.out"
;
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
Ã
);
System
.
out
.
println
(
\
u00CB
);
try
{
if
(!
Platform
.
shouldSAAttach
())
{
System
.
out
.
println
(
"SA attach not expected to work - test skipped."
);
return
;
}
int
pid
=
ProcessTools
.
getProcessId
();
JDKToolLauncher
jmap
=
JDKToolLauncher
.
create
(
"jmap"
)
.
addToolArg
(
"-F"
)
...
...
test/testlibrary/com/oracle/java/testlibrary/Platform.java
浏览文件 @
20f32c94
...
...
@@ -23,12 +23,15 @@
package
com.oracle.java.testlibrary
;
import
com.oracle.java.testlibrary.Utils
;
public
class
Platform
{
private
static
final
String
osName
=
System
.
getProperty
(
"os.name"
);
private
static
final
String
dataModel
=
System
.
getProperty
(
"sun.arch.data.model"
);
private
static
final
String
vmVersion
=
System
.
getProperty
(
"java.vm.version"
);
private
static
final
String
osArch
=
System
.
getProperty
(
"os.arch"
);
private
static
final
String
vmName
=
System
.
getProperty
(
"java.vm.name"
);
private
static
final
String
userName
=
System
.
getProperty
(
"user.name"
);
public
static
boolean
isClient
()
{
return
vmName
.
endsWith
(
" Client VM"
);
...
...
@@ -121,4 +124,56 @@ public class Platform {
return
osArch
;
}
/**
* Return a boolean for whether we expect to be able to attach
* the SA to our own processes on this system.
*/
public
static
boolean
shouldSAAttach
()
throws
Exception
{
if
(
isLinux
())
{
return
canPtraceAttachLinux
();
}
else
if
(
isOSX
())
{
return
canAttachOSX
();
}
else
{
// Other platforms expected to work:
return
true
;
}
}
/**
* On Linux, first check the SELinux boolean "deny_ptrace" and return false
* as we expect to be denied if that is "1". Then expect permission to attach
* if we are root, so return true. Then return false for an expected denial
* if "ptrace_scope" is 1, and true otherwise.
*/
public
static
boolean
canPtraceAttachLinux
()
throws
Exception
{
// SELinux deny_ptrace:
String
deny_ptrace
=
Utils
.
fileAsString
(
"/sys/fs/selinux/booleans/deny_ptrace"
);
if
(
deny_ptrace
!=
null
&&
deny_ptrace
.
contains
(
"1"
))
{
// ptrace will be denied:
return
false
;
}
if
(
userName
.
equals
(
"root"
))
{
return
true
;
}
// ptrace_scope:
String
ptrace_scope
=
Utils
.
fileAsString
(
"/proc/sys/kernel/yama/ptrace_scope"
);
if
(
ptrace_scope
!=
null
&&
ptrace_scope
.
contains
(
"1"
))
{
// ptrace will be denied:
return
false
;
}
// Otherwise expect to be permitted:
return
true
;
}
/**
* On OSX, expect permission to attach only if we are root.
*/
public
static
boolean
canAttachOSX
()
throws
Exception
{
return
userName
.
equals
(
"root"
);
}
}
test/testlibrary/com/oracle/java/testlibrary/Utils.java
浏览文件 @
20f32c94
...
...
@@ -298,6 +298,35 @@ public final class Utils {
return
output
;
}
/**
* Return the contents of the named file as a single String,
* or null if not found.
* @param filename name of the file to read
* @return String contents of file, or null if file not found.
*/
public
static
String
fileAsString
(
String
filename
)
{
StringBuilder
result
=
new
StringBuilder
();
try
{
File
file
=
new
File
(
filename
);
if
(
file
.
exists
())
{
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
file
));
while
(
true
)
{
String
line
=
reader
.
readLine
();
if
(
line
==
null
)
{
break
;
}
result
.
append
(
line
).
append
(
"\n"
);
}
}
else
{
// Does not exist:
return
null
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
result
.
toString
();
}
/**
* @return Unsafe instance.
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录