From f1972cabea7424e358706bf3e044a5be3970cdc1 Mon Sep 17 00:00:00 2001 From: Yiqiao Pu Date: Wed, 15 Feb 2012 17:29:28 +0000 Subject: [PATCH] tests: WHQL env setup Set up WHQL env following the whql request: 1) Log into a guest 2) Update Windows kernel to the newest version 3) Un-check Automatically restart in system failure 4) Disable UAC 5) Get the symbol files and update it to date 6) Set VM to physical memory + 100M 7) Update the nic configuration 8) Install debug view and make it auto run 9) Format disk if needed 10) Update qxl driver 11) Setup timezone 12) Disable windows update and firewall changes from v1: - Update symbol files automatic - Format disk in block device test - Save command line in record files - Update qxl driver - Setup timezone to China standard - Disable windows update and firewall changes from v2: - Fix symbole file thread problem - Fix disk format failed problem Signed-off-by: Yiqiao Pu Bin folder has been removed and most file in it have been moved to client folder. Signed-off-by: Feng Yang Fix some bugs in the scripts: - Use 64bit program in 64 bit system for nic setup - Update the nic setup with option and value pair as parameters - Fix some configuration mistakes - Fix some indent problem Signed-off-by: Yiqiao Pu --- tests/cfg/whql.cfg | 63 ++++++++++++++ tests/whql_env_setup.py | 185 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 248 insertions(+) create mode 100644 tests/whql_env_setup.py diff --git a/tests/cfg/whql.cfg b/tests/cfg/whql.cfg index 1c114be5..af3b7c18 100644 --- a/tests/cfg/whql.cfg +++ b/tests/cfg/whql.cfg @@ -169,3 +169,66 @@ - syscache_test: job_filter = syscache test test_timeout = 7200 + - whql_env_setup: + vms = "" + type = whql_env_setup + smp = 4 + rtc_drift = "slew" + drive_werror = stop + drive_rerror = stop + cpu_family = "0xf" + uuid = random + force_create_image = yes + force_create_image_image1 = no + update_cmd = cmd /c D:\whql\wua_update.exe && cmd /c net stop wuauserv && cmd /c net start wuauserv && cmd /c D:\whql\WUInstall.exe /install /criteria "IsHidden=0 and IsInstalled=0 and IsAssigned=1" && dir + auto_restart = "cmd /c regedit /s D:\whql\auto_restart_disable.reg" + disable_uas = "cmd /c regedit /s D:\whql\UAC_disable.reg" + dbgview_cmd = "cmd /c D:\whql\dbgview_install.exe" + setup_timeout = 9000 + disable_firewall = "netsh firewall set opmode mode=disable" + disable_update = "net stop wuauserv" + timezone_cmd = "tzutil /s "China Standard Time"" + # If you have some extra tools or scripts needed please put url or file list here. We will make a tmp iso here for running them inside guests + # cdrom_whql = images/whql.iso + # src_list = + variants: + - nic_device: + nics += ' nic2 nic3' + nic_model = virtio + nic_model_nic1 = e1000 + nic_config_cmd = "cmd /c D:\whql\whql_nic_set.exe" + nic_setup_params_nic2 = Init.MaxRxBuffers:256;Init.MaxTxBuffers:256 + nic_setup_params_nic3 = Init.MaxRxBuffers:256;Init.MaxTxBuffers:256 + + - block_device: + image_snapshot = yes + images += " stg stg2 stg3 stg4" + image_format_stg = raw + image_name_stg = images/storage + image_size_stg = 2G + image_format_stg2 = raw + image_name_stg2 = images/storage2 + image_size_stg2 = 2G + image_format_stg3 = raw + image_name_stg3 = images/storage3 + image_size_stg3 = 2G + image_format_stg4 = raw + image_name_stg4 = images/storage4 + image_size_stg4 = 2G + win_format_stg = NTFS + win_format_stg2 = NTFS + win_format_stg3 = FAT + win_format_stg4 = FAT32 + win_extra_stg = "/c" + # symbol_files git repo is a git repo set up in your test env which include most of the symbol files + # We just need update the symbol files in guest which may save a lot of time. + # symbol_files = + debuggers_install = "cmd /c D:\whql\dbg_install.bat" + symbol_file_download = "cmd /c C:\debuggers\symchk /r C:\windows\system32 /s SRV*C:\symbols\*http://msdl.microsoft.com/download/symbols & dir" + symbol_file_check = "cmd /c C:\debuggers\symchk C:\windows\system32\ntoskrnl.exe /s C:\symbols\" + symbol_check_pattern = "SYMCHK: FAILED files = 0" + symbol_pid_pattern = "symchk.*?PID:\s+(\d+)" + + disk_driver_install = "cmd /c D:\whql\disk_driver_check.exe " + format_cmd = "format %s: /FS:%s /V:local /y" + disk_init_cmd = "echo select disk %s > cmd && echo create partition primary >> cmd && echo select partition 1 >> cmd && echo assign letter=%s >> cmd && echo exit >> cmd && diskpart /s cmd" diff --git a/tests/whql_env_setup.py b/tests/whql_env_setup.py new file mode 100644 index 00000000..3dca1c10 --- /dev/null +++ b/tests/whql_env_setup.py @@ -0,0 +1,185 @@ +import time, os, re, logging +from autotest.client.shared import error +from virttest import utils_misc +from virttest import utils_test +from virttest import env_process +from virttest import data_dir +from autotest.client import utils + + +@error.context_aware +def run_whql_env_setup(test, params, env): + """ + KVM whql env setup test: + 1) Log into a guest + 2) Update Windows kernel to the newest version + 3) Un-check Automatically restart in system failure + 4) Disable UAC + 5) Get the symbol files + 6) Set VM to physical memory + 100M + 7) Update the nic configuration + 8) Install debug view and make it auto run + + @param test: QEMU test object + @param params: Dictionary with the test parameters + @param env: Dictionary with test environment. + """ + log_path = "%s/../debug" % test.resultsdir + # Prepare the tools iso + error.context("Prepare the tools iso", logging.info) + src_list = params.get("src_list") + src_path = params.get("src_path", "%s/whql_src" % test.tmpdir) + if not os.path.exists(src_path): + os.makedirs(src_path) + if src_list is not None: + for i in re.split(",", src_list): + utils.unmap_url(src_path, i, src_path) + + # Make iso for src + cdrom_whql = params.get("cdrom_whql") + cdrom_whql = utils_misc.get_path(data_dir.get_data_dir(), cdrom_whql) + cdrom_whql_dir = os.path.split(cdrom_whql)[0] + if not os.path.exists(cdrom_whql_dir): + os.makedirs(cdrom_whql_dir) + cmd = "mkisofs -J -o %s %s" % (cdrom_whql, src_path) + utils.system(cmd) + params["cdroms"] += " whql" + + vm = "vm1" + vm_params = params.object_params(vm) + env_process.preprocess_vm(test, vm_params, env, vm) + vm = env.get_vm(vm) + + timeout = float(params.get("login_timeout", 240)) + session = vm.wait_for_login(timeout=timeout) + error_log = utils_misc.get_path(log_path, "whql_setup_error_log") + run_guest_log = params.get("run_guest_log", "%s/whql_qemu_comman" % test.tmpdir) + + # Record qmmu command line in a log file + error.context("Record qemu command line", logging.info) + if os.path.isfile(run_guest_log): + fd = open(run_guest_log, "r+") + fd.read() + else: + fd = open(run_guest_log, "w") + fd.write("%s\n" % vm.qemu_command) + fd.close() + + + # Get set up commands + update_cmd = params.get("update_cmd", "") + timezone_cmd = params.get("timezone_cmd", "") + auto_restart = params.get("auto_restart", "") + qxl_install = params.get("qxl_install", "") + debuggers_install = params.get("debuggers_install", "") + disable_uas = params.get("disable_uas", "") + symbol_files = params.get("symbol_files", "") + vm_size = int(params.get("mem")) + 100 + nic_cmd = params.get("nic_config_cmd", "") + dbgview_cmd = params.get("dbgview_cmd", "") + format_cmd = params.get("format_cmd", "") + disable_firewall = params.get("disable_firewall", "") + disable_update = params.get("disable_update", "") + setup_timeout = int(params.get("setup_timeout", "7200")) + disk_init_cmd = params.get("disk_init_cmd", "") + disk_driver_install = params.get("disk_driver_install", "") + + vm_ma_cmd = "wmic computersystem set AutomaticManagedPagefile=False" + vm_cmd = "wmic pagefileset where name=\"C:\\\\pagefile.sys\" set " + vm_cmd += "InitialSize=%s,MaximumSize=%s" % (vm_size, vm_size) + vm_ma_cmd = "" + vm_cmd = "" + if symbol_files: + symbol_cmd = "del C:\\\\symbols &&" + symbol_cmd += "git clone %s C:\\\\symbol_files C:\\\\symbols" % \ + symbol_files + else: + symbol_cmd = "" + wmic_prepare_cmd = "echo exit > cmd && cmd /s wmic" + + error.context("Configure guest system", logging.info) + cmd_list = [wmic_prepare_cmd, auto_restart, disable_uas, symbol_cmd, + vm_ma_cmd, vm_cmd, dbgview_cmd, qxl_install, disable_firewall, + timezone_cmd] + if nic_cmd: + for index, nic in enumerate(re.split("\s+", params.get("nics"))): + setup_params = params.get("nic_setup_params_%s" % nic, "") + if params.get("platform", "") == "x86_64": + nic_cmd = re.sub("set", "set_64", nic_cmd) + cmd_list.append("%s %s %s" % (nic_cmd, str(index + 1), + setup_params)) + if disk_init_cmd: + disk_num = len(re.split("\s+", params.get("images"))) + if disk_driver_install: + cmd_list.append(disk_driver_install + str(disk_num - 1)) + labels = "IJKLMNOPQRSTUVWXYZ" + for index, images in enumerate(re.split("\s+", params.get("images"))): + if index > 0: + cmd_list.append(disk_init_cmd % (str(index), + labels[index-1])) + format_cmd_image = format_cmd % (labels[index-1], + params.get("win_format_%s" % images)) + if params.get("win_extra_%s" % images): + format_cmd_image += " %s" % params.get("win_extra_%s" % images) + cmd_list.append(format_cmd_image) + + cmd_list += [update_cmd, disable_update] + + failed_flag = 0 + + # Check symbol files in guest + if symbol_files: + error.context("Update symbol files", logging.info) + install_check_tool = False + check_tool_chk = params.get("check_tool_chk", + "C:\debuggers\symchk.exe") + output = session.cmd_output(check_tool_chk) + if "cannot find" in output: + install_check_tool = True + + if install_check_tool: + output = session.cmd_output(debuggers_install) + symbol_file_check = params.get("symbol_file_check") + symbol_file_download = params.get("symbol_file_download") + + symbol_check_pattern = params.get("symbol_check_pattern") + symbol_pid_pattern = params.get("symbol_pid_pattern") + download = utils_test.BackgroundTest(session.cmd, + (symbol_file_download, + setup_timeout)) + + sessioncheck = vm.wait_for_login(timeout=timeout) + download.start() + while download.is_alive(): + o = sessioncheck.cmd_output(symbol_file_check, setup_timeout) + if symbol_check_pattern in o: + # Check is done kill download process + cmd = "tasklist /FO list" + s, o = sessioncheck.cmd_status_output(cmd) + pid = re.findall(symbol_pid_pattern, o, re.S) + if pid: + cmd = "taskkill /PID %s /F" % pid[0] + try: + sessioncheck.cmd(cmd) + except Exception: + pass + break + time.sleep(5) + sessioncheck.close() + download.join() + + for cmd in cmd_list: + if len(cmd) > 0: + s = 0 + try: + s, o = session.cmd_status_output(cmd, timeout=setup_timeout) + except Exception, err: + failed_flag += 1 + utils_misc.log_line(error_log, "Unexpected exception: %s" % err) + if s != 0: + failed_flag += 1 + utils_misc.log_line(error_log, o) + + if failed_flag != 0: + raise error.TestFail("Have %s setup fialed. Please check the log." + % failed_flag) -- GitLab