Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
93a7ec6f
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,发现更多精彩内容 >>
提交
93a7ec6f
编写于
7月 10, 2018
作者:
S
Sitong Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
timedrift: add case to check time offset by qom-get
Signed-off-by:
N
Sitong Liu
<
siliu@redhat.com
>
上级
38c9d58e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
102 addition
and
0 deletion
+102
-0
qemu/tests/cfg/timedrift_check_clock_offset.cfg
qemu/tests/cfg/timedrift_check_clock_offset.cfg
+16
-0
qemu/tests/timedrift_check_non_event.py
qemu/tests/timedrift_check_non_event.py
+86
-0
未找到文件。
qemu/tests/cfg/timedrift_check_clock_offset.cfg
浏览文件 @
93a7ec6f
...
...
@@ -49,3 +49,19 @@
query_internal = 600
query_times = 4
drift_threshold = 3
- non_event:
only RHEL
type = timedrift_check_non_event
start_vm = yes
monitor_type = qmp
hwclock_time_command = "LC_TIME=C hwclock -u"
hwclock_time_filter_re = "(\d+-\d+-\d+ \d+:\d+:\d+).*"
hwclock_time_format = "%Y-%m-%d %H:%M:%S"
RHEL.7:
hwclock_time_filter_re = "(\S+ \S+\s+\d+ \d+:\d+:\d+ \d+).*"
hwclock_time_format = "%a %b %d %H:%M:%S %Y"
time_forward = 3600
hwclock_forward_cmd = 'hwclock --set --date "${time_forward} seconds"'
clock_sync_command = "(systemctl stop chronyd || service ntpdate stop)"
clock_sync_command += " && chronyd -q 'server clock.redhat.com iburst'"
drift_threshold = 3
qemu/tests/timedrift_check_non_event.py
0 → 100644
浏览文件 @
93a7ec6f
import
logging
import
re
import
time
from
avocado.utils
import
process
from
virttest
import
error_context
@
error_context
.
context_aware
def
run
(
test
,
params
,
env
):
"""
Check guest offset in non-event way.
1) sync host system time with ntp server
2) boot guest with '-rtc base=utc,clock=host,driftfix=slew'
3) get output of "qom-get" command
4) read RTC time inside guest
5) adjust RTC time forward 1 hour in guest
6) verify output of "qom-get"
:param test: QEMU test object.
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
def
get_hwtime
(
session
):
"""
Get guest's hardware clock in epoch.
:param session: VM session.
"""
hwclock_time_command
=
params
.
get
(
"hwclock_time_command"
,
"hwclock -u"
)
hwclock_time_filter_re
=
params
.
get
(
"hwclock_time_filter_re"
,
r
"(\d+-\d+-\d+ \d+:\d+:\d+).*"
)
hwclock_time_format
=
params
.
get
(
"hwclock_time_format"
,
"%Y-%m-%d %H:%M:%S"
)
output
=
session
.
cmd_output_safe
(
hwclock_time_command
)
try
:
str_time
=
re
.
findall
(
hwclock_time_filter_re
,
output
)[
0
]
guest_time
=
time
.
mktime
(
time
.
strptime
(
str_time
,
hwclock_time_format
))
except
Exception
as
err
:
logging
.
debug
(
"(time_format, output): (%s, %s)"
,
hwclock_time_format
,
output
)
raise
err
return
guest_time
clock_sync_command
=
params
[
"clock_sync_command"
]
error_context
.
context
(
"Sync host system time with ntpserver"
,
logging
.
info
)
process
.
system
(
clock_sync_command
,
shell
=
True
)
vm
=
env
.
get_vm
(
params
[
"main_vm"
])
session
=
vm
.
wait_for_login
()
hwclock_forward_cmd
=
params
[
"hwclock_forward_cmd"
]
time_forward
=
params
[
"time_forward"
]
drift_threshold
=
params
[
"drift_threshold"
]
error_context
.
context
(
"Get output of qom_get"
,
logging
.
info
)
qom_st1
=
vm
.
monitor
.
qom_get
(
"/machine"
,
"rtc-time"
)
error_context
.
context
(
"Get hardware time of guest"
,
logging
.
info
)
hwclock_st1
=
get_hwtime
(
session
)
logging
.
debug
(
"hwclock: guest time=%ss"
,
hwclock_st1
)
error_context
.
context
(
"Adjust guest hardware time forward 1 hour"
,
logging
.
info
)
session
.
cmd
(
hwclock_forward_cmd
,
timeout
=
120
)
error_context
.
context
(
"Verify output of qom-get"
,
logging
.
info
)
qom_st2
=
vm
.
monitor
.
qom_get
(
"/machine"
,
"rtc-time"
)
qom_gap
=
int
(
qom_st2
[
"tm_hour"
])
-
int
(
qom_st1
[
"tm_hour"
])
if
(
qom_gap
<
1
)
or
(
qom_gap
>
2
):
test
.
fail
(
"Unexpected offset in qom-get, "
"qom-get result before change guest's RTC time: %s, "
"qom-get result after change guest's RTC time: %s"
%
(
qom_st1
,
qom_st2
))
error_context
.
context
(
"Verify guest hardware time"
,
logging
.
info
)
hwclock_st2
=
get_hwtime
(
session
)
logging
.
debug
(
"hwclock: guest time=%ss"
,
hwclock_st2
)
session
.
close
()
if
(
hwclock_st1
-
hwclock_st2
-
float
(
time_forward
))
>
float
(
drift_threshold
):
test
.
fail
(
"Unexpected hwclock drift, "
"hwclock: current guest time=%ss"
%
hwclock_st2
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录