diff --git a/qemu/tests/balloon_stress.py b/qemu/tests/balloon_stress.py index 852e2ed8438a1def7cc04dc0126dcaee634f5796..65f389b6934e369815181ee9e80e99942c9fbdf1 100644 --- a/qemu/tests/balloon_stress.py +++ b/qemu/tests/balloon_stress.py @@ -1,5 +1,6 @@ import logging import random +import re from virttest import utils_misc from virttest import utils_test @@ -22,17 +23,18 @@ def run(test, params, env): :param env: Dictionary with test environment. """ - def run_stress(test, params, env, vm): + def check_bg_running(): """ - Run stress in background + Check the background test status in guest. + :return: return True if find the process name; otherwise False """ - while True: - if params['os_type'] == 'windows': - utils_test.run_virt_sub_test(test, params, env, - params.get("stress_test")) - else: - stress_bg = utils_test.VMStress(vm, "stress", params) - stress_bg.load_stress_tool() + if params['os_type'] == 'windows': + list_cmd = params.get("list_cmd", "wmic process get name") + output = session.cmd_output_safe(list_cmd, timeout=60) + process = re.findall("mplayer", output, re.M | re.I) + return bool(process) + else: + return stress_bg.app_running() error_context.context("Boot guest with balloon device", logging.info) vm = env.get_vm(params["main_vm"]) @@ -51,8 +53,16 @@ def run(test, params, env): balloon_test = BallooningTestLinux(test, params, env) error_context.context("Run stress background", logging.info) - bg = utils_misc.InterruptedThread(run_stress, (test, params, env, vm)) - bg.start() + stress_test = params.get("stress_test") + if params['os_type'] == 'windows': + utils_test.run_virt_sub_test(test, params, env, stress_test) + if not utils_misc.wait_for(check_bg_running, first=2.0, + text="wait for stress app to start", + step=1.0, timeout=60): + test.error("Run stress background failed") + else: + stress_bg = utils_test.VMStress(vm, "stress", params) + stress_bg.load_stress_tool() repeat_times = int(params.get("repeat_times", 1000)) min_sz, max_sz = balloon_test.get_memory_boundary() @@ -62,7 +72,7 @@ def run(test, params, env): for i in range(1, int(repeat_times+1)): logging.info("repeat times: %d" % i) balloon_test.balloon_memory(int(random.uniform(min_sz, max_sz))) - if not bg.is_alive(): + if not check_bg_running(): test.error("Background stress process is not alive") finally: if session: diff --git a/qemu/tests/cfg/balloon_in_use.cfg b/qemu/tests/cfg/balloon_in_use.cfg index cd985bdb3d1d7db7a2a54fe89e59dc831ca29491..682847c1f8bf47824b216d72690d08bc1c1e3db6 100644 --- a/qemu/tests/cfg/balloon_in_use.cfg +++ b/qemu/tests/cfg/balloon_in_use.cfg @@ -14,22 +14,12 @@ balloon_timeout = 240 check_setup_events = balloon_test_setup_ready Windows: - x86_64: - program_files = "%ProgramFiles(x86)%" - i386: - program_files = "%ProgramFiles%" stress_test = win_video_play - #Disable first startup guide for windows media player - wmplayer_reg_cmd = "reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer /v GroupPrivacyAcceptance /t REG_DWORD /f /d 00000001" - wmplayer_path = "${program_files}\Windows Media Player\wmplayer.exe" - #Install kmplayer if wmplayer is not installed default - kmplayer_install_cmd = "start /wait WIN_UTILS:\kmplayer\%s\KMPlayer-setup.exe /SP- /VERYSILENT" - kmplayer_path = "${program_files}\KMPlayer\kmplayer.exe" + mplayer_path = "WIN_UTILS:\mplayer.exe" + play_video_cmd = "start /MIN %s %s -loop 0 -fs" + target_process = mplayer.exe video_url = http://fileshare.com/Peppa_Pig_39_The_Tree_House.avi - play_video_cmd = '"%s" "%s" /play /fullscreen' - guest_alias = "Win2008-sp2-32:2k8\x86,Win2008-sp2-64:2k8\amd64,Win2008-r2-64:2k8\amd64,Win2012-64:2k12\amd64,Win2012-64r2:2k12\amd64" driver_name = "balloon" - time_for_video = 600 free_mem_cmd = wmic os get FreePhysicalMemory default_memory = ${mem} check_guest_bsod = yes diff --git a/qemu/tests/cfg/balloon_stress.cfg b/qemu/tests/cfg/balloon_stress.cfg index a2142d94ab3988178874d346501c876dcb9241f9..9d5fa9db3343ff5d75c50bcb97b3a765b352c458 100644 --- a/qemu/tests/cfg/balloon_stress.cfg +++ b/qemu/tests/cfg/balloon_stress.cfg @@ -8,22 +8,11 @@ balloon_dev_devid = balloon0 balloon_dev_add_bus = yes Windows: + driver_name = "balloon" stress_test = win_video_play + mplayer_path = "WIN_UTILS:\mplayer.exe" + play_video_cmd = "start /MIN %s %s -loop 0 -fs" video_url = http://FILESHARE.COM/pub/section2/kvmauto/video/big_buck_bunny_480p_stereo.avi - x86_64: - program_files = "%ProgramFiles(x86)%" - i386: - program_files = "%ProgramFiles%" - driver_name = "balloon" - #Disable first startup guide for windows media player - wmplayer_reg_cmd = "reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer /v GroupPrivacyAcceptance /t REG_DWORD /f /d 00000001" - wmplayer_path = "${program_files}\Windows Media Player\wmplayer.exe" - #Install kmplayer if wmplayer is not installed default - kmplayer_install_cmd = "start /wait WIN_UTILS:\kmplayer\%s\KMPlayer-setup.exe /SP- /VERYSILENT" - kmplayer_path = "${program_files}\KMPlayer\kmplayer.exe" - play_video_cmd = '"%s" "%s" /play /fullscreen' - time_for_video = 1200 - guest_alias = "Win2008-sp2-32:2k8\x86,Win2008-sp2-64:2k8\amd64,Win2008-r2-64:2k8\amd64,Win2012-64:2k12\amd64,Win2012-64r2:2k12\amd64" Linux: # Use a low stress to make sure guest can response during stress stress_args = "--cpu 4 --io 4 --vm 2 --vm-bytes 256M" diff --git a/qemu/tests/cfg/driver_load_stress.cfg b/qemu/tests/cfg/driver_load_stress.cfg index ad71ff469a17ba484dcdccbfdb9418c6f5dfab4b..8ed620819f82cb5252a22c2d895247e61d6b89a3 100644 --- a/qemu/tests/cfg/driver_load_stress.cfg +++ b/qemu/tests/cfg/driver_load_stress.cfg @@ -107,20 +107,10 @@ free_mem_cmd = wmic os get FreePhysicalMemory session_cmd_timeout = 240 stress_test = win_video_play - x86_64: - program_files = "%ProgramFiles(x86)%" - i386: - program_files = "%ProgramFiles%" - #Disable first startup guide for windows media player - wmplayer_reg_cmd = "reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer /v GroupPrivacyAcceptance /t REG_DWORD /f /d 00000001" - wmplayer_path = "${program_files}\Windows Media Player\wmplayer.exe" - #Install kmplayer if wmplayer is not installed default - kmplayer_install_cmd = "start /wait WIN_UTILS:\kmplayer\%s\KMPlayer-setup.exe /SP- /VERYSILENT" - kmplayer_path = "${program_files}\KMPlayer\kmplayer.exe" + mplayer_path = "WIN_UTILS:\mplayer.exe" + play_video_cmd = "start /MIN %s %s -loop 0 -fs" video_url = http://fileshare.com/Peppa_Pig_39_The_Tree_House.avi - play_video_cmd = '"%s" "%s" /play /fullscreen' - target_process = \w+mplayer.exe - guest_alias = "Win2008-sp2-32:2k8\x86,Win2008-sp2-64:2k8\amd64,Win2008-r2-64:2k8\amd64,Win2012-64:2k12\amd64,Win2012-64r2:2k12\amd64" + target_process = mplayer.exe - with_viorng: no no_virtio_rng driver_name = viorng diff --git a/qemu/tests/cfg/win_video_play.cfg b/qemu/tests/cfg/win_video_play.cfg index 194dd3fdf60e4af14491d1ddbaa1c670ba553031..217ed500b55e290c6bacf1e9c33f0c9ba7249ae3 100644 --- a/qemu/tests/cfg/win_video_play.cfg +++ b/qemu/tests/cfg/win_video_play.cfg @@ -2,16 +2,7 @@ type = win_video_play only Windows image_snapshot = yes - x86_64: - program_files = "%ProgramFiles(x86)%" - i386: - program_files = "%ProgramFiles%" - #Disable first startup guide for windows media player - wmplayer_reg_cmd = "reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer /v GroupPrivacyAcceptance /t REG_DWORD /f /d 00000001" - wmplayer_path = "${program_files}\Windows Media Player\wmplayer.exe" - #Install kmplayer if wmplayer is not installed default - kmplayer_install_cmd = "start /wait WIN_UTILS:\kmplayer\%s\KMPlayer-setup.exe /SP- /VERYSILENT" - kmplayer_path = "${program_files}\KMPlayer\kmplayer.exe" + mplayer_path = "WIN_UTILS:\mplayer.exe" + play_video_cmd = "start /MIN %s %s -loop 0 -fs" video_url = http://fileshare.com/Peppa_Pig_39_The_Tree_House.avi - play_video_cmd = '"%s" "%s" /play /fullscreen' - guest_alias = "Win2008-sp2-32:2k8\x86,Win2008-sp2-64:2k8\amd64,Win2008-r2-64:2k8\amd64,Win2012-64:2k12\amd64,Win2012-64r2:2k12\amd64" + play_video_duration = 300 diff --git a/qemu/tests/win_video_play.py b/qemu/tests/win_video_play.py index 43341898010ab2396cdd220679aabf54e70dc01b..a699042ec8ff0bd90daf15681db7e650214c2ca7 100644 --- a/qemu/tests/win_video_play.py +++ b/qemu/tests/win_video_play.py @@ -11,87 +11,30 @@ def run(test, params, env): """ Run video in Windows guest 1) Boot guest with the device. - 2) Check if wmplayer is installed default - 3) Install kmplayer if wmplayer is not installed - 4) Run video + 2) Run video by mplayer :param test: QEMU test object :param params: Dictionary with the test parameters :param env: Dictionary with test environment. """ - def check_wmplayer_installed(session): - """ - Check if wmplayer is installed - - :param session: VM session - :return: return wmplayer.exe path - """ - error_context.context("Check if wmplayer is installed", logging.info) - install_path = params.get("wmplayer_path") - check_cmd = 'dir "%s"|findstr /I wmplayer' - check_cmd = params.get("wmplayer_check_cmd", check_cmd) % install_path - if session.cmd_status(check_cmd) == 0: - return install_path - - def check_kmplayer_installed(session): - """ - Check if kmplayer is installed - - :param session: VM session - :return: return kmplayer.exe path - """ - error_context.context("Check if kmplayer is installed", logging.info) - install_path = params.get("kmplayer_path") - check_cmd = 'dir "%s"|findstr /I kmplayer' - check_cmd = params.get("kmplayer_check_cmd", check_cmd) % install_path - if session.cmd_status(check_cmd) != 0: - kmplayer_install(session) - return install_path - - def kmplayer_install(session): - """ - Install kmplayer - - :param session: VM session - """ - error_context.context("Install kmplayer ...", logging.info) - guest_name = params["guest_name"] - alias_map = params["guest_alias"] - guest_list = dict([x.split(":") for x in alias_map.split(",")]) - guest_name = guest_list[guest_name] - - install_cmd = params["kmplayer_install_cmd"] % guest_name - install_cmd = utils_misc.set_winutils_letter(session, install_cmd) - s, o = session.cmd_status_output(install_cmd, timeout=240) - if s != 0: - raise exceptions.TestError("Failed to install kmplayer %s" % o) - vm = env.get_vm(params["main_vm"]) vm.verify_alive() timeout = float(params.get("login_timeout", 360)) session = vm.wait_for_login(timeout=timeout) - - wmplayer = check_wmplayer_installed(session) - if wmplayer: - video_player = wmplayer - if params.get("wmplayer_reg_cmd"): - logging.info("Update regedit") - session.cmd(params.get("wmplayer_reg_cmd")) - else: - kmplayer = check_kmplayer_installed(session) - video_player = kmplayer - + video_player = utils_misc.set_winutils_letter(session, + params["mplayer_path"]) video_url = params["video_url"] play_video_cmd = params["play_video_cmd"] % (video_player, video_url) error_context.context("Play video", logging.info) try: session.cmd(play_video_cmd, timeout=240) - time.sleep(float(params.get("time_for_video", 240))) except Exception as details: raise exceptions.TestFail(details) - finally: - logging.info("Stop video") + + play_video_duration = params.get("play_video_duration") + if play_video_duration: + time.sleep(int(play_video_duration)) session.cmd("taskkill /IM %s /F" % video_player, ignore_all_errors=True) session.close()