Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
366d160b
T
tp-qemu
项目概览
openeuler
/
tp-qemu
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tp-qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
366d160b
编写于
8月 24, 2016
作者:
S
suqinhuang
提交者:
GitHub
8月 24, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #731 from pingl2016/amend_case
Add cases for subcommand amend of qemu-img
上级
200f7c45
7562f4ae
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
85 addition
and
0 deletion
+85
-0
qemu/tests/cfg/qemu_img.cfg
qemu/tests/cfg/qemu_img.cfg
+28
-0
qemu/tests/qemu_img.py
qemu/tests/qemu_img.py
+57
-0
未找到文件。
qemu/tests/cfg/qemu_img.cfg
浏览文件 @
366d160b
...
...
@@ -86,3 +86,31 @@
- commit: install setup image_copy unattended_install.cdrom
no vmdk raw qed
subcommand = commit
- amend:
only Host_RHEL.m7
subcommand = amend
start_vm = no
images += " stg"
image_name_stg = "images/stg"
force_create_image_stg = yes
remove_image_stg = yes
check_image_stg = no
variants:
- upgrade:
image_extra_params_stg = "compat=0.10,"
qemu_img_options = compat
compat = 1.1
- downgrade:
image_extra_params_stg = "compat=1.1,"
qemu_img_options = compat
compat = 0.10
variants:
- @default:
- refcount_bits:
variants:
- refcount_bits_32:
image_extra_params_stg += "refcount_bits=32,"
check_output = stderr
command_result_pattern = "(compat=0.10 requires refcount_bits=16)"
- refcount_bits_16:
image_extra_params_stg += "refcount_bits=16,"
qemu/tests/qemu_img.py
浏览文件 @
366d160b
...
...
@@ -264,6 +264,9 @@ def run(test, params, env):
sub_info
+=
": (.*)"
matches
=
re
.
findall
(
sub_info
,
output
)
if
"virtual size"
in
sub_info
:
p
=
re
.
compile
(
r
'\.0*(G|K)$'
)
return
p
.
sub
(
r
'\1'
,
matches
[
0
].
split
()[
0
])
if
matches
:
return
matches
[
0
]
return
None
...
...
@@ -498,6 +501,60 @@ def run(test, params, env):
remove
(
sn2
)
remove
(
sn1
)
def
_amend
(
cmd
,
img_name
,
img_fmt
,
options
):
"""
Simple wrapper of 'qemu-img amend'.
:param cmd: qemu-img base command
:param img_name: image name that should be amended
:param img_fmt: image format
:param options: a comma separated list of format specific options
"""
msg
=
"Amend '%s' with options '%s'"
%
(
img_name
,
options
)
cmd
+=
" amend"
if
img_fmt
:
cmd
+=
" -f %s"
%
img_fmt
cache
=
params
.
get
(
"cache_mode"
,
''
)
if
cache
:
cmd
+=
" -t %s"
%
cache
if
options
:
cmd
+=
" -o "
for
option
in
options
:
cmd
+=
"%s=%s,"
%
(
option
,
params
.
get
(
option
))
cmd
=
cmd
.
rstrip
(
','
)
cmd
+=
" %s"
%
img_name
error
.
context
(
msg
,
logging
.
info
)
check_command_output
(
utils
.
run
(
cmd
,
ignore_status
=
True
))
def
amend_test
(
cmd
):
"""
Subcommand 'qemu-img amend' test
Amend the image format specific options for the image file
:param cmd: qemu-img base command.
"""
img_name
=
params
.
get
(
"image_name_stg"
)
img_fmt
=
params
.
get
(
"image_format_stg"
,
"qcow2"
)
options
=
params
.
get
(
"qemu_img_options"
,
""
).
split
()
check_output
=
params
.
get
(
"check_output"
,
"exit_status"
)
img
=
_get_image_filename
(
img_name
,
img_fmt
=
img_fmt
)
_amend
(
cmd
,
img
,
img_fmt
,
options
)
if
check_output
==
"exit_status"
:
for
option
in
options
:
expect
=
params
.
get
(
option
)
if
option
==
"size"
:
option
=
"virtual size"
actual
=
_info
(
cmd
,
img
,
option
)
if
actual
is
not
None
and
actual
!=
expect
:
msg
=
"Get wrong %s from image %s!"
%
(
option
,
img_name
)
msg
+=
"Expect: %s, actual: %s"
%
(
expect
,
actual
)
raise
error
.
TestFail
(
msg
)
status
,
output
=
_check
(
cmd
,
img
)
if
not
status
:
raise
error
.
TestFail
(
"Check image '%s' failed after rebase;"
"got error: %s"
%
(
img
,
output
))
def
_boot
(
img_name
,
img_fmt
):
"""
Boot test:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录