Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
82d85aac
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,发现更多精彩内容 >>
提交
82d85aac
编写于
2月 28, 2014
作者:
Y
Yiqiao Pu
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20 from humanux/iofuzz
test.iofuzz: some modifications of iofuzz
上级
60184402
2b7086ce
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
15 deletion
+40
-15
generic/tests/cfg/iofuzz.cfg
generic/tests/cfg/iofuzz.cfg
+4
-0
generic/tests/iofuzz.py
generic/tests/iofuzz.py
+36
-15
未找到文件。
generic/tests/cfg/iofuzz.cfg
浏览文件 @
82d85aac
- iofuzz: install setup image_copy unattended_install.cdrom
virt_test_type = qemu libvirt
backup_image_before_testing = yes
backup_image_on_check_error = yes
restore_image = yes
restore_image_on_check_error = yes
only Linux
type = iofuzz
generic/tests/iofuzz.py
浏览文件 @
82d85aac
...
...
@@ -2,7 +2,8 @@ import logging
import
re
import
random
from
autotest.client.shared
import
error
from
virttest
import
aexpect
from
virttest
import
aexpect
,
qemu_vm
,
virt_vm
from
virttest
import
data_dir
,
storage
,
qemu_storage
def
run
(
test
,
params
,
env
):
...
...
@@ -23,6 +24,16 @@ def run(test, params, env):
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
def
qemu_img_check
():
"""
Check guest disk image, and backup image when error occured
"""
params
[
"backup_image_on_check_error"
]
=
'yes'
base_dir
=
data_dir
.
get_data_dir
()
image_name
=
storage
.
get_image_filename
(
params
,
base_dir
)
image
=
qemu_storage
.
QemuImg
(
params
,
base_dir
,
image_name
)
image
.
check_image
(
params
,
base_dir
)
def
outb
(
session
,
port
,
data
):
"""
Write data to a given port.
...
...
@@ -37,8 +48,8 @@ def run(test, params, env):
(
oct
(
data
),
port
))
try
:
session
.
cmd
(
outb_cmd
)
except
aexpect
.
ShellError
,
e
:
logging
.
debug
(
e
)
except
aexpect
.
ShellError
,
e
rr
:
logging
.
debug
(
e
rr
)
def
inb
(
session
,
port
):
"""
...
...
@@ -51,8 +62,8 @@ def run(test, params, env):
inb_cmd
=
"dd if=/dev/port seek=%d of=/dev/null bs=1 count=1"
%
port
try
:
session
.
cmd
(
inb_cmd
)
except
aexpect
.
ShellError
,
e
:
logging
.
debug
(
e
)
except
aexpect
.
ShellError
,
e
rr
:
logging
.
debug
(
e
rr
)
def
fuzz
(
session
,
inst_list
):
"""
...
...
@@ -66,26 +77,36 @@ def run(test, params, env):
:raise error.TestFail: If the VM process dies in the middle of the
fuzzing procedure.
"""
for
(
op
,
operand
)
in
inst_list
:
if
op
==
"read"
:
for
(
wr_
op
,
operand
)
in
inst_list
:
if
wr_
op
==
"read"
:
inb
(
session
,
operand
[
0
])
elif
op
==
"write"
:
elif
wr_
op
==
"write"
:
outb
(
session
,
operand
[
0
],
operand
[
1
])
else
:
raise
error
.
TestError
(
"Unknown command %s"
%
op
)
raise
error
.
TestError
(
"Unknown command %s"
%
wr_
op
)
if
not
session
.
is_responsive
():
logging
.
debug
(
"Session is not responsive"
)
try
:
vm
.
verify_alive
()
except
qemu_vm
.
QemuSegFaultError
,
err
:
raise
error
.
TestFail
(
"Qemu crash, error info: %s"
%
err
)
except
virt_vm
.
VMDeadKernelCrashError
,
err
:
raise
error
.
TestFail
(
"Guest kernel crash, info: %s"
%
err
)
else
:
logging
.
warn
(
"Guest is not alive during test"
)
if
vm
.
process
.
is_alive
():
logging
.
debug
(
"VM is alive, try to re-login"
)
try
:
session
=
vm
.
wait_for_login
(
timeout
=
10
)
except
Exception
:
logging
.
debug
(
"Could not re-login, reboot the guest"
)
qemu_img_check
()
session
=
vm
.
reboot
(
method
=
"system_reset"
)
else
:
raise
error
.
TestFail
(
"VM has quit abnormally during "
"%s: %s"
%
(
op
,
operand
))
"%s: %s"
%
(
wr_
op
,
operand
))
login_timeout
=
float
(
params
.
get
(
"login_timeout"
,
240
))
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
...
...
@@ -94,12 +115,12 @@ def run(test, params, env):
try
:
ports
=
{}
r
=
random
.
SystemRandom
()
o_random
=
random
.
SystemRandom
()
logging
.
info
(
"Enumerate guest devices through /proc/ioports"
)
ioports
=
session
.
cmd_output
(
"cat /proc/ioports"
)
logging
.
debug
(
ioports
)
devices
=
re
.
findall
(
"(\w+)-(\w+)\ : (.*)"
,
ioports
)
devices
=
re
.
findall
(
r
"(\w+)-(\w+)\ : (.*)"
,
ioports
)
skip_devices
=
params
.
get
(
"skip_devices"
,
""
)
fuzz_count
=
int
(
params
.
get
(
"fuzz_count"
,
10
))
...
...
@@ -126,10 +147,10 @@ def run(test, params, env):
# Write random values to random ports of the range
for
_
in
range
(
fuzz_count
*
(
end
-
beg
+
1
)):
inst
.
append
((
"write"
,
[
r
.
randint
(
beg
,
end
),
r
.
randint
(
0
,
255
)]))
inst
.
append
((
"write"
,
[
o_random
.
randint
(
beg
,
end
),
o_random
.
randint
(
0
,
255
)]))
fuzz
(
session
,
inst
)
vm
.
verify_alive
()
finally
:
session
.
close
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录