Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
49108b4d
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,发现更多精彩内容 >>
未验证
提交
49108b4d
编写于
11月 21, 2018
作者:
Q
Qianqian Zhu
提交者:
GitHub
11月 21, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1555 from sitoliu/boottest_fix
timerdevice_boot: fix bug
上级
26927c61
4d593f12
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
47 addition
and
46 deletion
+47
-46
qemu/tests/timerdevice_boot.py
qemu/tests/timerdevice_boot.py
+47
-46
未找到文件。
qemu/tests/timerdevice_boot.py
浏览文件 @
49108b4d
...
...
@@ -4,6 +4,7 @@ import re
from
avocado.utils
import
process
from
virttest
import
utils_test
from
virttest
import
utils_time
from
virttest
import
funcatexit
from
virttest
import
error_context
...
...
@@ -58,10 +59,40 @@ def run(test, params, env):
raise
err
return
guest_time
def
verify_timedrift
(
session
,
is_hardware
=
False
):
"""
Verify timedrift between host and guest.
:param session: VM session.
:param is_hardware: if need to verify guest's hardware time.
"""
# Command to run to get the current time
time_command
=
params
[
"time_command"
]
# Filter which should match a string to be passed to time.strptime()
time_filter_re
=
params
[
"time_filter_re"
]
# Time format for time.strptime()
time_format
=
params
[
"time_format"
]
timerdevice_drift_threshold
=
float
(
params
.
get
(
"timerdevice_drift_threshold"
,
3
))
time_type
=
"system"
if
not
is_hardware
else
"harware"
error_context
.
context
(
"Check the %s time on guest"
%
time_type
,
logging
.
info
)
host_time
,
guest_time
=
utils_test
.
get_time
(
session
,
time_command
,
time_filter_re
,
time_format
)
if
is_hardware
:
guest_time
=
get_hwtime
(
session
)
drift
=
abs
(
float
(
host_time
)
-
float
(
guest_time
))
if
drift
>
timerdevice_drift_threshold
:
test
.
fail
(
"The guest's %s time is different with"
" host's system time. Host time: '%s', guest time:"
" '%s'"
%
(
time_type
,
host_time
,
guest_time
))
def
get_current_clksrc
(
session
):
cmd
=
"cat /sys/devices/system/clocksource/"
cmd
+=
"clocksource0/current_clocksource"
current_clksrc
=
session
.
cmd_output
(
cmd
)
current_clksrc
=
session
.
cmd_output
_safe
(
cmd
)
if
"kvm-clock"
in
current_clksrc
:
return
"kvm-clock"
elif
"tsc"
in
current_clksrc
:
...
...
@@ -82,7 +113,7 @@ def run(test, params, env):
"""
avail_cmd
=
"cat /sys/devices/system/clocksource/clocksource0/"
avail_cmd
+=
"available_clocksource"
avail_clksrc
=
session
.
cmd_output
(
avail_cmd
)
avail_clksrc
=
session
.
cmd_output
_safe
(
avail_cmd
)
if
clksrc
in
avail_clksrc
:
clksrc_cmd
=
"echo %s > /sys/devices/system/clocksource/"
%
clksrc
clksrc_cmd
+=
"clocksource0/current_clocksource"
...
...
@@ -113,6 +144,12 @@ def run(test, params, env):
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
vm
.
verify_alive
()
error_context
.
context
(
"Sync guest timezone before test"
,
logging
.
info
)
if
params
[
"os_type"
]
==
'linux'
:
utils_time
.
sync_timezone_linux
(
vm
)
else
:
utils_time
.
sync_timezone_win
(
vm
)
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
))
session
=
vm
.
wait_for_serial_login
(
timeout
=
timeout
)
...
...
@@ -126,33 +163,11 @@ def run(test, params, env):
update_clksrc
(
session
,
timerdevice_clksource
)
need_restore_clksrc
=
True
# Command to run to get the current time
time_command
=
params
[
"time_command"
]
# Filter which should match a string to be passed to time.strptime()
time_filter_re
=
params
[
"time_filter_re"
]
# Time format for time.strptime()
time_format
=
params
[
"time_format"
]
timerdevice_drift_threshold
=
float
(
params
.
get
(
"timerdevice_drift_threshold"
,
3
))
error_context
.
context
(
"Check the system time on guest and host"
,
error_context
.
context
(
"check timedrift between guest and host."
,
logging
.
info
)
(
host_time
,
guest_time
)
=
utils_test
.
get_time
(
session
,
time_command
,
time_filter_re
,
time_format
)
verify_timedrift
(
session
)
if
params
[
"os_type"
]
==
"linux"
:
error_context
.
context
(
"Check the hardware time on guest"
,
logging
.
info
)
guest_hwtime
=
get_hwtime
(
session
)
drift
=
abs
(
float
(
host_time
)
-
float
(
guest_time
))
if
drift
>
timerdevice_drift_threshold
:
test
.
fail
(
"The guest's system time is different with"
" host's. Host time: '%s', guest time:"
" '%s'"
%
(
host_time
,
guest_time
))
drift
=
abs
(
float
(
host_time
)
-
float
(
guest_hwtime
))
if
drift
>
timerdevice_drift_threshold
:
test
.
fail
(
"The guest's hardware time is different with"
" host's system time. Host time: '%s', guest time:"
" '%s'"
%
(
host_time
,
guest_hwtime
))
verify_timedrift
(
session
,
is_hardware
=
True
)
if
params
.
get
(
"timerdevice_reboot_test"
)
==
"yes"
:
sleep_time
=
params
.
get
(
"timerdevice_sleep_time"
)
...
...
@@ -162,26 +177,12 @@ def run(test, params, env):
sleep_time
=
int
(
sleep_time
)
time
.
sleep
(
sleep_time
)
session
=
vm
.
reboot
(
timeout
=
timeout
)
error_context
.
context
(
"Check the system time on guest and host"
,
logging
.
info
)
(
host_time
,
guest_time
)
=
utils_test
.
get_time
(
session
,
time_command
,
time_filter_re
,
time_format
)
drift
=
abs
(
float
(
host_time
)
-
float
(
guest_time
))
if
drift
>
timerdevice_drift_threshold
:
test
.
fail
(
"The guest's system time is different with"
" host's. Host time: '%s', guest time:"
" '%s'"
%
(
host_time
,
guest_time
))
error_context
.
context
(
"Check timedrift between guest and host "
"after reboot."
,
logging
.
info
)
vm
.
reboot
(
timeout
=
timeout
,
serial
=
True
)
verify_timedrift
(
session
)
if
params
[
"os_type"
]
==
"linux"
:
error_context
.
context
(
"Check the hardware time on guest"
,
logging
.
info
)
guest_hwtime
=
get_hwtime
(
session
)
drift
=
abs
(
float
(
host_time
)
-
float
(
guest_hwtime
))
if
drift
>
timerdevice_drift_threshold
:
test
.
fail
(
"The guest's hardware time is different with"
" host's. Host time: '%s', guest time:"
" '%s'"
%
(
host_time
,
guest_hwtime
))
verify_timedrift
(
session
,
is_hardware
=
True
)
session
.
close
()
if
need_restore_clksrc
:
update_clksrc
(
session
,
origin_clksrc
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录