Home | History | Annotate | Download | only in tests
      1 import logging, os
      2 from autotest_lib.client.common_lib import error
      3 from autotest_lib.client.bin import utils
      4 
      5 
      6 def run_clock_getres(test, params, env):
      7     """
      8     Verify if guests using kvm-clock as the time source have a sane clock
      9     resolution.
     10 
     11     @param test: kvm test object.
     12     @param params: Dictionary with test parameters.
     13     @param env: Dictionary with the test environment.
     14     """
     15     source_name = "test_clock_getres/test_clock_getres.c"
     16     source_name = os.path.join(test.bindir, "deps", source_name)
     17     dest_name = "/tmp/test_clock_getres.c"
     18     bin_name = "/tmp/test_clock_getres"
     19 
     20     if not os.path.isfile(source_name):
     21         raise error.TestError("Could not find %s" % source_name)
     22 
     23     vm = env.get_vm(params["main_vm"])
     24     vm.verify_alive()
     25     timeout = int(params.get("login_timeout", 360))
     26     session = vm.wait_for_login(timeout=timeout)
     27 
     28     vm.copy_files_to(source_name, dest_name)
     29     session.cmd("gcc -lrt -o %s %s" % (bin_name, dest_name))
     30     session.cmd(bin_name)
     31     logging.info("PASS: Guest reported appropriate clock resolution")
     32     logging.info("Guest's dmesg:\n%s", session.cmd_output("dmesg").strip())
     33