1import logging, os
2from autotest_lib.client.bin import utils
3from autotest_lib.client.tests.iozone import postprocessing
4
5
6def run_iozone_windows(test, params, env):
7    """
8    Run IOzone for windows on a windows guest:
9    1) Log into a guest
10    2) Execute the IOzone test contained in the winutils.iso
11    3) Get results
12    4) Postprocess it with the IOzone postprocessing module
13
14    @param test: kvm test object
15    @param params: Dictionary with the test parameters
16    @param env: Dictionary with test environment.
17    """
18    vm = env.get_vm(params["main_vm"])
19    vm.verify_alive()
20    timeout = int(params.get("login_timeout", 360))
21    session = vm.wait_for_login(timeout=timeout)
22    results_path = os.path.join(test.resultsdir,
23                                'raw_output_%s' % test.iteration)
24    analysisdir = os.path.join(test.resultsdir, 'analysis_%s' % test.iteration)
25
26    # Run IOzone and record its results
27    c = params.get("iozone_cmd")
28    t = int(params.get("iozone_timeout"))
29    logging.info("Running IOzone command on guest, timeout %ss", t)
30    results = session.cmd_output(cmd=c, timeout=t)
31    utils.open_write_close(results_path, results)
32
33    # Postprocess the results using the IOzone postprocessing module
34    logging.info("Iteration succeed, postprocessing")
35    a = postprocessing.IOzoneAnalyzer(list_files=[results_path],
36                                      output_dir=analysisdir)
37    a.analyze()
38    p = postprocessing.IOzonePlotter(results_file=results_path,
39                                     output_dir=analysisdir)
40    p.plot_all()
41