Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
45522d60
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
45522d60
编写于
3月 24, 2020
作者:
L
Longxiang Lyu
提交者:
GitHub
3月 24, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2155 from ybduan/umount_wipefs
umount_wipefs: add umount and wipefs steps
上级
49f55a02
282eaa5e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
36 deletion
+27
-36
qemu/tests/cfg/format_disk.cfg
qemu/tests/cfg/format_disk.cfg
+1
-0
qemu/tests/cfg/usb.cfg
qemu/tests/cfg/usb.cfg
+6
-8
qemu/tests/format_disk.py
qemu/tests/format_disk.py
+16
-2
qemu/tests/usb_storage.py
qemu/tests/usb_storage.py
+4
-26
未找到文件。
qemu/tests/cfg/format_disk.cfg
浏览文件 @
45522d60
...
...
@@ -22,6 +22,7 @@
show_dev_cmd = "ls {0}"
mount_cmd = "mkdir -p /media && mount -t ${fs_type} {0} /media"
show_mount_cmd = "mount | grep {0}"
wipefs_cmd = "wipefs -a {0}"
umount_cmd = "umount {0}"
testfile_name = "/media/format_disk-test.txt"
writefile_cmd = "echo %s > %s"
...
...
qemu/tests/cfg/usb.cfg
浏览文件 @
45522d60
...
...
@@ -231,20 +231,19 @@
drive_index_stg = 1
create_image_stg = yes
remove_image_stg = yes
image_size_stg = 10M
fdisk_string = "10 MB, 10485760 bytes"
format_timeout = 400
image_size_stg = 16G
check_serial_option = yes
check_removable_option = yes
check_io_size_option = yes
# The following parameters will be overridden in guest-os config files.
create_partition_cmd = ""
format_cmd = "yes |
mkfs $(readlink -f `ls /dev/disk/by-path/* | grep usb`)
"
format_cmd = "yes |
mkfs.ext4 {0}
"
list_disk_cmd = ""
set_online_cmd = ""
chk_mount_cmd = "grep -qs $(readlink -f `ls /dev/disk/by-path/* | grep usb`) /proc/mounts"
mount_cmd = "mount $(readlink -f `ls /dev/disk/by-path/* | grep usb`) /media"
umount_cmd = "umount $(readlink -f `ls /dev/disk/by-path/* | grep usb`)"
show_mount_cmd = "mount | grep {0}"
wipefs_cmd = "wipefs -a {0}"
mount_cmd = "mkdir -p /media && mount {0} /media"
umount_cmd = "umount {0}"
testfile_name = "/media/usb_storage-test.txt"
writefile_cmd = "echo "set -e" > /media/md5chk.sh;"
writefile_cmd += " out=%s;"
...
...
@@ -317,7 +316,6 @@
force_create_image_image1 = no
remove_image = yes
remove_image_image1 = no
cmd_timeout = 1000
stg_image_size = 1G
stg_image_boot = no
stg_image_format = qcow2
...
...
qemu/tests/format_disk.py
浏览文件 @
45522d60
...
...
@@ -31,9 +31,10 @@ def run(test, params, env):
error_context
.
context
(
"Login to the guest"
,
logging
.
info
)
session
=
vm
.
wait_for_login
(
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
)))
cmd_timeout
=
int
(
params
.
get
(
"cmd_timeout"
,
360
))
os_type
=
params
[
"os_type"
]
drive_path
=
""
if
params
.
get
(
"os_type"
)
==
'linux'
:
if
os_type
==
'linux'
:
drive_name
=
params
.
objects
(
"images"
)[
-
1
]
drive_id
=
params
[
"blk_extra_params_%s"
%
drive_name
].
split
(
"="
)[
1
]
# If a device option(bool/str) in qemu cmd line doesn't have a value,
...
...
@@ -50,7 +51,7 @@ def run(test, params, env):
create_partition_cmd
=
params
.
get
(
"create_partition_cmd"
)
if
create_partition_cmd
:
has_dispart
=
re
.
findall
(
"diskpart"
,
create_partition_cmd
,
re
.
I
)
if
(
params
.
get
(
"os_type"
)
==
'windows'
and
has_dispart
):
if
(
os_type
==
'windows'
and
has_dispart
):
error_context
.
context
(
"Get disk list in guest"
)
list_disk_cmd
=
params
.
get
(
"list_disk_cmd"
)
status
,
output
=
session
.
cmd_status_output
(
list_disk_cmd
,
...
...
@@ -72,6 +73,19 @@ def run(test, params, env):
format_cmd
=
params
.
get
(
"format_cmd"
,
""
).
format
(
drive_path
)
if
format_cmd
:
if
os_type
==
'linux'
:
show_mount_cmd
=
params
[
"show_mount_cmd"
].
format
(
drive_path
)
status
=
session
.
cmd_status
(
show_mount_cmd
)
if
not
status
:
error_context
.
context
(
"Umount before format"
,
logging
.
info
)
umount_cmd
=
params
[
"umount_cmd"
].
format
(
drive_path
)
status
,
output
=
session
.
cmd_status_output
(
umount_cmd
,
timeout
=
cmd_timeout
)
if
status
!=
0
:
test
.
fail
(
"Failed to umount with error: %s"
%
output
)
error_context
.
context
(
"Wipe existing filesystem"
,
logging
.
info
)
wipefs_cmd
=
params
[
"wipefs_cmd"
].
format
(
drive_path
)
session
.
cmd
(
wipefs_cmd
)
error_context
.
context
(
"Format the disk with cmd '%s'"
%
format_cmd
,
logging
.
info
)
status
,
output
=
session
.
cmd_status_output
(
format_cmd
,
...
...
qemu/tests/usb_storage.py
浏览文件 @
45522d60
...
...
@@ -62,7 +62,8 @@ def run(test, params, env):
logging
.
debug
(
string
)
test
.
error
(
"Could not find matched sub-string"
)
error_context
.
context
(
"Verify matched string is same as expected"
)
error_context
.
context
(
"Verify matched string is same as expected"
,
logging
.
info
)
actual_result
=
m
[
0
]
if
"removable"
in
regex_str
:
if
actual_result
in
[
"on"
,
"yes"
,
"true"
]:
...
...
@@ -86,7 +87,7 @@ def run(test, params, env):
test
.
fail
(
"Could not find expected string:
\n
%s"
%
(
"
\n
"
.
join
(
fail_log
)))
def
_do_io_test_guest
(
session
):
def
_do_io_test_guest
():
utils_test
.
run_virt_sub_test
(
test
,
params
,
env
,
"format_disk"
)
@
error_context
.
context_aware
...
...
@@ -118,20 +119,6 @@ def run(test, params, env):
return
devname
[
0
]
return
"sda"
@
error_context
.
context_aware
def
_check_and_umount_usb
(
session
):
chk_status
=
session
.
cmd_status
(
params
[
"chk_mount_cmd"
],
timeout
=
login_timeout
)
if
chk_status
:
return
error_context
.
context
(
"Unmounting usb disk"
,
logging
.
info
)
# choose to umount usb disk instead of ejecting it
# because if usb is removable it will not available after ejection
status
,
output
=
session
.
cmd_status_output
(
params
[
"umount_cmd"
],
timeout
=
login_timeout
)
if
status
!=
0
:
test
.
error
(
"Failed to umount with error: %s"
%
output
)
@
error_context
.
context_aware
def
_check_serial_option
(
serial
,
regex_str
,
expect_str
):
error_context
.
context
(
"Set serial option to '%s'"
%
serial
,
...
...
@@ -148,9 +135,6 @@ def run(test, params, env):
if
serial
not
in
[
"EMPTY_STRING"
,
"NO_EQUAL_STRING"
]:
# Verify in guest when serial is set to empty/null is meaningless.
_verify_string
(
serial
,
output
,
[
serial
])
_check_and_umount_usb
(
session
)
_do_io_test_guest
(
session
)
session
.
close
()
@
error_context
.
context_aware
...
...
@@ -170,9 +154,6 @@ def run(test, params, env):
cmd
=
"dmesg | grep %s"
%
_get_usb_disk_name_in_guest
(
session
)
output
=
session
.
cmd
(
cmd
)
_verify_string
(
expect_str
,
output
,
[
expect_str
],
re
.
I
)
_check_and_umount_usb
(
session
)
_do_io_test_guest
(
session
)
session
.
close
()
@
error_context
.
context_aware
...
...
@@ -206,9 +187,6 @@ def run(test, params, env):
expected_min_size
=
"512"
_verify_string
(
r
"(\d+)\n(\d+)"
,
output
,
[
expected_min_size
,
opt_io_size
])
_check_and_umount_usb
(
session
)
_do_io_test_guest
(
session
)
session
.
close
()
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
...
...
@@ -229,8 +207,8 @@ def run(test, params, env):
# No bus specified, default using "usb.0" for "usb-storage"
for
i
in
params
[
"chk_usb_info_keyword"
].
split
(
","
):
_verify_string
(
i
,
output
,
[
i
])
_do_io_test_guest
(
session
)
session
.
close
()
_do_io_test_guest
()
# this part is linux only
if
params
.
get
(
"check_serial_option"
)
==
"yes"
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录