提交 c11ed208 编写于 作者: J Jonas Eriksson

time drift test: Avoid build if available

Tested by running: check_clock_offset.with_syscall
Signed-off-by: NJonas Eriksson <jonas.eriksson@enea.com>
上级 536fcdb3
......@@ -18,8 +18,6 @@ def run(test, params, env):
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
build_cmd = params.get("build_cmd", "gcc -lrt clktest.c -o clktest")
test_cmd = params.get("test_cmd", "./clktest")
check_timeout = int(params.get("check_timeout", "600"))
tmp_dir = params.get("tmp_dir", "/tmp")
......@@ -28,15 +26,18 @@ def run(test, params, env):
timeout = int(params.get("login_timeout", 360))
session = vm.wait_for_login(timeout=timeout)
src_dir = os.path.join(data_dir.get_deps_dir(), 'timedrift')
src_file = os.path.join(src_dir, "clktest.c")
dst_file = os.path.join(tmp_dir, "clktest.c")
error.context("transfer '%s' to guest('%s')" % (src_file, dst_file),
logging.info)
vm.copy_files_to(src_file, tmp_dir, timeout=120)
error.context("build binary file 'clktest'", logging.info)
session.cmd(build_cmd)
test_cmd = params.get("test_cmd", "./clktest")
if session.get_command_status("test -x %s" % test_cmd):
src_dir = os.path.join(data_dir.get_deps_dir(), 'timedrift')
src_file = os.path.join(src_dir, "clktest.c")
dst_file = os.path.join(tmp_dir, "clktest.c")
error.context("transfer '%s' to guest('%s')" % (src_file, dst_file),
logging.info)
vm.copy_files_to(src_file, tmp_dir, timeout=120)
build_cmd = params.get("build_cmd", "gcc -lrt clktest.c -o clktest")
error.context("build binary file 'clktest'", logging.info)
session.cmd(build_cmd)
error.context("check clock offset via `clktest`", logging.info)
logging.info("set check timeout to %s seconds", check_timeout)
......
......@@ -28,12 +28,17 @@ def run(test, params, env):
drift_threshold = float(params.get("drift_threshold"))
interval = float(params.get("interval"))
cpu_chk_cmd = params.get("cpu_chk_cmd")
tsc_cmd_guest = params.get("tsc_cmd_guest", "./a.out")
tsc_cmd_host = params.get("tsc_cmd_host", "./a.out")
tsc_freq_path = os.path.join(data_dir.get_deps_dir(),
'timedrift/get_tsc.c')
host_freq = 0
def get_tsc(machine="host", i=0):
cmd = "taskset -c %s ./a.out" % i
tsc_cmd = tsc_cmd_guest
if tsc_cmd == "host":
tsc_cmd = tsc_cmd_host
cmd = "taskset %s %s" % (1 << i, tsc_cmd)
if machine == "host":
s, o = commands.getstatusoutput(cmd)
else:
......@@ -48,7 +53,9 @@ def run(test, params, env):
session = vm.wait_for_login(timeout=int(params.get("login_timeout", 360)))
commands.getoutput("gcc %s" % tsc_freq_path)
if not os.path.exists(tsc_cmd_guest):
commands.getoutput("gcc %s" % tsc_freq_path)
ncpu = local_host.LocalHost().get_num_cpu()
logging.info("Interval is %s" % interval)
......@@ -66,9 +73,10 @@ def run(test, params, env):
host_freq += delta / ncpu
logging.info("Average frequency of host's cpus: %s" % host_freq)
vm.copy_files_to(tsc_freq_path, '/tmp/get_tsc.c')
if session.get_command_status("gcc /tmp/get_tsc.c") != 0:
raise error.TestError("Fail to compile program on guest")
if session.get_command_status("test -x %s" % tsc_cmd_guest):
vm.copy_files_to(tsc_freq_path, '/tmp/get_tsc.c')
if session.get_command_status("gcc /tmp/get_tsc.c") != 0:
raise error.TestError("Fail to compile program on guest")
s, guest_ncpu = session.get_command_status_output(cpu_chk_cmd)
if s != 0:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册