Example #1
0
def run_unittest_kvmctl(test, params, env):
    """
    This is kvm userspace unit test, use kvm test harness kvmctl load binary
    test case file to test various functions of the kvm kernel module.
    The output of all unit tests can be found in the test result dir.

    @param test: KVM test object.
    @param params: Dictionary with the test parameters.
    @param env: Dictionary with test environment.
    """
    case = params.get("case")
    srcdir = params.get("srcdir", test.srcdir)
    unit_dir = os.path.join(srcdir, "kvm_userspace", "kvm", "user")
    if not os.path.isdir(unit_dir):
        os.makedirs(unit_dir)
    os.chdir(unit_dir)

    cmd = "./kvmctl test/x86/bootstrap test/x86/%s.flat" % case
    try:
        results = utils.system_output(cmd)
    except error.CmdError:
        raise error.TestFail("Unit test %s failed" % case)

    result_file = os.path.join(test.resultsdir, case)
    utils.open_write_close(result_file, results)
Example #2
0
def run_iozone_windows(test, params, env):
    """
    Run IOzone for windows on a windows guest:
    1) Log into a guest
    2) Execute the IOzone test contained in the winutils.iso
    3) Get results
    4) Postprocess it with the IOzone postprocessing module

    @param test: kvm test object
    @param params: Dictionary with the test parameters
    @param env: Dictionary with test environment.
    """
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    timeout = int(params.get("login_timeout", 360))
    session = vm.wait_for_login(timeout=timeout)
    results_path = os.path.join(test.resultsdir,
                                'raw_output_%s' % test.iteration)
    analysisdir = os.path.join(test.resultsdir, 'analysis_%s' % test.iteration)

    # Run IOzone and record its results
    c = params.get("iozone_cmd")
    t = int(params.get("iozone_timeout"))
    logging.info("Running IOzone command on guest, timeout %ss", t)
    results = session.cmd_output(cmd=c, timeout=t)
    utils.open_write_close(results_path, results)

    # Postprocess the results using the IOzone postprocessing module
    logging.info("Iteration succeed, postprocessing")
    a = postprocess_iozone.IOzoneAnalyzer(list_files=[results_path],
                                          output_dir=analysisdir)
    a.analyze()
    p = postprocess_iozone.IOzonePlotter(results_file=results_path,
                                         output_dir=analysisdir)
    p.plot_all()
Example #3
0
def run_iozone_windows(test, params, env):
    """
    Run IOzone for windows on a windows guest:
    1) Log into a guest
    2) Execute the IOzone test contained in the winutils.iso
    3) Get results
    4) Postprocess it with the IOzone postprocessing module

    @param test: kvm test object
    @param params: Dictionary with the test parameters
    @param env: Dictionary with test environment.
    """
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    timeout = int(params.get("login_timeout", 360))
    session = vm.wait_for_login(timeout=timeout)
    results_path = os.path.join(test.resultsdir,
                                'raw_output_%s' % test.iteration)
    analysisdir = os.path.join(test.resultsdir, 'analysis_%s' % test.iteration)

    # Run IOzone and record its results
    c = params.get("iozone_cmd")
    t = int(params.get("iozone_timeout"))
    logging.info("Running IOzone command on guest, timeout %ss", t)
    results = session.cmd_output(cmd=c, timeout=t)
    utils.open_write_close(results_path, results)

    # Postprocess the results using the IOzone postprocessing module
    logging.info("Iteration succeed, postprocessing")
    a = postprocessing.IOzoneAnalyzer(list_files=[results_path],
                                      output_dir=analysisdir)
    a.analyze()
    p = postprocessing.IOzonePlotter(results_file=results_path,
                                     output_dir=analysisdir)
    p.plot_all()
Example #4
0
    def answer_kickstart(self, answer_path):
        """
        Replace KVM_TEST_CDKEY (in the unattended file) with the cdkey
        provided for this test and replace the KVM_TEST_MEDIUM with
        the tree url or nfs address provided for this test.

        @return: Answer file contents
        """
        contents = open(self.unattended_file).read()

        dummy_cdkey_re = r'\bKVM_TEST_CDKEY\b'
        if re.search(dummy_cdkey_re, contents):
            if self.cdkey:
                contents = re.sub(dummy_cdkey_re, self.cdkey, contents)

        dummy_medium_re = r'\bKVM_TEST_MEDIUM\b'
        if self.medium in ["cdrom", "kernel_initrd"]:
            content = "cdrom"

        elif self.medium == "url":
            content = "url --url %s" % self.url

        elif self.medium == "nfs":
            content = "nfs --server=%s --dir=%s" % (self.nfs_server,
                                                    self.nfs_dir)
        else:
            raise ValueError("Unexpected installation medium %s" % self.url)

        contents = re.sub(dummy_medium_re, content, contents)

        logging.debug("Unattended install contents:")
        for line in contents.splitlines():
            logging.debug(line)

        utils.open_write_close(answer_path, contents)
Example #5
0
    def run_once(self, testname=['compiler'], do='run'):
	cmd = 'phoronix-test-suite'

	utils.system_output(cmd + ' list-available-suites',retain_output=True)	
	for test in testname:
		res_dir = test + '-result'
		des_conf = test + '-conf'
		self.results_path = os.path.join(self.resultsdir,'raw_output_%s' % test)
                if (test == 'desktop-graphics'):
			base_cmd = cmd + ' ' + do + ' ' + test
			todo = ''' <<TODO
                        y
                        ''' + res_dir + \
                        '''
                        ''' + des_conf + '''
                        
                        n                        
                        TODO'''
                        self.results = utils.system_output('export DISPLAY=:0.0;' + base_cmd + todo,
                                                        retain_output=True)
                        utils.open_write_close(self.results_path, self.results)
		else:
                	fout = open(self.results_path, 'w')
			runpts = pexpect.spawn('%s %s %s' % (cmd, do, test))
			runpts.logfile = fout
			while 1:
				index = runpts.expect(['\(Y/n\):', pexpect.EOF, pexpect.TIMEOUT])
                                print index
				logging.info("now start first expect.........")
				if index == 0 :
					break
				elif index == 1 :
					pass
				elif index == 2 :
					pass
			runpts.sendline('y')
			logging.debug(runpts.before)
			runpts.expect('under:')
			runpts.sendline(res_dir)
			logging.debug(runpts.before)
			runpts.expect('configuration:')
			runpts.sendline(des_conf)
			logging.debug(runpts.before)
			runpts.expect('Description:')
			runpts.sendline('')
			logging.debug(runpts.before)
			logging.info("now start run test..............")
			while 1:
                        	index = runpts.expect(['OpenBenchmarking.org', pexpect.EOF, pexpect.TIMEOUT])
 				index = runpts.expect(['\(Y/n\):', pexpect.EOF, pexpect.TIMEOUT])
                        	if index == 0 :
                                	break
                        	elif index == 1 :
                                	pass
                        	elif index == 2 :
                                	pass
			runpts.sendline('n')
			logging.debug(runpts.before)
			runpts.expect(pexpect.EOF)
			fout.close()
Example #6
0
    def answer_kickstart(self, answer_path):
        """
        Replace KVM_TEST_CDKEY (in the unattended file) with the cdkey
        provided for this test and replace the KVM_TEST_MEDIUM with
        the tree url or nfs address provided for this test.

        @return: Answer file contents
        """
        contents = open(self.unattended_file).read()

        dummy_cdkey_re = r'\bKVM_TEST_CDKEY\b'
        if re.search(dummy_cdkey_re, contents):
            if self.cdkey:
                contents = re.sub(dummy_cdkey_re, self.cdkey, contents)

        dummy_medium_re = r'\bKVM_TEST_MEDIUM\b'
        if self.medium in ["cdrom", "kernel_initrd"]:
            content = "cdrom"

        elif self.medium == "url":
            content = "url --url %s" % self.url

        elif self.medium == "nfs":
            content = "nfs --server=%s --dir=%s" % (self.nfs_server,
                                                    self.nfs_dir)
        else:
            raise ValueError("Unexpected installation medium %s" % self.url)

        contents = re.sub(dummy_medium_re, content, contents)

        logging.debug("Unattended install contents:")
        for line in contents.splitlines():
            logging.debug(line)

        utils.open_write_close(answer_path, contents)
 def run_once(self, args=''):
     vars = 'UB_TMPDIR="%s" UB_RESULTDIR="%s"' % (self.tmpdir,
                                                  self.resultsdir)
     os.chdir(self.srcdir)
     self.report_data = utils.system_output(vars + ' ./Run ' + args)
     self.results_path = os.path.join(self.resultsdir,
                                      'raw_output_%s' % self.iteration)
     utils.open_write_close(self.results_path, self.report_data)
Example #8
0
 def run_once(self, args=''):
     vars = 'UB_TMPDIR="%s" UB_RESULTDIR="%s"' % (self.tmpdir,
                                                  self.resultsdir)
     os.chdir(self.srcdir)
     self.report_data = utils.system_output(vars + ' ./Run ' + args)
     self.results_path = os.path.join(self.resultsdir,
                                      'raw_output_%s' % self.iteration)
     utils.open_write_close(self.results_path, self.report_data)
Example #9
0
    def client(self, server_ip, test, test_time, num_streams, args):
        run_args = '-H %s -t %s -l %d' % (server_ip, test, test_time)
	self.results_path = os.path.join(self.resultsdir,'netperf_output_%s_%s' % (test, self.iteration))
        # Append the test specific arguments.
        if args:
            run_args += ' ' + args
        
	cmd = '%s %s' % (self.client_prog, run_args)
        self.results = utils.system_output(cmd, retain_output=True)
	utils.open_write_close(self.results_path, self.results)
Example #10
0
    def request_devs(self, count=None):
        """
        Implement setup process: unbind the PCI device and then bind it
        to the pci-stub driver.

        @param count: count number of PCI devices needed for pass through

        @return: a list of successfully requested devices' PCI IDs.
        """
        if count is None:
            count = self.devices_requested
        base_dir = "/sys/bus/pci"
        stub_path = os.path.join(base_dir, "drivers/pci-stub")

        self.pci_ids = self.get_devs(count)
        logging.info("The following pci_ids were found: %s", self.pci_ids)
        requested_pci_ids = []

        # Setup all devices specified for assignment to guest
        for pci_id in self.pci_ids:
            full_id = utils_misc.get_full_pci_id(pci_id)
            if not full_id:
                continue
            drv_path = os.path.join(base_dir, "devices/%s/driver" % full_id)
            dev_prev_driver = os.path.realpath(
                os.path.join(drv_path, os.readlink(drv_path)))
            self.dev_drivers[pci_id] = dev_prev_driver

            # Judge whether the device driver has been binded to stub
            if not self.is_binded_to_stub(full_id):
                error.context("Bind device %s to stub" % full_id, logging.info)
                vendor_id = utils_misc.get_vendor_from_pci_id(pci_id)
                stub_new_id = os.path.join(stub_path, 'new_id')
                unbind_dev = os.path.join(drv_path, 'unbind')
                stub_bind = os.path.join(stub_path, 'bind')

                info_write_to_files = [(vendor_id, stub_new_id),
                                       (full_id, unbind_dev),
                                       (full_id, stub_bind)]

                for content, file in info_write_to_files:
                    try:
                        utils.open_write_close(file, content)
                    except IOError:
                        logging.debug("Failed to write %s to file %s", content,
                                      file)
                        continue

                if not self.is_binded_to_stub(full_id):
                    logging.error("Binding device %s to stub failed", pci_id)
                    continue
            else:
                logging.debug("Device %s already binded to stub", pci_id)
            requested_pci_ids.append(pci_id)
        return requested_pci_ids
Example #11
0
    def request_devs(self, count=None):
        """
        Implement setup process: unbind the PCI device and then bind it
        to the pci-stub driver.

        @param count: count number of PCI devices needed for pass through

        @return: a list of successfully requested devices' PCI IDs.
        """
        if count is None:
            count = self.devices_requested
        base_dir = "/sys/bus/pci"
        stub_path = os.path.join(base_dir, "drivers/pci-stub")

        self.pci_ids = self.get_devs(count)
        logging.info("The following pci_ids were found: %s", self.pci_ids)
        requested_pci_ids = []

        # Setup all devices specified for assignment to guest
        for pci_id in self.pci_ids:
            full_id = utils_misc.get_full_pci_id(pci_id)
            if not full_id:
                continue
            drv_path = os.path.join(base_dir, "devices/%s/driver" % full_id)
            dev_prev_driver = os.path.realpath(os.path.join(drv_path,
                                               os.readlink(drv_path)))
            self.dev_drivers[pci_id] = dev_prev_driver

            # Judge whether the device driver has been binded to stub
            if not self.is_binded_to_stub(full_id):
                error.context("Bind device %s to stub" % full_id, logging.info)
                vendor_id = utils_misc.get_vendor_from_pci_id(pci_id)
                stub_new_id = os.path.join(stub_path, 'new_id')
                unbind_dev = os.path.join(drv_path, 'unbind')
                stub_bind = os.path.join(stub_path, 'bind')

                info_write_to_files = [(vendor_id, stub_new_id),
                                       (full_id, unbind_dev),
                                       (full_id, stub_bind)]

                for content, file in info_write_to_files:
                    try:
                        utils.open_write_close(file, content)
                    except IOError:
                        logging.debug("Failed to write %s to file %s", content,
                                      file)
                        continue

                if not self.is_binded_to_stub(full_id):
                    logging.error("Binding device %s to stub failed", pci_id)
                    continue
            else:
                logging.debug("Device %s already binded to stub", pci_id)
            requested_pci_ids.append(pci_id)
        return requested_pci_ids
Example #12
0
 def count_log(self, string):
     '''returns count of the 'string' in log'''
     count = 0
     try:
         f = open(self.log)
     except IOError:
         utils.open_write_close(self.log, 'Cron automation\n')
         f = open(self.log)
     for i in f.readlines():
         if string in i:
             count = count + 1
     f.close()
     return count
Example #13
0
    def execute_cpu(self, cpu_max_prime, runtimes, args):
	base_cmd = self.srcdir + '/sysbench/sysbench --test=cpu'
        
        for prime in cpu_max_prime:
               for run in range(1,runtimes+1):
                       utils.system('echo 3 > /proc/sys/vm/drop_caches')
                       logging.info("clean caches....")
                       logging.info("===============Start sysbench cpu")
                       rcmd = base_cmd + ' --cpu-max-prime=' + str(prime)
                       self.results = utils.system_output(rcmd + ' run',retain_output=True)
                       self.results_path = os.path.join(self.resultsdir,
                                        'raw_output_%d_%d' % (prime,run))
                       utils.open_write_close(self.results_path, self.results)        
 def count_log(self, string):
     '''returns count of the 'string' in log'''
     count = 0
     try:
         f = open(self.log)
     except IOError:
         utils.open_write_close(self.log, 'Cron automation\n')
         f = open(self.log)
     for i in f.readlines():
         if string in i:
             count = count + 1
     f.close()
     return count
    def answer_kickstart(self, answer_path):
        """
        Replace KVM_TEST_CDKEY (in the unattended file) with the cdkey
        provided for this test and replace the KVM_TEST_MEDIUM with
        the tree url or nfs address provided for this test.

        :return: Answer file contents
        """
        contents = open(self.unattended_file).read()

        dummy_cdkey_re = r'\bKVM_TEST_CDKEY\b'
        if re.search(dummy_cdkey_re, contents):
            if self.cdkey:
                contents = re.sub(dummy_cdkey_re, self.cdkey, contents)

        dummy_medium_re = r'\bKVM_TEST_MEDIUM\b'
        if self.medium in ["cdrom", "kernel_initrd"]:
            content = "cdrom"

        elif self.medium == "url":
            content = "url --url %s" % self.url

        elif self.medium == "nfs":
            content = "nfs --server=%s --dir=%s" % (self.nfs_server,
                                                    self.nfs_dir)
        else:
            raise ValueError("Unexpected installation medium %s" % self.url)

        contents = re.sub(dummy_medium_re, content, contents)

        dummy_logging_re = r'\bKVM_TEST_LOGGING\b'
        if re.search(dummy_logging_re, contents):
            if self.syslog_server_enabled == 'yes':
                l = 'logging --host=%s --port=%s --level=debug'
                l = l % (self.syslog_server_ip, self.syslog_server_port)
            else:
                l = ''
            contents = re.sub(dummy_logging_re, l, contents)

        dummy_graphical_re = re.compile('GRAPHICAL_OR_TEXT')
        if dummy_graphical_re.search(contents):
            if not self.vga or self.vga.lower() == "none":
                contents = dummy_graphical_re.sub('text', contents)
            else:
                contents = dummy_graphical_re.sub('graphical', contents)

        logging.debug("Unattended install contents:")
        for line in contents.splitlines():
            logging.debug(line)

        utils.open_write_close(answer_path, contents)
    def answer_kickstart(self, answer_path):
        """
        Replace KVM_TEST_CDKEY (in the unattended file) with the cdkey
        provided for this test and replace the KVM_TEST_MEDIUM with
        the tree url or nfs address provided for this test.

        :return: Answer file contents
        """
        contents = open(self.unattended_file).read()

        dummy_cdkey_re = r'\bKVM_TEST_CDKEY\b'
        if re.search(dummy_cdkey_re, contents):
            if self.cdkey:
                contents = re.sub(dummy_cdkey_re, self.cdkey, contents)

        dummy_medium_re = r'\bKVM_TEST_MEDIUM\b'
        if self.medium in ["cdrom", "kernel_initrd"]:
            content = "cdrom"

        elif self.medium == "url":
            content = "url --url %s" % self.url

        elif self.medium == "nfs":
            content = "nfs --server=%s --dir=%s" % (self.nfs_server,
                                                    self.nfs_dir)
        else:
            raise ValueError("Unexpected installation medium %s" % self.url)

        contents = re.sub(dummy_medium_re, content, contents)

        dummy_logging_re = r'\bKVM_TEST_LOGGING\b'
        if re.search(dummy_logging_re, contents):
            if self.syslog_server_enabled == 'yes':
                l = 'logging --host=%s --port=%s --level=debug'
                l = l % (self.syslog_server_ip, self.syslog_server_port)
            else:
                l = ''
            contents = re.sub(dummy_logging_re, l, contents)

        dummy_graphical_re = re.compile('GRAPHICAL_OR_TEXT')
        if dummy_graphical_re.search(contents):
            if not self.vga or self.vga.lower() == "none":
                contents = dummy_graphical_re.sub('text', contents)
            else:
                contents = dummy_graphical_re.sub('graphical', contents)

        logging.debug("Unattended install contents:")
        for line in contents.splitlines():
            logging.debug(line)

        utils.open_write_close(answer_path, contents)
Example #17
0
    def run_once(self, num_groups=90):
        """
        Run hackbench, store the output in raw output files per iteration and
        also in the results list attribute.

        @param num_groups: Number of children processes hackbench will spawn.
        """
        hackbench_bin = os.path.join(self.srcdir, 'hackbench')
        cmd = '%s %s' % (hackbench_bin, num_groups)
        raw_output = utils.system_output(cmd, retain_output=True)
        self.results = raw_output

        path = os.path.join(self.resultsdir, 'raw_output_%s' % self.iteration)
        utils.open_write_close(path, raw_output)
Example #18
0
    def run_once(self):
        tool_node = self.check_tool_result_node()

        lptlog.info("----------开始获取测试参数")

        self.parallels = self.get_config_array(tool_node, "parallel", [1])
        lptlog.info("测试并行组: %s" % lutils.list_to_str(self.parallels))
        self.times = self.get_config_value(tool_node,
                                           "times",
                                           10,
                                           valueType=int)
        if self.times < 3:
            self.times = 10
            lptlog.warning("测试次数必须大于3, 将采用默认值10")
        lptlog.info("测试次数: %d" % self.times)

        cmd = "./Run"

        #执行测试脚本
        lptlog.info("---------运行测试脚本")

        #shutil.rmtree(self.resultsdir)
        os.chdir(self.srcdir)

        #添加测试次数
        args_list = ["-i", "%d" % self.times]

        #添加并行数
        for parallel in self.parallels:
            args_list.append("-c")
            args_list.append("%d" % parallel)
        self.mainParameters["parameters"] = " ".join([cmd] + args_list)
        #utils.run_shell2(cmd, args_list=args_list, file=os.devnull)
        #utils.system_output(cmd, args=args_list)
        #返回根目录

        vars = 'UB_TMPDIR="%s" UB_RESULTDIR="%s"' % (self.tmpdir,
                                                     self.resultsdir)
        self.report_data = utils.system_output(vars + ' %s ' % cmd +
                                               ' '.join(args_list))
        self.results_path = os.path.join(self.resultsdir,
                                         'raw_output_%s' % self.iteration)
        utils.open_write_close(self.results_path, self.report_data)

        #数据处理
        self.create_result()
        self.save_results_to_xml()
        #create txt report
        self.txt_report()
Example #19
0
    def execute_mem(self, num_threads, runtimes, block_size, total_size, args):
	base_cmd = self.srcdir + '/sysbench/sysbench --test=memory'
	
	for num_thread in num_threads:
		for run in range(1,runtimes+1):
			utils.system('echo 3 > /proc/sys/vm/drop_caches')
                        logging.info("clean caches....")
			logging.info("==============Start sysbench memory %d threads test for %dth =======" % (num_thread,run))
			rcmd = base_cmd + ' --num-threads=' + str(num_thread) + \
					' --memory-block-size=' + block_size + \
					' --memory-total-size='	+ total_size
			self.results = utils.system_output(rcmd + ' run',retain_output=True)
			self.results_path = os.path.join(self.resultsdir,
                                         'raw_output_%d_%d' % (num_thread,run))
                        utils.open_write_close(self.results_path, self.results)
Example #20
0
    def log_per_reboot_data(self):
        """ Logging hook called whenever a job starts, and again after
        any reboot. """
        logdir = self._get_boot_subdir(next=True)
        if not os.path.exists(logdir):
            os.mkdir(logdir)

        for log in (self.test_loggables | self.boot_loggables):
            log.run(logdir)

        if _LOG_INSTALLED_PACKAGES:
            # also log any installed packages
            installed_path = os.path.join(logdir, "installed_packages")
            installed_packages = "\n".join(self.sm.list_all()) + "\n"
            utils.open_write_close(installed_path, installed_packages)
Example #21
0
    def log_per_reboot_data(self):
        """ Logging hook called whenever a job starts, and again after
        any reboot. """
        logdir = self._get_boot_subdir(next=True)
        if not os.path.exists(logdir):
            os.mkdir(logdir)

        for log in (self.test_loggables | self.boot_loggables):
            log.run(logdir)

        if _LOG_INSTALLED_PACKAGES:
            # also log any installed packages
            installed_path = os.path.join(logdir, "installed_packages")
            installed_packages = "\n".join(self.sm.list_all()) + "\n"
            utils.open_write_close(installed_path, installed_packages)
    def run_once(self, args=''):

        vars = 'UB_TMPDIR="%s" UB_RESULTDIR="%s"' % (self.tmpdir,
                                                     self.resultsdir)
        os.chdir(self.srcdir)
        if not args:
            args = 'gindex'
      
        self.report_data = utils.system_output('export DISPLAY=:0.0;'+ vars + ' ./Run ' + args)
        self.results_path = os.path.join(self.resultsdir,
                                         'raw_output_%s' % self.iteration)
        utils.open_write_close(self.results_path, self.report_data)
        if self.iteration == 3 :
            os.chdir(self.bindir)
            utils.system('./unixbench.sh')
Example #23
0
 def run_once(self):
     """
     Runs a single iteration of the FFSB.
     """
     self.dup_ffsb_profilefl()
     # Run FFSB using abspath
     cmd = '%s/ffsb %s/profile.cfg' % (self.srcdir, self.srcdir)
     logging.info("FFSB command: %s", cmd)
     self.results_path = os.path.join(self.resultsdir,
                                      'raw_output_%s' % self.iteration)
     try:
         self.results = utils.system_output(cmd, retain_output=True)
         logging.info(self.results)
         utils.open_write_close(self.results_path, self.results)
     except error.CmdError, e:
         self.nfail += 1
         logging.error('Failed to execute FFSB : %s', e)
Example #24
0
 def run_once(self):
     """
     Runs a single iteration of the FFSB.
     """
     self.dup_ffsb_profilefl()
     # Run FFSB using abspath
     cmd = '%s/ffsb %s/profile.cfg' % (self.srcdir, self.srcdir)
     logging.info("FFSB command: %s", cmd)
     self.results_path = os.path.join(self.resultsdir,
                                      'raw_output_%s' % self.iteration)
     try:
         self.results = utils.system_output(cmd, retain_output=True)
         logging.info(self.results)
         utils.open_write_close(self.results_path, self.results)
     except error.CmdError, e:
         self.nfail += 1
         logging.error('Failed to execute FFSB : %s', e)
Example #25
0
    def run_once(self):
        tool_node = self.check_tool_result_node()

        lptlog.info("----------开始获取测试参数")

        self.parallels =  self.get_config_array(tool_node, "parallel", [1])
        lptlog.info("测试并行组: %s" % lutils.list_to_str(self.parallels))
        self.times = self.get_config_value(tool_node, "times", 10, valueType=int)
        if self.times < 3:
            self.times = 10
            lptlog.warning("测试次数必须大于3, 将采用默认值10")
        lptlog.info("测试次数: %d" % self.times)

        cmd = "./Run"

        #执行测试脚本
        lptlog.info("---------运行测试脚本")

	#shutil.rmtree(self.resultsdir)
        os.chdir(self.srcdir)

        #添加测试次数
        args_list=["-i", "%d" %self.times]

        #添加并行数
        for parallel in self.parallels:
            args_list.append("-c")
            args_list.append("%d" % parallel)
        self.mainParameters["parameters"] = " ".join([cmd]+args_list)
        #utils.run_shell2(cmd, args_list=args_list, file=os.devnull)
        #utils.system_output(cmd, args=args_list)
         #返回根目录

        vars = 'UB_TMPDIR="%s" UB_RESULTDIR="%s"' % (self.tmpdir,
                                                     self.resultsdir)
        self.report_data = utils.system_output(vars + ' %s ' % cmd  + ' '.join(args_list))
        self.results_path = os.path.join(self.resultsdir,
                                         'raw_output_%s' % self.iteration)
        utils.open_write_close(self.results_path, self.report_data)

        #数据处理
        self.create_result()
        self.save_results_to_xml()
        #create txt report
        self.txt_report()
Example #26
0
    def log_before_each_test(self, test):
        """ Logging hook called before a test starts. """
        if _LOG_INSTALLED_PACKAGES:
            self._installed_packages = self.sm.list_all()
            # Also log the list of installed packaged before each test starts
            test_sysinfodir = self._get_sysinfodir(test.outputdir)
            installed_path = os.path.join(test_sysinfodir, "installed_packages")
            installed_packages = "\n".join(self._installed_packages)
            utils.open_write_close(installed_path, installed_packages)

        if os.path.exists("/var/log/messages"):
            stat = os.stat("/var/log/messages")
            self._messages_size = stat.st_size
            self._messages_inode = stat.st_ino
        elif os.path.exists("/var/log/syslog"):
            stat = os.stat("/var/log/syslog")
            self._messages_size = stat.st_size
            self._messages_inode = stat.st_ino
Example #27
0
    def log_before_each_test(self, test):
        """ Logging hook called before a test starts. """
        if _LOG_INSTALLED_PACKAGES:
            self._installed_packages = self.sm.list_all()
            # Also log the list of installed packaged before each test starts
            test_sysinfodir = self._get_sysinfodir(test.outputdir)
            installed_path = os.path.join(test_sysinfodir, "installed_packages")
            installed_packages = "\n".join(self._installed_packages)
            utils.open_write_close(installed_path, installed_packages)

        if os.path.exists("/var/log/messages"):
            stat = os.stat("/var/log/messages")
            self._messages_size = stat.st_size
            self._messages_inode = stat.st_ino
        elif os.path.exists("/var/log/syslog"):
            stat = os.stat("/var/log/syslog")
            self._messages_size = stat.st_size
            self._messages_inode = stat.st_ino
Example #28
0
    def run_once(self, dir=None, args=None):
        if not dir:
            self.dir = self.tmpdir
        else:
            self.dir = dir
        if not args:
            self.args = '--block=4096 --block=8192 --threads=10 --size=1024 --numruns=2'
        else:
            self.args = args

        os.chdir(self.srcdir)
        results = utils.system_output('./tiobench.pl --dir %s %s' %
                                      (self.dir, self.args))

        logging.info(results)
        results_path = os.path.join(self.resultsdir,
                                    'raw_output_%s' % self.iteration)

        utils.open_write_close(results_path, results)
Example #29
0
    def run_once(self, dir=None, args=None):
        if not dir:
            self.dir = self.tmpdir
        else:
            self.dir = dir
        if not args:
            self.args = '--block=4096 --block=8192 --threads=10 --size=1024 --numruns=2'
        else:
            self.args = args

        os.chdir(self.srcdir)
        results = utils.system_output('./tiobench.pl --dir %s %s' %
                                      (self.dir, self.args))

        logging.info(results)
        results_path = os.path.join(self.resultsdir,
                                    'raw_output_%s' % self.iteration)

        utils.open_write_close(results_path, results)
    def execute_mysql(self, num_threads, db_pw, table_size, runtimes, read_only, args):

	utils.system('service mysqld restart')
        # Wait for database to start
        time.sleep(5)

        try:
            base_cmd = self.srcdir + '/sysbench/sysbench --test=oltp ' + \
                                     '--mysql-user=root --mysql-table-engine=innodb ' + \
				     '--mysql-host=localhost --mysql-password='******' --mysql-socket=/var/lib/mysql/mysql.sock ' + \
				     '--oltp-table-size=' + str(table_size)
	    
	    for num_thread in num_threads:
            	utils.system('echo "create database sbtest;" | ' + 'mysql -u root -p%s' % db_pw)
            	pcmd = base_cmd + ' prepare'
            	utils.system(pcmd)
		for run in range(1,runtimes+1):
	        	logging.info("===============Start sysbench %d threads test for %dth============" % (num_thread,run))
            		rcmd = base_cmd + \
                		' --num-threads=' + str(num_thread) + \
                		' --mysql-db=sbtest --mysql-engine-trx=yes' + \
                		' --db-ps-mode=disable'

            		if read_only:
                		rcmd = rcmd + ' --oltp-read-only=on'

            		self.results = utils.system_output(rcmd + ' run',
                                                    retain_output=True)
			self.results_path = os.path.join(self.resultsdir,
                                         'raw_output_%d_%d' % (num_thread,run))
			utils.open_write_close(self.results_path, self.results)

	        utils.system(base_cmd + ' cleanup')
		utils.system('echo "drop database sbtest;" | ' + 'mysql -u root -p%s' % db_pw)

        except Exception:
    	    ccmd = base_cmd + ' cleanup'
            utils.system(ccmd)
            utils.system('echo "drop database sbtest;" | ' + 'mysql -u root -p%s' % db_pw)
            raise
Example #31
0
 def init_create(self):
     try:
         os.mkdir(self.archive)
         os.mkdir(self.archive + '/d_one')
         os.mkdir(self.archive + '/d_two')
         os.mkdir(self.archive + '/d_three')
         utils.open_write_close(self.archive + '/d_one/f_one', 'file 1')
         utils.open_write_close(self.archive + '/d_one/f_two', 'file 2')
         utils.open_write_close(self.archive + '/d_one/f_three', 'file 3')
         os.mkdir(self.archive + '/d_two/d_four')
         utils.open_write_close(self.archive + '/d_one/f_four', 'file 4')
     except Exception as e:
         logging.error(e)
         self.nfail += 1
Example #32
0
 def init_create(self):
     try:
         os.mkdir(self.archive)
         os.mkdir(self.archive + '/d_one')
         os.mkdir(self.archive + '/d_two')
         os.mkdir(self.archive + '/d_three')
         utils.open_write_close(self.archive + '/d_one/f_one', 'file 1')
         utils.open_write_close(self.archive + '/d_one/f_two', 'file 2')
         utils.open_write_close(self.archive + '/d_one/f_three', 'file 3')
         os.mkdir(self.archive + '/d_two/d_four')
         utils.open_write_close(self.archive + '/d_one/f_four', 'file 4')
     except Exception as e:
         logging.error(e)
         self.nfail += 1
    def run_once(self, testdir=None, args='', cthon_iterations=1):
        """
        Runs the test, with the appropriate control file.
        """
        os.chdir(self.srcdir)

        if testdir is None:
            testdir = self.tmpdir

        self.results_path = os.path.join(self.resultsdir,
                                         'raw_output_%s' % self.iteration)

        try:
            if not args:
                # run basic test
                args = "-b -t"

            self.results = utils.system_output('./runtests -N %s %s %s' % (cthon_iterations, args, testdir))
            utils.open_write_close(self.results_path, self.results)

        except error.CmdError, e:
            self.nfail += 1
            logging.error("Test failed: %s", e)
Example #34
0
    def log_after_each_test(self, test):
        """ Logging hook called after a test finishs. """
        test_sysinfodir = self._get_sysinfodir(test.outputdir)

        # create a symlink in the test sysinfo dir to the current boot
        reboot_dir = self._get_boot_subdir()
        assert os.path.exists(reboot_dir)
        symlink_dest = os.path.join(test_sysinfodir, "reboot_current")
        symlink_src = utils.get_relative_path(reboot_dir,
                                              os.path.dirname(symlink_dest))
        try:
            os.symlink(symlink_src, symlink_dest)
        except Exception as e:
            raise Exception('%s: whilst linking %s to %s' % (e, symlink_src,
                                                             symlink_dest))

        # run all the standard logging commands
        for log in self.test_loggables:
            log.run(test_sysinfodir)

        # grab any new data from the system log
        self._log_messages(test_sysinfodir)

        # log some sysinfo data into the test keyval file
        keyval = self.log_test_keyvals(test_sysinfodir)
        test.write_test_keyval(keyval)

        if _LOG_INSTALLED_PACKAGES:
            # log any changes to installed packages
            old_packages = set(self._installed_packages)
            new_packages = set(self.sm.list_all())
            added_path = os.path.join(test_sysinfodir, "added_packages")
            added_packages = "\n".join(new_packages - old_packages) + "\n"
            utils.open_write_close(added_path, added_packages)
            removed_path = os.path.join(test_sysinfodir, "removed_packages")
            removed_packages = "\n".join(old_packages - new_packages) + "\n"
            utils.open_write_close(removed_path, removed_packages)
Example #35
0
    def run_once(self, dir=None, args=None):
        """
        Runs IOzone with appropriate parameters, record raw results in a per
        iteration raw output file as well as in the results attribute

        @param dir: IOzone file generation dir.
        @param args: Arguments to the iozone program.
        @param fstype: Type of file system to test
        """
        if not dir:
            dir = self.tmpdir
        os.chdir(dir)
        if not args:
            args = '-a'
        cmd = os.path.join(self.srcdir, 'src', 'current', 'iozone')
        self.results = utils.system_output('%s %s' % (cmd, args))
        self.auto_mode = ("-a" in args)

        self.results_path = os.path.join(self.resultsdir,
                                         'raw_output_%s' % self.iteration)
        self.analysisdir = os.path.join(self.resultsdir,
                                        'analysis_%s' % self.iteration)

        utils.open_write_close(self.results_path, self.results)
Example #36
0
    def run_once(self, testdir=None, args='', cthon_iterations=1):
        """
        Runs the test, with the appropriate control file.
        """
        os.chdir(self.srcdir)

        if testdir is None:
            testdir = self.tmpdir

        self.results_path = os.path.join(self.resultsdir,
                                         'raw_output_%s' % self.iteration)

        try:
            if not args:
                # run basic test
                args = "-b -t"

            self.results = utils.system_output(
                './runtests -N %s %s %s' % (cthon_iterations, args, testdir))
            utils.open_write_close(self.results_path, self.results)

        except error.CmdError, e:
            self.nfail += 1
            logging.error("Test failed: %s", e)
Example #37
0
    def run_once(self, dir=None, args=None):
        """
        Runs IOzone with appropriate parameters, record raw results in a per
        iteration raw output file as well as in the results attribute

        @param dir: IOzone file generation dir.
        @param args: Arguments to the iozone program.
        """
        if not dir:
            dir = self.tmpdir
        os.chdir(dir)
        if not args:
            args = '-a'

        cmd = os.path.join(self.srcdir, 'src', 'current', 'iozone')
        self.results = utils.system_output('%s %s' % (cmd, args))
        self.auto_mode = ("-a" in args)

        self.results_path = os.path.join(self.resultsdir,
                                         'raw_output_%s' % self.iteration)
        self.analysisdir = os.path.join(self.resultsdir,
                                        'analysis_%s' % self.iteration)

        utils.open_write_close(self.results_path, self.results)
Example #38
0
 def __write_file(self, file_name, data):
     path = os.path.join(self.__base_path, file_name)
     utils.open_write_close(path, data)
Example #39
0
def run(test, params, env):
    """
    Run IOzone for windows on a windows guest:
    1) Log into a guest
    2) Execute the IOzone test contained in the winutils.iso
    3) Get results
    4) Postprocess it with the IOzone postprocessing module

    :param test: kvm test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """
    def post_result(results_path, analysisdir):
        """
        Pick results from an IOzone run, generate a series graphs

        :params results_path: iozone test result path
        :params analysisdir: output of analysis result
        """
        a = postprocess_iozone.IOzoneAnalyzer(list_files=[results_path],
                                              output_dir=analysisdir)
        a.analyze()
        p = postprocess_iozone.IOzonePlotter(results_file=results_path,
                                             output_dir=analysisdir)
        p.plot_all()

    def get_driver():
        """
        Get driver name
        """
        driver_name = params.get("driver_name", "")
        drive_format = params.get("drive_format")
        if not driver_name:
            if "scsi" in drive_format:
                driver_name = "vioscsi"
            elif "virtio" in drive_format:
                driver_name = "viostor"
            else:
                driver_name = None
        return driver_name

    timeout = int(params.get("login_timeout", 360))
    iozone_timeout = int(params.get("iozone_timeout"))
    disk_letter = params["disk_letter"]
    disk_index = params.get("disk_index", "2")
    results_path = os.path.join(test.resultsdir,
                                'raw_output_%s' % test.iteration)
    analysisdir = os.path.join(test.resultsdir, 'analysis_%s' % test.iteration)

    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()

    driver_name = get_driver()
    if driver_name:
        utils_test.qemu.setup_win_driver_verifier(driver_name, vm, timeout)

    session = vm.wait_for_login(timeout=timeout)
    if params.get("format_disk", "no") == "yes":
        error_context.context("Format disk", logging.info)
        utils_misc.format_windows_disk(session,
                                       disk_index,
                                       mountpoint=disk_letter)
    winutils = utils_misc.get_winutils_vol(session)
    cmd = params["iozone_cmd"]
    iozone_cmd = re.sub("WIN_UTILS", winutils, cmd)
    error_context.context(
        "Running IOzone command on guest, timeout %ss" % iozone_timeout,
        logging.info)

    status, results = session.cmd_status_output(cmd=iozone_cmd,
                                                timeout=iozone_timeout)
    error_context.context("Write results to %s" % results_path, logging.info)
    if status != 0:
        raise exceptions.TestFail("iozone test failed: %s" % results)
    utils.open_write_close(results_path, results)

    if params.get("post_result", "no") == "yes":
        error_context.context("Generate graph of test result", logging.info)
        post_result(results_path, analysisdir)
Example #40
0
class base_sysinfo(object):
    def __init__(self, job_resultsdir):
        self.sysinfodir = self._get_sysinfodir(job_resultsdir)

        # pull in the post-test logs to collect
        self.test_loggables = set()
        for cmd in _DEFAULT_COMMANDS_TO_LOG_PER_TEST:
            self.test_loggables.add(command(cmd))
        for filename in _DEFAULT_FILES_TO_LOG_PER_TEST:
            self.test_loggables.add(logfile(filename))

        # pull in the EXTRA post-boot logs to collect
        self.boot_loggables = set()
        for cmd in _DEFAULT_COMMANDS_TO_LOG_PER_BOOT:
            self.boot_loggables.add(command(cmd))
        for filename in _DEFAULT_FILES_TO_LOG_PER_BOOT:
            self.boot_loggables.add(logfile(filename))

        # pull in the pre test iteration logs to collect
        self.before_iteration_loggables = set()
        for cmd in _DEFAULT_COMMANDS_TO_LOG_BEFORE_ITERATION:
            self.before_iteration_loggables.add(
                command(cmd, logf=cmd.replace(" ", "_") + '.before'))
        for fname in _DEFAULT_FILES_TO_LOG_BEFORE_ITERATION:
            self.before_iteration_loggables.add(
                logfile(fname, logf=os.path.basename(fname) + '.before'))

        # pull in the post test iteration logs to collect
        self.after_iteration_loggables = set()
        for cmd in _DEFAULT_COMMANDS_TO_LOG_AFTER_ITERATION:
            self.after_iteration_loggables.add(
                command(cmd, logf=cmd.replace(" ", "_") + '.after'))
        for fname in _DEFAULT_FILES_TO_LOG_AFTER_ITERATION:
            self.after_iteration_loggables.add(
                logfile(fname, logf=os.path.basename(fname) + '.after'))

        # add in a couple of extra files and commands we want to grab
        self.test_loggables.add(command("df -mP", logf="df"))
        # We compress the dmesg because it can get large when kernels are
        # configured with a large buffer and some tests trigger OOMs or
        # other large "spam" that fill it up...
        self.test_loggables.add(
            command("dmesg -c", logf="dmesg", compress_log=True))
        self.boot_loggables.add(logfile("/proc/cmdline", log_in_keyval=True))
        # log /proc/mounts but with custom filename since we already
        # log the output of the "mount" command as the filename "mount"
        self.boot_loggables.add(logfile('/proc/mounts', logf='proc_mounts'))
        self.boot_loggables.add(
            command("uname -a", logf="uname", log_in_keyval=True))
        self.sm = software_manager.SoftwareManager()

    def __getstate__(self):
        ret = dict(self.__dict__)
        ret["sm"] = None
        return ret

    def serialize(self):
        return {"boot": self.boot_loggables, "test": self.test_loggables}

    def deserialize(self, serialized):
        self.boot_loggables = serialized["boot"]
        self.test_loggables = serialized["test"]

    @staticmethod
    def _get_sysinfodir(resultsdir):
        sysinfodir = os.path.join(resultsdir, "sysinfo")
        if not os.path.exists(sysinfodir):
            os.makedirs(sysinfodir)
        return sysinfodir

    def _get_reboot_count(self):
        if not glob.glob(os.path.join(self.sysinfodir, "*")):
            return -1
        else:
            return len(glob.glob(os.path.join(self.sysinfodir, "boot.*")))

    def _get_boot_subdir(self, next=False):
        reboot_count = self._get_reboot_count()
        if next:
            reboot_count += 1
        if reboot_count < 1:
            return self.sysinfodir
        else:
            boot_dir = "boot.%d" % (reboot_count - 1)
            return os.path.join(self.sysinfodir, boot_dir)

    def _get_iteration_subdir(self, test, iteration):
        iter_dir = "iteration.%d" % iteration

        logdir = os.path.join(self._get_sysinfodir(test.outputdir), iter_dir)
        if not os.path.exists(logdir):
            os.mkdir(logdir)
        return logdir

    @log.log_and_ignore_errors("post-reboot sysinfo error:")
    def log_per_reboot_data(self):
        """ Logging hook called whenever a job starts, and again after
        any reboot. """
        logdir = self._get_boot_subdir(next=True)
        if not os.path.exists(logdir):
            os.mkdir(logdir)

        for log in (self.test_loggables | self.boot_loggables):
            log.run(logdir)

        if _LOG_INSTALLED_PACKAGES:
            # also log any installed packages
            installed_path = os.path.join(logdir, "installed_packages")
            installed_packages = "\n".join(self.sm.list_all()) + "\n"
            utils.open_write_close(installed_path, installed_packages)

    @log.log_and_ignore_errors("pre-test sysinfo error:")
    def log_before_each_test(self, test):
        """ Logging hook called before a test starts. """
        if _LOG_INSTALLED_PACKAGES:
            self._installed_packages = self.sm.list_all()
        if os.path.exists("/var/log/messages"):
            stat = os.stat("/var/log/messages")
            self._messages_size = stat.st_size
            self._messages_inode = stat.st_ino
        elif os.path.exists("/var/log/syslog"):
            stat = os.stat("/var/log/syslog")
            self._messages_size = stat.st_size
            self._messages_inode = stat.st_ino

    @log.log_and_ignore_errors("post-test sysinfo error:")
    def log_after_each_test(self, test):
        """ Logging hook called after a test finishs. """
        test_sysinfodir = self._get_sysinfodir(test.outputdir)

        # create a symlink in the test sysinfo dir to the current boot
        reboot_dir = self._get_boot_subdir()
        assert os.path.exists(reboot_dir)
        symlink_dest = os.path.join(test_sysinfodir, "reboot_current")
        symlink_src = utils.get_relative_path(reboot_dir,
                                              os.path.dirname(symlink_dest))
        try:
            os.symlink(symlink_src, symlink_dest)
        except Exception, e:
            raise Exception, '%s: whilst linking %s to %s' % (e, symlink_src,
                                                              symlink_dest)

        # run all the standard logging commands
        for log in self.test_loggables:
            log.run(test_sysinfodir)

        # grab any new data from the system log
        self._log_messages(test_sysinfodir)

        # log some sysinfo data into the test keyval file
        keyval = self.log_test_keyvals(test_sysinfodir)
        test.write_test_keyval(keyval)

        if _LOG_INSTALLED_PACKAGES:
            # log any changes to installed packages
            old_packages = set(self._installed_packages)
            new_packages = set(self.sm.list_all())
            added_path = os.path.join(test_sysinfodir, "added_packages")
            added_packages = "\n".join(new_packages - old_packages) + "\n"
            utils.open_write_close(added_path, added_packages)
            removed_path = os.path.join(test_sysinfodir, "removed_packages")
            removed_packages = "\n".join(old_packages - new_packages) + "\n"
            utils.open_write_close(removed_path, removed_packages)
 def trace_config(self, path, value):
     """
     Write value to a tracing config file under self.tracing_dir.
     """
     path = os.path.join(self.tracing_dir, path)
     utils.open_write_close(path, value)
Example #42
0
 def trace_config(self, path, value):
     """
     Write value to a tracing config file under self.tracing_dir.
     """
     path = os.path.join(self.tracing_dir, path)
     utils.open_write_close(path, value)
Example #43
0
                                  logging.info)
            try:
                session = utils_test.qemu.setup_win_driver_verifier(
                          session, driver_name, vm, timeout)
                funcatexit.register(env, params.get("type"),
                                    utils_test.qemu.clear_win_driver_verifier,
                                    session, vm, timeout)
            except Exception, e:
                raise exceptions.TestFail(e)

    if params.get("format_disk", "no") == "yes":
        error_context.context("Format disk", logging.info)
        utils_misc.format_windows_disk(session, disk_index,
                                       mountpoint=disk_letter)
    winutils = utils_misc.get_winutils_vol(session)
    cmd = params["iozone_cmd"]
    iozone_cmd = re.sub("WIN_UTILS", winutils, cmd)
    error_context.context("Running IOzone command on guest, timeout %ss"
                          % iozone_timeout, logging.info)

    status, results = session.cmd_status_output(cmd=iozone_cmd,
                                                timeout=iozone_timeout)
    error_context.context("Write results to %s" % results_path, logging.info)
    if status != 0:
        raise exceptions.TestFail("iozone test failed: %s" % results)
    utils.open_write_close(results_path, results)

    if params.get("post_result", "no") == "yes":
        error_context.context("Generate graph of test result", logging.info)
        post_result(results_path, analysisdir)
Example #44
0
                session = utils_test.qemu.setup_win_driver_verifier(
                    session, driver_name, vm, timeout)
                funcatexit.register(env, params.get("type"),
                                    utils_test.qemu.clear_win_driver_verifier,
                                    session, vm, timeout)
            except Exception, e:
                raise exceptions.TestFail(e)

    if params.get("format_disk", "no") == "yes":
        error_context.context("Format disk", logging.info)
        utils_misc.format_windows_disk(session,
                                       disk_index,
                                       mountpoint=disk_letter)
    winutils = utils_misc.get_winutils_vol(session)
    cmd = params["iozone_cmd"]
    iozone_cmd = re.sub("WIN_UTILS", winutils, cmd)
    error_context.context(
        "Running IOzone command on guest, timeout %ss" % iozone_timeout,
        logging.info)

    status, results = session.cmd_status_output(cmd=iozone_cmd,
                                                timeout=iozone_timeout)
    error_context.context("Write results to %s" % results_path, logging.info)
    if status != 0:
        raise exceptions.TestFail("iozone test failed: %s" % results)
    utils.open_write_close(results_path, results)

    if params.get("post_result", "no") == "yes":
        error_context.context("Generate graph of test result", logging.info)
        post_result(results_path, analysisdir)
Example #45
0
def run(test, params, env):
    """
    Run IOzone for windows on a windows guest:
    1) Log into a guest
    2) Execute the IOzone test contained in the winutils.iso
    3) Get results
    4) Postprocess it with the IOzone postprocessing module

    :param test: kvm test object
    :param params: Dictionary with the test parameters
    :param env: Dictionary with test environment.
    """

    def post_result(results_path, analysisdir):
        """
        Pick results from an IOzone run, generate a series graphs

        :params results_path: iozone test result path
        :params analysisdir: output of analysis result
        """
        a = postprocess_iozone.IOzoneAnalyzer(list_files=[results_path],
                                              output_dir=analysisdir)
        a.analyze()
        p = postprocess_iozone.IOzonePlotter(results_file=results_path,
                                             output_dir=analysisdir)
        p.plot_all()

    def get_driver():
        """
        Get driver name
        """
        driver_name = params.get("driver_name", "")
        drive_format = params.get("drive_format")
        if not driver_name:
            if "scsi" in drive_format:
                driver_name = "vioscsi"
            elif "virtio" in drive_format:
                driver_name = "viostor"
            else:
                driver_name = None
        return driver_name

    timeout = int(params.get("login_timeout", 360))
    iozone_timeout = int(params.get("iozone_timeout"))
    disk_letter = params["disk_letter"]
    disk_index = params.get("disk_index", "2")
    results_path = os.path.join(test.resultsdir,
                                'raw_output_%s' % test.iteration)
    analysisdir = os.path.join(test.resultsdir, 'analysis_%s' % test.iteration)

    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()

    driver_name = get_driver()
    if driver_name:
        utils_test.qemu.setup_win_driver_verifier(driver_name, vm, timeout)

    session = vm.wait_for_login(timeout=timeout)
    if params.get("format_disk", "no") == "yes":
        error_context.context("Format disk", logging.info)
        utils_misc.format_windows_disk(session, disk_index,
                                       mountpoint=disk_letter)
    winutils = utils_misc.get_winutils_vol(session)
    cmd = params["iozone_cmd"]
    iozone_cmd = re.sub("WIN_UTILS", winutils, cmd)
    error_context.context("Running IOzone command on guest, timeout %ss"
                          % iozone_timeout, logging.info)

    status, results = session.cmd_status_output(cmd=iozone_cmd,
                                                timeout=iozone_timeout)
    error_context.context("Write results to %s" % results_path, logging.info)
    if status != 0:
        raise exceptions.TestFail("iozone test failed: %s" % results)
    utils.open_write_close(results_path, results)

    if params.get("post_result", "no") == "yes":
        error_context.context("Generate graph of test result", logging.info)
        post_result(results_path, analysisdir)