Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
b2701428
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,发现更多精彩内容 >>
提交
b2701428
编写于
10月 28, 2013
作者:
X
Xu Tian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu.tests: add check clock offset when vm crash/bsod
Signed-off-by:
N
Xu Tian
<
xutian@redhat.com
>
上级
24e7d937
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
96 addition
and
0 deletion
+96
-0
qemu/tests/timedrift_check_when_crash.py
qemu/tests/timedrift_check_when_crash.py
+96
-0
未找到文件。
qemu/tests/timedrift_check_when_crash.py
0 → 100644
浏览文件 @
b2701428
import
logging
import
time
import
re
from
autotest.client.shared
import
error
from
autotest.client.shared
import
utils
from
virttest.env_process
import
preprocess
from
virttest.virt_vm
import
VMDeadKernelCrashError
@
error
.
context_aware
def
run_timedrift_check_when_crash
(
test
,
params
,
env
):
"""
Time clock offset check when guest crash/bsod test:
1) boot guest with '-rtc base=utc,clock=host,driftfix=slew';
2) sync host system time with "ntpdate clock.redhat.com";
3) inject nmi to guest/ make linux kernel crash;
4) sleep long time, then reset vm via system_reset;
5) query clock offset from ntp server;
:param test: QEMU test object.
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
ntp_server
=
params
.
get
(
"ntp_server"
,
"clock.redhat.com"
)
ntp_cmd
=
params
[
"ntp_cmd"
]
ntp_query_cmd
=
params
[
"ntp_query_cmd"
]
nmi_cmd
=
params
.
get
(
"nmi_cmd"
,
"inject-nmi"
)
sleep_time
=
float
(
params
.
get
(
"sleep_time"
,
1800
))
deviation
=
float
(
params
.
get
(
"deviation"
,
5
))
error
.
context
(
"sync host time with ntp server"
,
logging
.
info
)
utils
.
system
(
"ntpdate %s"
%
ntp_server
)
error
.
context
(
"start guest"
,
logging
.
info
)
params
[
"start_vm"
]
=
"yes"
preprocess
(
test
,
params
,
env
)
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
error
.
context
(
"sync time in guest"
,
logging
.
info
)
session
.
cmd
(
ntp_cmd
)
error
.
context
(
"inject nmi interupt in vm"
,
logging
.
info
)
target
,
cmd
=
re
.
split
(
"\s*:\s*"
,
nmi_cmd
)
if
target
==
"monitor"
:
vm
.
monitor
.
send_args_cmd
(
cmd
)
else
:
session
.
sendline
(
cmd
)
try
:
session
.
cmd
(
"dir"
)
except
Exception
:
pass
else
:
raise
error
.
TestFail
(
"Guest OS still alive ..."
)
error
.
context
(
"sleep %s seconds"
%
sleep_time
,
logging
.
info
)
time
.
sleep
(
sleep_time
)
# Autotest parses serial output and could raise VMDeadKernelCrash
# we generated using sysrq. Ignore one "BUG:" line
try
:
session
=
vm
.
reboot
(
method
=
"system_reset"
)
except
VMDeadKernelCrashError
,
details
:
details
=
str
(
details
)
if
(
re
.
findall
(
r
"Trigger a crash\s.*BUG:"
,
details
,
re
.
M
)
and
details
.
count
(
"BUG:"
)
!=
1
):
raise
error
.
TestFail
(
"Got multiple kernel crashes. Please "
"note that one of them was "
"intentionally generated by sysrq in "
"this test.
\n
%s"
%
details
)
end_time
=
time
.
time
()
+
timeout
while
time
.
time
()
<
end_time
:
try
:
session
=
vm
.
wait_for_login
(
timeout
=
timeout
)
except
VMDeadKernelCrashError
,
details
:
details
=
str
(
details
)
if
(
re
.
findall
(
r
"Trigger a crash\s.*BUG:"
,
details
,
re
.
M
)
and
details
.
count
(
"BUG:"
)
!=
1
):
raise
error
.
TestFail
(
"Got multiple kernel crashes. "
"Please note that one of them was "
"intentionally generated by sysrq "
"in this test.
\n
%s"
%
details
)
else
:
break
error
.
context
(
"check time offset via ntp"
,
logging
.
info
)
output
=
session
.
cmd_output
(
ntp_query_cmd
)
try
:
offset
=
re
.
findall
(
r
"[+-](\d+\.\d+)"
,
output
,
re
.
M
)[
-
1
]
except
IndexError
:
offset
=
0.0
if
float
(
offset
)
>
deviation
:
raise
error
.
TestFail
(
"Unacceptable offset '%s', "
%
offset
+
"deviation '%s'"
%
deviation
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录