提交 aa6ae35c 编写于 作者: S suqinhuang 提交者: GitHub

Merge pull request #677 from suqinhuang/driver_load_rng

Add virtio-win viorng driver load/unload test
......@@ -4,17 +4,25 @@
kill_vm_on_error = yes
check_guest_bsod = yes
login_timeout = 240
suppress_exception = no
driver_load_cmd = C:\devcon.exe enable @DRIVER_ID
driver_unload_cmd = C:\devcon.exe disable @DRIVER_ID
driver_id_cmd = C:\devcon.exe find * | find "VirtIO"
image_snapshot = yes
only Windows
sub_test = driver_load
i386, i686:
driver_load_cmd = "WIN_UTILS:\devcon\wnet_x86\devcon.exe enable @DRIVER_ID"
driver_unload_cmd = "WIN_UTILS:\devcon\wnet_x86\devcon.exe disable @DRIVER_ID"
driver_id_cmd = 'WIN_UTILS:\devcon\wnet_x86\devcon.exe find * | find "VirtIO"'
driver_check_cmd = "WIN_UTILS:\devcon\wnet_x86\devcon.exe status @DRIVER_ID"
x86_64:
driver_load_cmd = "WIN_UTILS:\devcon\wnet_amd64\devcon.exe enable @DRIVER_ID"
driver_unload_cmd = "WIN_UTILS:\devcon\wnet_amd64\devcon.exe disable @DRIVER_ID"
driver_id_cmd = 'WIN_UTILS:\devcon\wnet_amd64\devcon.exe find * | find "VirtIO"'
driver_check_cmd = "WIN_UTILS:\devcon\wnet_amd64\devcon.exe status @DRIVER_ID"
variants:
- before_bg_test:
run_bg_flag = "before_bg_test"
- during_bg_test:
run_bg_flag = "during_bg_test"
suppress_exception = yes
- after_bg_test:
run_bg_flag = "after_bg_test"
variants:
......@@ -111,3 +119,17 @@
# reset media player play mode
post_cmd += "reg add HKCU\Software\Microsoft\MediaPlayer\Preferences /v ModeLoop /t REG_DWORD /d 0 /f"
target_process = wmplayer.exe
- with_viorng:
no no_virtio_rng
driver_name = viorng
run_bgstress = rng_bat
target_process = random\w*.exe
session_cmd_timeout = 240
read_rng_cmd = "WIN_UTILS:\random_%PROCESSOR_ARCHITECTURE%.exe"
rng_data_rex = "0x\w"
driver_id_pattern = "(.*?):.*?VirtIO RNG Device"
during_bg_test:
run_bgstress = for /l %i in (1, 1, 2000) do WIN_UTILS:\random_%PROCESSOR_ARCHITECTURE%.exe &
test_after_load = rng_bat
bg_stress_test_is_cmd = yes
read_rng_timeout = 360
......@@ -54,10 +54,16 @@ def run(test, params, env):
# Need to set bg_stress_run_flag in some cases to make sure all
# necessary steps are active
env[bg_stress_run_flag] = False
stress_thread = utils.InterruptedThread(
utils_test.run_virt_sub_test, (test, params, env),
{"sub_type": bg_stress_test})
stress_thread.start()
if params.get("bg_stress_test_is_cmd", "no") == "yes":
session = vm.wait_for_login()
bg_stress_test = utils_misc.set_winutils_letter(
session, bg_stress_test)
session.sendline(bg_stress_test)
else:
stress_thread = utils.InterruptedThread(
utils_test.run_virt_sub_test, (test, params, env),
{"sub_type": bg_stress_test})
stress_thread.start()
if not utils_misc.wait_for(lambda: check_bg_running(target_process),
120, 0, 1):
raise exceptions.TestFail("Backgroud test %s is not "
......@@ -95,8 +101,8 @@ def run(test, params, env):
wait_time = float(params.get("wait_bg_time", 60))
suppress_exception = params.get("suppress_exception", "no") == "yes"
error_context.context("Run sub test %s %s" % (sub_type, run_bg_flag),
logging.info)
error_context.context("Run %s %s %s" % (sub_type, run_bg_flag,
bg_stress_test), logging.info)
if run_bg_flag == "before_bg_test":
run_subtest(sub_type)
if vm.is_dead():
......
import logging
import re
import time
from autotest.client.shared import error
from avocado.core import exceptions
from virttest import utils_test
from virttest import utils_misc
from virttest import error_context
@error.context_aware
@error_context.context_aware
def run(test, params, env):
"""
KVM driver load test:
......@@ -21,72 +22,89 @@ def run(test, params, env):
:param env: Dictionary with test environment.
"""
def load_driver(session, cmd, driver_id):
def load_driver(cmd, driver_id):
"""
Load driver
:param cmd: Driver load cmd
:param driver_id: Driver id in windows guest
"""
nic_index = len(vm.virtnet) - 1
session = vm.wait_for_login(nic_index=nic_index)
if params["os_type"] == "windows":
cmd = cmd.replace("DRIVER_ID", driver_id)
status, output = session.cmd_status_output(cmd)
session.close()
if status != 0:
raise error.TestFail("failed to load driver, %s" % output)
if params["os_type"] == "windows":
if "device(s) are enabled" not in output:
raise error.TestFail("failed to load driver, %s" % output)
def unload_driver(session, cmd, driver_id):
raise exceptions.TestFail("failed to load driver, %s" % output)
def unload_driver(cmd, driver_id):
"""
Unload driver
:param cmd: Driver unload cmd
:param driver_id: Driver id in windows guest
"""
nic_index = len(vm.virtnet) - 1
session = vm.wait_for_login(nic_index=nic_index)
if params["os_type"] == "windows":
cmd = cmd.replace("DRIVER_ID", driver_id)
status, output = session.cmd_status_output(cmd)
session.close()
if status != 0:
raise error.TestFail("failed to unload driver, %s" % output)
if params["os_type"] == "windows":
if "device(s) disabled" not in output:
raise error.TestFail("failed to unload driver, %s" % output)
def check_driver(session, cmd, pattern):
if "reboot" in output:
vm.reboot()
session.close()
else:
raise exceptions.TestFail("failed to unload driver, %s" %
output)
def get_driver_id(cmd, pattern):
"""
Get driver id from guest
:param cmd: cmd to get driver info
:param pattern: pattern to filter driver id
"""
nic_index = len(vm.virtnet) - 1
session = vm.wait_for_login(nic_index=nic_index)
output = session.cmd_output(cmd)
driver_id = re.findall(pattern, output)
if not driver_id:
raise error.TestFail("Didn't find driver info from guest %s"
% output)
raise exceptions.TestFail("Didn't find driver info from guest %s"
% output)
driver_id = driver_id[0]
if params["os_type"] == "windows":
driver_id = '^&'.join(driver_id.split('&'))
session.close()
return driver_id
error.context("Try to log into guest.", logging.info)
error_context.context("Try to log into guest.", logging.info)
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
timeout = float(params.get("login_timeout", 240))
# Use the last nic for send driver load/unload command
nic_index = len(vm.virtnet) - 1
session = vm.wait_for_login(nic_index=nic_index, timeout=timeout)
session = vm.wait_for_login(timeout=timeout)
driver_id_cmd = params["driver_id_cmd"]
driver_id_pattern = params["driver_id_pattern"]
driver_load_cmd = params["driver_load_cmd"]
driver_unload_cmd = params["driver_unload_cmd"]
devcon = params.get("devcon")
if devcon:
error.context("Copy devcon.exe from winutils.iso to C:\\")
copy_devcon_cmd = params.get("devcon") % \
utils_misc.get_winutils_vol(session)
session.cmd(copy_devcon_cmd)
driver_id_cmd = utils_misc.set_winutils_letter(
session, params["driver_id_cmd"])
driver_load_cmd = utils_misc.set_winutils_letter(
session, params["driver_load_cmd"])
driver_unload_cmd = utils_misc.set_winutils_letter(
session, params["driver_unload_cmd"])
session.close()
for repeat in range(0, int(params.get("repeats", 1))):
error.context("Unload and load the driver. Round %s" % repeat,
logging.info)
error.context("Get driver info from guest", logging.info)
driver_id = check_driver(session, driver_id_cmd, driver_id_pattern)
error_context.context("Unload and load the driver. Round %s" % repeat,
logging.info)
logging.info("Get driver info from guest")
driver_id = get_driver_id(driver_id_cmd, driver_id_pattern)
error.context("Unload the driver", logging.info)
unload_driver(session, driver_unload_cmd, driver_id)
error_context.context("Unload the driver", logging.info)
unload_driver(driver_unload_cmd, driver_id)
time.sleep(5)
error.context("Load the driver", logging.info)
load_driver(session, driver_load_cmd, driver_id)
error_context.context("Load the driver", logging.info)
load_driver(driver_load_cmd, driver_id)
time.sleep(5)
test_after_load = params.get("test_after_load")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册