Exemple #1
0
def run(vt_test, test_params, env):
    """Run remote-viewer at client VM.

    Parameters
    ----------
    vt_test : avocado.core.plugins.vt.VirtTest
        QEMU test object.
    test_params : virttest.utils_params.Params
        Dictionary with the test parameters.
    env : virttest.utils_env.Env
        Dictionary with test environment.

    """
    test = stest.ClientGuestTest(vt_test, test_params, env)
    cfg = test.cfg
    act.x_active(test.vmi_c)
    act.x_active(test.vmi_g)
    ssn = act.new_ssn(test.vmi_c)
    act.rv_connect(test.vmi_c, ssn)
    act.clear_cb(test.vmi_g)
    act.clear_cb(test.vmi_c)
    if cfg.vdagent_action:
        act.service_vdagent(test.vmi_g, cfg.vdagent_action)
    if cfg.guest2client:
        src = test.vmi_g
        dst = test.vmi_c
    elif cfg.client2guest:
        src = test.vmi_c
        dst = test.vmi_g
    success = False
    if cfg.copy_text:
        act.text2cb(src, cfg.text)
        text = act.cb2text(dst)
        if cfg.text in text:
            success = True
    elif cfg.copy_text_big:
        act.gen_text2cb(src, cfg.kbytes)
        act.cb2file(src, cfg.dump_file)
        md5src = act.md5sum(src, cfg.dump_file)
        act.cb2file(dst, cfg.dump_file)
        md5dst = act.md5sum(dst, cfg.dump_file)
        if md5src == md5dst:
            success = True
    elif cfg.copy_img:
        dst_img = os.path.join(act.dst_dir(src), cfg.test_image)
        act.imggen(src, dst_img, cfg.test_image_size)
        act.img2cb(src, dst_img)
        act.cb2img(src, cfg.dump_img)
        act.cb2img(dst, cfg.dump_img)
        md5src = act.md5sum(src, cfg.dump_img)
        md5dst = act.md5sum(dst, cfg.dump_img)
        if md5src == md5dst:
            success = True

    if cfg.negative and success \
        or not cfg.negative and not success:
        raise utils.SpiceTestFail(test, "Test failed.")

    pass
Exemple #2
0
def chk_deps(vmi, fname, dst_dir=None):
    if not dst_dir:
        dst_dir = act.dst_dir(vmi)
    dst_path = os.path.join(dst_dir, fname)
    cmd = utils.Cmd("test", "-e", dst_path)
    status, _ = act.rstatus(vmi, cmd)
    if status != 0:
        act.cp_deps(vmi, fname, dst_path)
    return dst_path
Exemple #3
0
def cp_file(vmi, src_fpath, dst_fpath=None, dst_dir=None, dst_fname=None):
    """Copy file from host system to VM's workdir.
    """
    if not dst_fpath:
        if not dst_dir:
            dst_dir = act.dst_dir(vmi)
        fname = ntpath.basename(src_fpath)
        dst_fpath = os.path.join(dst_dir, fname)
    vmi.vm.copy_files_to(src_fpath, dst_fpath)
    return dst_fpath
Exemple #4
0
def cp_file(vmi, src_fpath, dst_fpath=None, dst_dir=None, dst_fname=None):
    """Copy file from host system to VM's workdir.
    """
    if not dst_fpath:
        if not dst_dir:
            dst_dir = act.dst_dir(vmi)
        if not dst_fname:
            dst_fname = ntpath.basename(src_fpath)
        dst_fpath = os.path.join(dst_dir, dst_fname)
    vmi.vm.copy_files_to(src_fpath, dst_fpath)
    return dst_fpath
Exemple #5
0
def cp2vm(vmi, src, dst_dir=None, dst_name=None):
    if not dst_dir:
        dst_dir = act.dst_dir(vmi)
    provider_dir = asset.get_test_provider_subdirs(backend="spice")[0]
    src = os.path.normpath(src)
    src_path = os.path.join(provider_dir, src)
    if not dst_name:
        dst_name = src
    dst_path = os.path.join(dst_dir, dst_name)
    utils.info(vmi, "Copy: %s to %s", src_path, dst_path)
    vmi.vm.copy_files_to(src_path, dst_dir)
    return dst_path
Exemple #6
0
def run(vt_test, test_params, env):
    """Run remote-viewer at client VM.

    Parameters
    ----------
    vt_test : avocado.core.plugins.vt.VirtTest
        QEMU test object.
    test_params : virttest.utils_params.Params
        Dictionary with the test parameters.
    env : virttest.utils_env.Env
        Dictionary with test environment.

    """
    test = stest.ClientGuestTest(vt_test, test_params, env)
    cfg = test.cfg
    act.x_active(test.vmi_c)
    act.x_active(test.vmi_g)
    ssn = act.new_ssn(test.vmi_c, dogtail_ssn=test.vmi_c.vm.is_rhel8())
    act.rv_connect(test.vmi_c, ssn)
    act.clear_cb(test.vmi_g)
    act.clear_cb(test.vmi_c)
    if cfg.vdagent_action:
        if cfg.vdagent_action == "stop":
            act.service_vdagent(test.vmi_g, "mask")
        act.service_vdagent(test.vmi_g, cfg.vdagent_action)
    if cfg.guest2client:
        src = test.vmi_g
        dst = test.vmi_c
    elif cfg.client2guest:
        src = test.vmi_c
        dst = test.vmi_g
    success = False
    if cfg.copy_text:
        act.text2cb(src, cfg.text)
        try:
            text = act.cb2text(dst)
        except aexpect.exceptions.ShellCmdError:
            logger.info('Cannot paste from buffer.')
        else:
            if cfg.text in text:
                success = True
    elif cfg.copy_text_big:
        act.gen_text2cb(src, cfg.kbytes)
        act.cb2file(src, cfg.dump_file)
        md5src = act.md5sum(src, cfg.dump_file)
        try:
            act.cb2file(dst, cfg.dump_file)
        except aexpect.exceptions.ShellCmdError:
            logger.info('Cannot paste from buffer.')
        else:
            md5dst = act.md5sum(dst, cfg.dump_file)
            if md5src == md5dst:
                success = True
    elif cfg.copy_img:
        dst_img = os.path.join(act.dst_dir(src), cfg.test_image)
        act.imggen(src, dst_img, cfg.test_image_size)
        act.img2cb(src, dst_img)
        act.cb2img(src, cfg.dump_img)
        try:
            act.cb2img(dst, cfg.dump_img)
        except aexpect.exceptions.ShellCmdError:
            logger.info('Cannot paste from buffer.')
        else:
            md5src = act.md5sum(src, cfg.dump_img)
            md5dst = act.md5sum(dst, cfg.dump_img)
            if md5src == md5dst:
                success = True

    if cfg.negative and success or not cfg.negative and not success:
        raise utils.SpiceTestFail(test, "Test failed.")
Exemple #7
0
def cp_deps(vmi, src, dst_dir=None):
    provider_dir = asset.get_test_provider_subdirs(backend="spice")[0]
    src_path = os.path.join(provider_dir, "deps", src)
    dst_dir = act.dst_dir(vmi)
    utils.info(vmi, "Copy from deps: %s to %s", src_path, dst_dir)
    vmi.vm.copy_files_to(src_path, dst_dir)
Exemple #8
0
def workdir(vmi):
    return act.dst_dir(vmi)