Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
tp-qemu
提交
f1f585a2
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,发现更多精彩内容 >>
提交
f1f585a2
编写于
8月 15, 2013
作者:
M
Milan Barta
提交者:
Marian Krcmarik
11月 27, 2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rv_input.py: Rewrite from wxPython to PyGTK.
Signed-off-by:
N
Milan Barta
<
mbarta@redhat.com
>
上级
e7d8f3e7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
50 addition
and
76 deletion
+50
-76
qemu/tests/rv_input.py
qemu/tests/rv_input.py
+50
-76
未找到文件。
qemu/tests/rv_input.py
浏览文件 @
f1f585a2
...
...
@@ -3,7 +3,9 @@ rv_input.py - test keyboard inputs through spice
Requires: Two VMs - client and guest and remote-viewer session
from client VM to guest VM created by rv_connect test.
Deployed wxPython on guest VM.
Deployed PyGTK on guest VM.
Presumes the numlock state at startup is 'OFF'.
"""
import
logging
...
...
@@ -13,57 +15,21 @@ from virttest.aexpect import ShellCmdError
from
virttest
import
utils_misc
,
utils_spice
,
aexpect
def
deploy_epel_repo
(
guest_session
,
params
):
"""
Deploy epel repository to RHEL VM If It's RHEL6 or 5.
:param guest_session - ssh session to guest VM
:param params
"""
# Check existence of epel repository
cmd
=
(
"if [ ! -f /etc/yum.repos.d/epel.repo ]; then echo"
"
\"
NeedsInstall
\"
; fi"
)
output
=
guest_session
.
cmd
(
cmd
,
timeout
=
10
)
# Install epel repository If needed
if
"NeedsInstall"
in
output
:
arch
=
guest_session
.
cmd
(
"arch"
)
if
"i686"
in
arch
:
arch
=
"i386"
else
:
arch
=
arch
[:
-
1
]
if
"release 5"
in
guest_session
.
cmd
(
"cat /etc/redhat-release"
):
cmd
=
(
"yum -y localinstall http://download.fedoraproject.org/"
"pub/epel/5/%s/epel-release-5-4.noarch.rpm 2>&1"
%
arch
)
logging
.
info
(
"Installing epel repository to %s"
,
params
.
get
(
"guest_vm"
))
guest_session
.
cmd
(
cmd
,
print_func
=
logging
.
info
,
timeout
=
90
)
elif
"release 6"
in
guest_session
.
cmd
(
"cat /etc/redhat-release"
):
cmd
=
(
"yum -y localinstall http://download.fedoraproject.org/"
"pub/epel/6/%s/epel-release-6-8.noarch.rpm 2>&1"
%
arch
)
logging
.
info
(
"Installing epel repository to %s"
,
params
.
get
(
"guest_vm"
))
guest_session
.
cmd
(
cmd
,
print_func
=
logging
.
info
,
timeout
=
90
)
else
:
raise
Exception
(
"Unsupported RHEL guest"
)
def
install_wxpython
(
guest_session
,
params
):
def
install_pygtk
(
guest_session
,
params
):
"""
Install wxPython to a VM with yum package manager.
Requires epel repository for RHEL guest.
Install PyGTK to a VM with yum package manager.
:param guest_session - ssh session to guest VM
:param params
"""
cmd
=
"rpm -q
wxPython
"
cmd
=
"rpm -q
pygtk2
"
try
:
guest_session
.
cmd
(
cmd
)
except
ShellCmdError
:
cmd
=
"yum -y install
wxPython
--nogpgcheck > /dev/null"
logging
.
info
(
"Installing
wxPython
package to %s"
,
params
.
get
(
"guest_vm"
))
cmd
=
"yum -y install
pygtk2
--nogpgcheck > /dev/null"
logging
.
info
(
"Installing
pygtk2
package to %s"
,
params
.
get
(
"guest_vm"
))
guest_session
.
cmd
(
cmd
,
timeout
=
60
)
...
...
@@ -143,7 +109,7 @@ def test_leds_and_esc_keys(client_vm, guest_session, params):
:param params
"""
#
Run wxPython
form catching KeyEvents on guest
#
Run PyGTK
form catching KeyEvents on guest
run_test_form
(
guest_session
,
params
)
utils_spice
.
wait_timeout
(
3
)
...
...
@@ -174,7 +140,7 @@ def test_nonus_layout(client_vm, guest_session, params):
:param params
"""
#
Run wxPython
form catching KeyEvents on guest
#
Run PyGTK
form catching KeyEvents on guest
run_test_form
(
guest_session
,
params
)
utils_spice
.
wait_timeout
(
3
)
...
...
@@ -212,7 +178,16 @@ def test_leds_migration(client_vm, guest_vm, guest_session, params):
:param params
"""
# Run wxPython form catching KeyEvents on guest
# Turn numlock on RHEL6 on before the test begins:
grep_ver_cmd
=
"grep -o 'release [[:digit:]]' /etc/redhat-release"
rhel_ver
=
guest_session
.
cmd
(
grep_ver_cmd
).
strip
()
logging
.
info
(
"RHEL version: #{0}#"
.
format
(
rhel_ver
))
if
rhel_ver
==
"release 6"
:
client_vm
.
send_key
(
'num_lock'
)
#Run PyGTK form catching KeyEvents on guest
run_test_form
(
guest_session
,
params
)
utils_spice
.
wait_timeout
(
3
)
...
...
@@ -224,10 +199,10 @@ def test_leds_migration(client_vm, guest_vm, guest_session, params):
utils_spice
.
wait_timeout
(
0.3
)
guest_vm
.
migrate
()
utils_spice
.
wait_timeout
(
5
)
utils_spice
.
wait_timeout
(
8
)
#
Tested keys after migration
test_keys
=
[
'a'
,
'kp_1'
]
#Tested keys after migration
test_keys
=
[
'a'
,
'kp_1'
,
'caps_lock'
,
'num_lock'
]
logging
.
info
(
"Sending leds keys to client machine after migration"
)
for
key
in
test_keys
:
client_vm
.
send_key
(
key
)
...
...
@@ -244,33 +219,38 @@ def analyze_results(file_path, test_type):
"""
if
test_type
==
"type_and_func_keys"
:
#
List of expected keycodes from guest machine
correct_keycodes
=
[
'
2
7'
,
'49'
,
'50'
,
'51'
,
'52'
,
'53'
,
'54'
,
'55'
,
'56'
,
'57'
,
'48'
,
'45'
,
'61'
,
'
8'
,
'9'
,
'113
'
,
'11
9'
,
'101'
,
'114'
,
'116'
,
'121'
,
'117'
,
'105
'
,
'1
11'
,
'112'
,
'91'
,
'93'
,
'13'
,
'97'
,
'115'
,
'100
'
,
'1
02'
,
'103'
,
'104'
,
'106'
,
'107'
,
'108'
,
'59
'
,
'
39'
,
'96'
,
'92'
,
'122'
,
'120'
,
'99'
,
'118'
,
'98
'
,
'11
0'
,
'109'
,
'44'
,
'46'
,
'47'
,
'32'
,
'340'
,
'341
'
,
'
342'
,
'343'
,
'344'
,
'345'
,
'346'
,
'347'
,
'348
'
,
'34
9'
]
#List of expected keycodes from guest machine
correct_keycodes
=
[
'
6530
7'
,
'49'
,
'50'
,
'51'
,
'52'
,
'53'
,
'54'
,
'55'
,
'56'
,
'57'
,
'48'
,
'45'
,
'61'
,
'
65288'
,
'65289
'
,
'11
3'
,
'119'
,
'101'
,
'114'
,
'116'
,
'121'
,
'117
'
,
'1
05'
,
'111'
,
'112'
,
'91'
,
'93'
,
'65293'
,
'97
'
,
'1
15'
,
'100'
,
'102'
,
'103'
,
'104'
,
'106'
,
'107
'
,
'
108'
,
'59'
,
'39'
,
'96'
,
'92'
,
'122'
,
'120'
,
'99
'
,
'11
8'
,
'98'
,
'110'
,
'109'
,
'44'
,
'46'
,
'47'
,
'32
'
,
'
65470'
,
'65471'
,
'65472'
,
'65473'
,
'65474
'
,
'65475'
,
'65476'
,
'65477'
,
'65478'
,
'6547
9'
]
elif
test_type
==
"leds_and_esc_keys"
:
correct_keycodes
=
[
'97'
,
'65'
,
'49'
,
'312'
,
'97'
,
'65'
,
'65'
,
'1'
,
'3'
,
'22'
,
'120'
,
'322'
,
'127'
,
'313'
,
'312'
,
'366'
,
'367'
,
'315'
,
'317'
,
'316'
,
'314'
]
correct_keycodes
=
[
'97'
,
'65509'
,
'65'
,
'65509'
,
'65407'
,
'65457'
,
'65407'
,
'65436'
,
'97'
,
'65505'
,
'65'
,
'65506'
,
'65'
,
'65507'
,
'97'
,
'65507'
,
'99'
,
'65507'
,
'118'
,
'65513'
,
'120'
,
'65379'
,
'65535'
,
'65360'
,
'65367'
,
'65365'
,
'65366'
,
'65362'
,
'65364'
,
'65363'
,
'65361'
]
elif
test_type
==
"nonus_layout"
:
correct_keycodes
=
[
'253'
,
'225'
,
'237'
,
'233'
,
'35'
,
'38'
,
'64'
,
'223'
,
'252'
,
'64'
,
'181'
]
correct_keycodes
=
[
'253'
,
'225'
,
'237'
,
'233'
,
'65027'
,
'35'
,
'65027'
,
'38'
,
'65027'
,
'64'
,
'223'
,
'252'
,
'65027'
,
'64'
,
'65027'
,
'181'
]
elif
test_type
==
"leds_migration"
:
correct_keycodes
=
[
'97'
,
'312'
,
'65'
,
'49'
,
'65'
,
'49'
]
correct_keycodes
=
[
'97'
,
'65457'
,
'65509'
,
'65407'
,
'65'
,
'65436'
,
'65'
,
'65436'
,
'65509'
,
'65407'
]
# Read caught keycodes on guest machine
fileobj
=
open
(
file_path
,
"r"
)
keycodes
=
fileobj
.
read
()
fileobj
.
close
()
#
Compare caught keycodes with expected keycodes
test_keycodes
=
keycodes
.
split
(
","
)
#Compare caught keycodes with expected keycodes
test_keycodes
=
keycodes
.
split
()
logging
.
info
(
"Caught keycodes:%s"
,
test_keycodes
)
for
i
in
range
(
len
(
correct_keycodes
)):
if
not
(
test_keycodes
[
i
]
==
correct_keycodes
[
i
]):
...
...
@@ -298,14 +278,8 @@ def run_rv_input(test, params, env):
guest_session
=
guest_vm
.
wait_for_login
(
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
)))
guest_root_session
=
guest_vm
.
wait_for_login
(
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
)),
username
=
"root"
,
password
=
"123456"
)
try
:
guest_session
.
cmd
(
"! test -e /etc/redhat-release"
)
except
ShellCmdError
:
deploy_epel_repo
(
guest_root_session
,
params
)
# utils_spice.launch_startx(guest_vm)
timeout
=
int
(
params
.
get
(
"login_timeout"
,
360
)),
username
=
"root"
,
password
=
"123456"
)
# Verify that gnome is now running on the guest
try
:
...
...
@@ -315,7 +289,7 @@ def run_rv_input(test, params, env):
guest_session
.
cmd
(
"export DISPLAY=:0.0"
)
install_
wxpython
(
guest_root_session
,
params
)
install_
pygtk
(
guest_root_session
,
params
)
deploy_test_form
(
test
,
guest_vm
,
params
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录