Ejemplo n.º 1
0
def run(vt_test, test_params, env):
    """Tests for Remote Desktop connection. Tests expect that remote-viewer
    will be executed from guest 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.

    Raises
    ------
    TestFail
        Test fails for expected behaviour.

    """
    test = stest.ClientGuestTest(vt_test, test_params, env)
    cfg = test.cfg
    cmd_g = test.cmd_g
    test.cmd_c.reset_gui()
    cmd_g.reset_gui()
    rv_ssn.connect(test)
    if cfg.spice_vdagent_stop_log:
        logger.info("Inspect logs for stop action.")
        if not cmd_g.vdagent_is_running():
            cmd_g.start_vdagent()
        cmd_g.stop_vdagent()
        cmd = "tail -n 3 %s | grep 'vdagentd quiting'" % cfg.vdagent_log
        test.vm_g.assn_g.cmd(cmd)
    if cfg.spice_vdagent_start_log:
        logger.info("Inspect logs for start action.")
        if cmd_g.vdagent_is_active():
            cmd_g.stop_vdagent()
        cmd_g.start_vdagent()
        cmd = "tail -n 2 %s | grep 'opening vdagent virtio channel'" % \
            cfg.vdagent_log
        test.vm_g.assn_g.cmd(cmd)
    if cfg.spice_vdagent_restart_log:
        cmd_g.restart_vdagent()
        cmd = "tail -n 2 %s | grep 'opening vdagent virtio channel'" % \
            cfg.vdagent_log
        test.vm_g.assn_g.cmd(cmd)
    if cfg.spice_vdagent_copypaste:
        # Script location: avocado-vt/shared/scripts/cb.py
        script_path = os.path.join(test.virtdir, "scripts", cfg.guest_script)
        test.vm_g.copy_files_to(script_path, cfg.dst_dir)
        cmd = ('echo "SPICE_VDAGENTD_EXTRA_ARGS=-dd > '
               '/etc/sysconfig/spice-vdagentd')
        test.vm_g.assn_g.cmd(cmd)
        cmd_g.restart_vdagent()
        script_call = os.path.join(cfg.dst_dir, cfg.guest_script)
        cmd = "%s %s %s %s" % (cfg.interpreter, script_call, cfg.script_params,
                               cfg.text_to_test)
        test.vm_g.assn_g.cmd(cmd)
        cmd = "tail -n 3 " + cfg.vdagent_log + " | grep 'clipboard grab'"
        test.vm_g.assn_g.cmd(cmd)
Ejemplo n.º 2
0
def run(vt_test, test_params, env):
    """Tests for Remote Desktop connection. Tests expect that remote-viewer
    will be executed from guest 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.

    Raises
    ------
    TestFail
        Test fails for expected behaviour.

    """
    test = stest.ClientGuestTest(vt_test, test_params, env)
    cfg = test.cfg
    cmd_g = test.cmd_g
    test.cmd_c.reset_gui()
    cmd_g.reset_gui()
    rv_ssn.connect(test)
    if cfg.spice_vdagent_stop_log:
        logger.info("Inspect logs for stop action.")
        if not cmd_g.vdagent_is_running():
            cmd_g.start_vdagent()
        cmd_g.stop_vdagent()
        cmd = "tail -n 3 %s | grep 'vdagentd quiting'" % cfg.vdagent_log
        vm_g.assn_g.cmd(cmd)
    if cfg.spice_vdagent_start_log:
        logger.info("Inspect logs for start action.")
        if cmd_g.vdagent_is_active():
            cmd_g.stop_vdagent()
        .cmd_g.start_vdagent()
        cmd = "tail -n 2 %s | grep 'opening vdagent virtio channel'" % \
            cfg.vdagent_log
        vm_g.assn_g.cmd(cmd)
    if cfg.spice_vdagent_restart_log:
        cmd_g.restart_vdagent()
        cmd = "tail -n 2 %s | grep 'opening vdagent virtio channel'" % \
            cfg.vdagent_log
        vm_g.assn_g.cmd(cmd)
    if cfg.spice_vdagent_copypaste:
        # Script location: avocado-vt/shared/scripts/cb.py
        script_path = os.path.join(test.virtdir, "scripts", cfg.guest_script)
        vm_g.copy_files_to(script_path, cfg.dst_dir)
        cmd = 'echo "SPICE_VDAGENTD_EXTRA_ARGS=-dd > /etc/sysconfig/spice-vdagentd'
        vm_g.assn_g.cmd(cmd)
        cmd_g.restart_vdagent()
        script_call = os.path.join(cfg.dst_dir, cfg.guest_script)
        cmd = "%s %s %s %s" % (cfg.interpreter, script_call, cfg.script_params,
                               cfg.text_to_test)
        vm_g.assn_g.cmd(cmd)
        cmd = "tail -n 3 " + cfg.vdagent_log + " | grep 'clipboard grab'"
        vm_g.assn_g.cmd(cmd)
Ejemplo n.º 3
0
def run(vt_test, test_params, env):
    """Playback of audio stream tests for remote-viewer.

    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.

    Raises
    ------
    TestFail
        Test fails for expected behaviour.

    """
    test = stest.ClientGuestTest(vt_test, test_params, env)
    cfg = test.cfg
    act.reset_gui(test.vmi_c)
    act.reset_gui(test.vmi_g)
    # Get default sink at the client.
    cmd = r"pacmd stat | grep 'Default sink name' | " \
        r"sed -e 's/^.*[[:space:]]//'"
    try:
        def_sink = test.ssn_c.cmd(cmd).rstrip('\r\n')
    except aexpect.ShellCmdError as excp:
        raise utils.SpiceTestFail(test, "Test failed: %s" % str(excp))
    logging.info("Default sink at client is: %s", def_sink)
    # Create RV session
    env = {}
    if cfg.rv_record:
        env["PULSE_SOURCE"] = "%s.monitor" % def_sink
    try:
        rv_ssn.connect(test, env=env)
    except rv_ssn.RVSessionError as excp:
        raise utils.SpiceTestFail(test, str(excp))
    ret, out = commands.getstatusoutput(MAKE_WAV)
    if ret:
        errmsg = "Cannot generate specimen WAV file: %s" % out
        raise utils.SpiceTestFail(test, errmsg)
    play_cmd = "aplay %s &> /dev/null &" % cfg.audio_tgt
    rec_cmd = "arecord -d %s -f cd %s" % (cfg.audio_time,
                                          cfg.audio_rec)
    # Check test type
    if cfg.rv_record:
        logging.info("Recording test. Player is client. Recorder is guest.")
        player = test.ssn_c
        recorder = test.ssn_g
        vm_recorder = test.vm_g
        vm_player = test.vm_c
    else:
        logging.info("Playback test. Player is guest. Recorder is client.")
        env_var = "PULSE_SOURCE=%s.monitor" % def_sink
        rec_cmd = env_var + " " + rec_cmd
        player = test.ssn_g
        recorder = test.ssn_c
        vm_recorder = test.vm_c
        vm_player = test.vm_g
    vm_player.copy_files_to(SPECIMEN_FILE, cfg.audio_tgt)
    player.cmd(play_cmd)
    if cfg.config_test == "migration":
        bguest = utils_misc.InterruptedThread(test.vm_g.migrate, kwargs={})
        bguest.start()
    try:
        recorder.cmd(rec_cmd, timeout=500)
    except aexpect.ShellCmdError as excp:
        raise utils.SpiceTestFail(test, str(excp))
    if cfg.config_test == "migration":
        bguest.join()
    vm_recorder.copy_files_from(cfg.audio_rec, RECORDED_FILE)
    if not verify_recording(RECORDED_FILE, cfg):
        raise utils.SpiceTestFail(test, "Cannot verify recorded file.")
    # Test pass
    utils.finish_test(test)