1import os
2from autotest_lib.client.virt import virt_test_utils
3
4
5def run_autotest(test, params, env):
6    """
7    Run an autotest test inside a guest.
8
9    @param test: kvm test object.
10    @param params: Dictionary with test parameters.
11    @param env: Dictionary with the test environment.
12    """
13    vm = env.get_vm(params["main_vm"])
14    vm.verify_alive()
15    timeout = int(params.get("login_timeout", 360))
16    session = vm.wait_for_login(timeout=timeout)
17
18    # Collect test parameters
19    timeout = int(params.get("test_timeout", 300))
20    control_path = os.path.join(test.bindir, "autotest_control",
21                                params.get("test_control_file"))
22    outputdir = test.outputdir
23
24    virt_test_utils.run_autotest(vm, session, control_path, timeout, outputdir,
25                                 params)
26