Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
1dfc72a9
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1dfc72a9
编写于
8月 13, 2018
作者:
C
Cleber Rosa
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'clebergnu/functional_tests_output_tmpdir'
Signed-off-by:
N
Cleber Rosa
<
crosa@redhat.com
>
上级
7da03618
8f8c6fe0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
111 addition
and
155 deletion
+111
-155
selftests/functional/test_output.py
selftests/functional/test_output.py
+111
-155
未找到文件。
selftests/functional/test_output.py
浏览文件 @
1dfc72a9
...
...
@@ -335,56 +335,45 @@ class OutputPluginTest(unittest.TestCase):
"Missing excerpt error message from output:
\n
%s"
%
output
)
def
test_output_compatible_setup
(
self
):
tmpfile
=
tempfile
.
mktemp
()
tmpfile
=
tempfile
.
mktemp
(
dir
=
self
.
tmpdir
)
cmd_line
=
(
'%s run --job-results-dir %s --sysinfo=off '
'--journal --xunit %s --json - passtest.py'
%
(
AVOCADO
,
self
.
tmpdir
,
tmpfile
))
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
output
=
result
.
stdout_text
+
result
.
stderr_text
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
try
:
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
# Check if we are producing valid outputs
json
.
loads
(
output
)
minidom
.
parse
(
tmpfile
)
finally
:
try
:
os
.
remove
(
tmpfile
)
except
OSError
:
pass
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
# Check if we are producing valid outputs
json
.
loads
(
output
)
minidom
.
parse
(
tmpfile
)
def
test_output_compatible_setup_2
(
self
):
tmpfile
=
tempfile
.
mktemp
()
tmpfile
=
tempfile
.
mktemp
(
dir
=
self
.
tmpdir
)
cmd_line
=
(
'%s run --job-results-dir %s --sysinfo=off '
'--xunit - --json %s --tap-include-logs passtest.py'
%
(
AVOCADO
,
self
.
tmpdir
,
tmpfile
))
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
output
=
result
.
stdout
+
result
.
stderr
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
try
:
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
# Check if we are producing valid outputs
with
open
(
tmpfile
,
'r'
)
as
fp
:
json_results
=
json
.
load
(
fp
)
debug_log
=
json_results
[
'debuglog'
]
self
.
check_output_files
(
debug_log
)
minidom
.
parseString
(
output
)
finally
:
try
:
os
.
remove
(
tmpfile
)
except
OSError
:
pass
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
# Check if we are producing valid outputs
with
open
(
tmpfile
,
'r'
)
as
fp
:
json_results
=
json
.
load
(
fp
)
debug_log
=
json_results
[
'debuglog'
]
self
.
check_output_files
(
debug_log
)
minidom
.
parseString
(
output
)
@
unittest
.
skipIf
(
html_uncapable
(),
"Uncapable of Avocado Result HTML plugin"
)
def
test_output_compatible_setup_3
(
self
):
tmpfile
=
tempfile
.
mktemp
(
prefix
=
'avocado_'
+
__name__
)
tmpfile2
=
tempfile
.
mktemp
(
prefix
=
'avocado_'
+
__name__
)
tmpdir
=
tempfile
.
mkdtemp
(
prefix
=
'avocado_'
+
__name__
)
prefix
=
'avocado_'
+
__name__
tmpfile
=
tempfile
.
mktemp
(
prefix
=
prefix
,
dir
=
self
.
tmpdir
)
tmpfile2
=
tempfile
.
mktemp
(
prefix
=
prefix
,
dir
=
self
.
tmpdir
)
tmpdir
=
tempfile
.
mkdtemp
(
prefix
=
prefix
,
dir
=
self
.
tmpdir
)
tmpfile3
=
os
.
path
.
join
(
tmpdir
,
"result.html"
)
cmd_line
=
(
'%s run --job-results-dir %s --sysinfo=off '
'--xunit %s --json %s --html %s --tap-include-logs '
...
...
@@ -397,28 +386,20 @@ class OutputPluginTest(unittest.TestCase):
self
.
assertEqual
(
len
(
tmpdir_contents
),
1
,
"Html plugin generated "
"extra files in the result dir: %s"
%
tmpdir_contents
)
try
:
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
self
.
assertNotEqual
(
output
,
""
,
"Output is empty"
)
# Check if we are producing valid outputs
with
open
(
tmpfile2
,
'r'
)
as
fp
:
json_results
=
json
.
load
(
fp
)
debug_log
=
json_results
[
'debuglog'
]
self
.
check_output_files
(
debug_log
)
minidom
.
parse
(
tmpfile
)
finally
:
try
:
os
.
remove
(
tmpfile
)
os
.
remove
(
tmpfile2
)
shutil
.
rmtree
(
tmpdir
)
except
OSError
:
pass
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
self
.
assertNotEqual
(
output
,
""
,
"Output is empty"
)
# Check if we are producing valid outputs
with
open
(
tmpfile2
,
'r'
)
as
fp
:
json_results
=
json
.
load
(
fp
)
debug_log
=
json_results
[
'debuglog'
]
self
.
check_output_files
(
debug_log
)
minidom
.
parse
(
tmpfile
)
def
test_output_compatible_setup_nooutput
(
self
):
tmpfile
=
tempfile
.
mktemp
()
tmpfile2
=
tempfile
.
mktemp
()
tmpfile
=
tempfile
.
mktemp
(
dir
=
self
.
tmpdir
)
tmpfile2
=
tempfile
.
mktemp
(
dir
=
self
.
tmpdir
)
# Verify --silent can be supplied as app argument
cmd_line
=
(
'%s --silent run --job-results-dir %s '
'--sysinfo=off --xunit %s --json %s --tap-include-logs '
...
...
@@ -426,23 +407,16 @@ class OutputPluginTest(unittest.TestCase):
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
output
=
result
.
stdout
+
result
.
stderr
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
try
:
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
self
.
assertEqual
(
output
,
b
""
,
"Output is not empty:
\n
%s"
%
output
)
# Check if we are producing valid outputs
with
open
(
tmpfile2
,
'r'
)
as
fp
:
json_results
=
json
.
load
(
fp
)
debug_log
=
json_results
[
'debuglog'
]
self
.
check_output_files
(
debug_log
)
minidom
.
parse
(
tmpfile
)
finally
:
try
:
os
.
remove
(
tmpfile
)
os
.
remove
(
tmpfile2
)
except
OSError
:
pass
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
self
.
assertEqual
(
output
,
b
""
,
"Output is not empty:
\n
%s"
%
output
)
# Check if we are producing valid outputs
with
open
(
tmpfile2
,
'r'
)
as
fp
:
json_results
=
json
.
load
(
fp
)
debug_log
=
json_results
[
'debuglog'
]
self
.
check_output_files
(
debug_log
)
minidom
.
parse
(
tmpfile
)
def
test_nonprintable_chars
(
self
):
cmd_line
=
(
"%s run --external-runner /bin/ls "
...
...
@@ -513,98 +487,80 @@ class OutputPluginTest(unittest.TestCase):
self
.
check_output_files
(
debug_log
)
def
test_verify_whiteboard_save
(
self
):
tmpfile
=
tempfile
.
mktemp
()
try
:
config
=
os
.
path
.
join
(
self
.
tmpdir
,
"conf.ini"
)
content
=
(
"[datadir.paths]
\n
logs_dir = %s"
%
os
.
path
.
relpath
(
self
.
tmpdir
,
"."
))
script
.
Script
(
config
,
content
).
save
()
cmd_line
=
(
'%s --config %s --show all run '
'--sysinfo=off whiteboard.py --json %s'
%
(
AVOCADO
,
config
,
tmpfile
))
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
with
open
(
tmpfile
,
'r'
)
as
fp
:
json_results
=
json
.
load
(
fp
)
logfile
=
json_results
[
'tests'
][
0
][
'logfile'
]
debug_dir
=
os
.
path
.
dirname
(
logfile
)
whiteboard_path
=
os
.
path
.
join
(
debug_dir
,
'whiteboard'
)
self
.
assertTrue
(
os
.
path
.
exists
(
whiteboard_path
),
'Missing whiteboard file %s'
%
whiteboard_path
)
finally
:
try
:
os
.
remove
(
tmpfile
)
except
OSError
:
pass
tmpfile
=
tempfile
.
mktemp
(
dir
=
self
.
tmpdir
)
config
=
os
.
path
.
join
(
self
.
tmpdir
,
"conf.ini"
)
content
=
(
"[datadir.paths]
\n
logs_dir = %s"
%
os
.
path
.
relpath
(
self
.
tmpdir
,
"."
))
script
.
Script
(
config
,
content
).
save
()
cmd_line
=
(
'%s --config %s --show all run '
'--sysinfo=off whiteboard.py --json %s'
%
(
AVOCADO
,
config
,
tmpfile
))
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
with
open
(
tmpfile
,
'r'
)
as
fp
:
json_results
=
json
.
load
(
fp
)
logfile
=
json_results
[
'tests'
][
0
][
'logfile'
]
debug_dir
=
os
.
path
.
dirname
(
logfile
)
whiteboard_path
=
os
.
path
.
join
(
debug_dir
,
'whiteboard'
)
self
.
assertTrue
(
os
.
path
.
exists
(
whiteboard_path
),
'Missing whiteboard file %s'
%
whiteboard_path
)
@
unittest
.
skipIf
(
image_output_uncapable
(),
"Uncapable of generating images with PIL library"
)
def
test_gendata
(
self
):
tmpfile
=
tempfile
.
mktemp
()
try
:
cmd_line
=
(
"%s run --job-results-dir %s "
"--sysinfo=off gendata.py --json %s"
%
(
AVOCADO
,
self
.
tmpdir
,
tmpfile
))
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
with
open
(
tmpfile
,
'r'
)
as
fp
:
json_results
=
json
.
load
(
fp
)
bsod_dir
=
None
json_dir
=
None
for
test
in
json_results
[
'tests'
]:
if
"test_bsod"
in
test
[
'id'
]:
bsod_dir
=
test
[
'logfile'
]
elif
"test_json"
in
test
[
'id'
]:
json_dir
=
test
[
'logfile'
]
self
.
assertTrue
(
bsod_dir
,
"Failed to get test_bsod output "
"directory"
)
self
.
assertTrue
(
json_dir
,
"Failed to get test_json output "
"directory"
)
bsod_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
bsod_dir
),
"data"
,
"bsod.png"
)
json_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
json_dir
),
"data"
,
"test.json"
)
self
.
assertTrue
(
os
.
path
.
exists
(
bsod_dir
),
"File %s produced by"
"test does not exist"
%
bsod_dir
)
self
.
assertTrue
(
os
.
path
.
exists
(
json_dir
),
"File %s produced by"
"test does not exist"
%
json_dir
)
finally
:
try
:
os
.
remove
(
tmpfile
)
except
OSError
:
pass
tmpfile
=
tempfile
.
mktemp
(
dir
=
self
.
tmpdir
)
cmd_line
=
(
"%s run --job-results-dir %s "
"--sysinfo=off gendata.py --json %s"
%
(
AVOCADO
,
self
.
tmpdir
,
tmpfile
))
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
with
open
(
tmpfile
,
'r'
)
as
fp
:
json_results
=
json
.
load
(
fp
)
bsod_dir
=
None
json_dir
=
None
for
test
in
json_results
[
'tests'
]:
if
"test_bsod"
in
test
[
'id'
]:
bsod_dir
=
test
[
'logfile'
]
elif
"test_json"
in
test
[
'id'
]:
json_dir
=
test
[
'logfile'
]
self
.
assertTrue
(
bsod_dir
,
"Failed to get test_bsod output "
"directory"
)
self
.
assertTrue
(
json_dir
,
"Failed to get test_json output "
"directory"
)
bsod_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
bsod_dir
),
"data"
,
"bsod.png"
)
json_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
json_dir
),
"data"
,
"test.json"
)
self
.
assertTrue
(
os
.
path
.
exists
(
bsod_dir
),
"File %s produced by"
"test does not exist"
%
bsod_dir
)
self
.
assertTrue
(
os
.
path
.
exists
(
json_dir
),
"File %s produced by"
"test does not exist"
%
json_dir
)
def
test_redirect_output
(
self
):
redirected_output_path
=
tempfile
.
mktemp
()
try
:
cmd_line
=
(
'%s run --job-results-dir %s '
'--sysinfo=off passtest.py > %s'
%
(
AVOCADO
,
self
.
tmpdir
,
redirected_output_path
))
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
,
shell
=
True
)
output
=
result
.
stdout
+
result
.
stderr
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
self
.
assertEqual
(
output
,
b
''
,
'After redirecting to file, output is not empty: %s'
%
output
)
with
open
(
redirected_output_path
,
'r'
)
as
redirected_output_file_obj
:
redirected_output
=
redirected_output_file_obj
.
read
()
for
code
in
TermSupport
.
ESCAPE_CODES
:
self
.
assertNotIn
(
code
,
redirected_output
,
'Found terminal support code %s in redirected output
\n
%s'
%
(
code
,
redirected_output
))
finally
:
try
:
os
.
remove
(
redirected_output_path
)
except
OSError
:
pass
redirected_output_path
=
tempfile
.
mktemp
(
dir
=
self
.
tmpdir
)
cmd_line
=
(
'%s run --job-results-dir %s '
'--sysinfo=off passtest.py > %s'
%
(
AVOCADO
,
self
.
tmpdir
,
redirected_output_path
))
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
,
shell
=
True
)
output
=
result
.
stdout
+
result
.
stderr
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
self
.
assertEqual
(
output
,
b
''
,
'After redirecting to file, output is not empty: %s'
%
output
)
with
open
(
redirected_output_path
,
'r'
)
as
redirected_output_file_obj
:
redirected_output
=
redirected_output_file_obj
.
read
()
for
code
in
TermSupport
.
ESCAPE_CODES
:
self
.
assertNotIn
(
code
,
redirected_output
,
'Found terminal support code %s in redirected output
\n
%s'
%
(
code
,
redirected_output
))
@
unittest
.
skipIf
(
perl_tap_parser_uncapable
(),
"Uncapable of using Perl TAP::Parser library"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录