Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
9a66f45d
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看板
提交
9a66f45d
编写于
7月 06, 2016
作者:
A
avorobye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8071909: Port testlibrary improvments in jdk/test to hotspot/test as required for DCMD test port
Reviewed-by: jbachorik, egahlin, ykantser, mtobiass
上级
ba01cd97
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
97 addition
and
16 deletion
+97
-16
test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java
...stlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java
+68
-0
test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java
...testlibrary/com/oracle/java/testlibrary/ProcessTools.java
+29
-16
未找到文件。
test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java
浏览文件 @
9a66f45d
...
...
@@ -24,6 +24,8 @@
package
com.oracle.java.testlibrary
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
...
...
@@ -69,6 +71,58 @@ public final class OutputAnalyzer {
}
/**
* Verify that the stdout contents of output buffer is empty
*
* @throws RuntimeException
* If stdout was not empty
*/
public
void
stdoutShouldBeEmpty
()
{
if
(!
getStdout
().
isEmpty
())
{
reportDiagnosticSummary
();
throw
new
RuntimeException
(
"stdout was not empty"
);
}
}
/**
* Verify that the stderr contents of output buffer is empty
*
* @throws RuntimeException
* If stderr was not empty
*/
public
void
stderrShouldBeEmpty
()
{
if
(!
getStderr
().
isEmpty
())
{
reportDiagnosticSummary
();
throw
new
RuntimeException
(
"stderr was not empty"
);
}
}
/**
* Verify that the stdout contents of output buffer is not empty
*
* @throws RuntimeException
* If stdout was empty
*/
public
void
stdoutShouldNotBeEmpty
()
{
if
(
getStdout
().
isEmpty
())
{
reportDiagnosticSummary
();
throw
new
RuntimeException
(
"stdout was empty"
);
}
}
/**
* Verify that the stderr contents of output buffer is not empty
*
* @throws RuntimeException
* If stderr was empty
*/
public
void
stderrShouldNotBeEmpty
()
{
if
(
getStderr
().
isEmpty
())
{
reportDiagnosticSummary
();
throw
new
RuntimeException
(
"stderr was empty"
);
}
}
/**
* Verify that the stdout and stderr contents of output buffer contains the string
*
* @param expectedString String that buffer should contain
...
...
@@ -365,4 +419,18 @@ public final class OutputAnalyzer {
public
int
getExitValue
()
{
return
exitValue
;
}
/**
* Get the contents of the output buffer (stdout and stderr) as list of strings.
* Output will be split by newlines.
*
* @return Contents of the output buffer as list of strings
*/
public
List
<
String
>
asLines
()
{
return
asLines
(
getOutput
());
}
private
List
<
String
>
asLines
(
String
buffer
)
{
return
Arrays
.
asList
(
buffer
.
split
(
"(\\r\\n|\\n|\\r)"
));
}
}
test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java
浏览文件 @
9a66f45d
...
...
@@ -187,23 +187,36 @@ public final class ProcessTools {
return
executeProcess
(
pb
);
}
/**
* Executes a process, waits for it to finish and returns the process output.
* @param pb The ProcessBuilder to execute.
* @return The output from the process.
*/
public
static
OutputAnalyzer
executeProcess
(
ProcessBuilder
pb
)
throws
Throwable
{
OutputAnalyzer
output
=
null
;
try
{
output
=
new
OutputAnalyzer
(
pb
.
start
());
return
output
;
}
catch
(
Throwable
t
)
{
System
.
out
.
println
(
"executeProcess() failed: "
+
t
);
throw
t
;
}
finally
{
System
.
out
.
println
(
getProcessLog
(
pb
,
output
));
/**
* Executes a process, waits for it to finish and returns the process output.
* The process will have exited before this method returns.
* @param pb The ProcessBuilder to execute.
* @return The {@linkplain OutputAnalyzer} instance wrapping the process.
*/
public
static
OutputAnalyzer
executeProcess
(
ProcessBuilder
pb
)
throws
Exception
{
OutputAnalyzer
output
=
null
;
Process
p
=
null
;
boolean
failed
=
false
;
try
{
p
=
pb
.
start
();
output
=
new
OutputAnalyzer
(
p
);
p
.
waitFor
();
return
output
;
}
catch
(
Throwable
t
)
{
if
(
p
!=
null
)
{
p
.
destroyForcibly
().
waitFor
();
}
failed
=
true
;
System
.
out
.
println
(
"executeProcess() failed: "
+
t
);
throw
t
;
}
finally
{
if
(
failed
)
{
System
.
err
.
println
(
getProcessLog
(
pb
,
output
));
}
}
}
}
/**
* Executes a process, waits for it to finish and returns the process output.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录