Exemplo n.º 1
0
def run_fullscreen_setup(test, params, env):
    """
    Simple test for Remote Desktop connection
    Tests expectes that Remote Desktop client (spice/vnc) will be executed
    from within a second guest so we won't be limited to Linux only clients

    The plan is to support remote-viewer at first place

    @param test: QEMU test object.
    @param params: Dictionary with the test parameters.
    @param env: Dictionary with test environment.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
            timeout=int(params.get("login_timeout", 360)))

    logging.debug("Exporting guest display")
    guest_session.cmd("export DISPLAY=:0.0")
    utils_spice.launch_startx(guest_vm)

    # Get the min, current, and max resolution on the guest
    output = guest_session.cmd("xrandr | grep Screen")
    outputlist = output.split()

    minimum = "640x480"

    current_index = outputlist.index("current")
    current = outputlist[current_index + 1]
    current += outputlist[current_index + 2]
    # Remove trailing comma
    current += outputlist[current_index + 3].replace(",", "")

    maximum = "2560x1600"

    logging.info("Minimum: " + minimum + " Current: " + current +
                 " Maximum: " + maximum)
    if(current != minimum):
        resolution = minimum
    else:
        resolution = maximum

    # Changing the guest resolution
    guest_session.cmd("xrandr -s " + resolution)
    logging.info("The resolution on the guest has been changed from " +
                 current + " to: " + resolution)

    # Start vdagent daemon
    utils_spice.start_vdagent(guest_session, test_timeout)

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()
    client_session = client_vm.wait_for_login(
            timeout=int(params.get("login_timeout", 360)))

    client_session.close()
    guest_session.close()
Exemplo n.º 2
0
def copy_and_paste_cpdisabled_neg(session_to_copy_from, session_to_paste_to,
                                  guest_session, params):
    """
    Negative Test: Sending the commands to copy from one session to another,
    for this test cp/paste will be disabled from qemu-kvm, Verify with vdagent
    started that copy/paste will fail.

    @param session_to_copy_from: ssh session of the vm to copy from
    @param session_to_paste_to: ssh session of the vm to paste to
    @param guest_session: guest ssh session
    @param params: Dictionary with the test parameters.
    """
    #Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_params = params.get("script_params", "")
    dst_path = params.get("dst_dir", "guest_script")
    script_call = os.path.join(dst_path, script)
    testing_text = params.get("text_to_test")

    # Before doing the copy and paste, verify vdagent is installed and the
    # daemon is running on the guest
    utils_spice.verify_vdagent(guest_session, test_timeout)
    # Stop vdagent for this negative test
    utils_spice.start_vdagent(guest_session, test_timeout)
    # Make sure virtio driver is running
    utils_spice.verify_virtio(guest_session, test_timeout)
    # Command to copy text and put it in the keyboard, copy on the client
    place_text_in_clipboard(session_to_copy_from, interpreter, script_call,
                            script_params, testing_text, test_timeout)
    # Now test to see if the copied text from the one session can be pasted
    # on the other session
    verify_paste_fails(session_to_paste_to, testing_text, interpreter,
                       script_call, test_timeout)
Exemplo n.º 3
0
def copy_and_paste_pos(session_to_copy_from, session_to_paste_to,
                       guest_session, params):
    """
    Sending the commands to copy from one session to another, and make
    sure it works correctly

    @param session_to_copy_from: ssh session of the vm to copy from
    @param session_to_paste_to: ssh session of the vm to paste to
    @param guest_session: guest ssh session
    @param params: Dictionary with the test parameters.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_params = params.get("script_params", "")
    dst_path = params.get("dst_dir", "guest_script")
    script_call = os.path.join(dst_path, script)
    testing_text = params.get("text_to_test")

    # Before doing the copy and paste, verify vdagent is
    # installed and the daemon is running on the guest
    utils_spice.verify_vdagent(guest_session, test_timeout)
    # Start vdagent daemon
    utils_spice.start_vdagent(guest_session, test_timeout)
    # Make sure virtio driver is running
    utils_spice.verify_virtio(guest_session, test_timeout)
    # Command to copy text and put it in the keyboard, copy on the client
    place_text_in_clipboard(session_to_copy_from, interpreter, script_call,
                            script_params, testing_text, test_timeout)
    # Now test to see if the copied text from the one session can be
    # pasted on the other
    verify_paste_successful(session_to_paste_to, testing_text, interpreter,
                            script_call, test_timeout)
Exemplo n.º 4
0
def copy_and_paste_pos(session_to_copy_from, session_to_paste_to,
                       guest_session, params):
    """
    Sending the commands to copy from one session to another, and make
    sure it works correctly

    @param session_to_copy_from: ssh session of the vm to copy from
    @param session_to_paste_to: ssh session of the vm to paste to
    @param guest_session: guest ssh session
    @param params: Dictionary with the test parameters.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_params = params.get("script_params", "")
    dst_path = params.get("dst_dir", "guest_script")
    script_call = os.path.join(dst_path, script)
    testing_text = params.get("text_to_test")

    # Before doing the copy and paste, verify vdagent is
    # installed and the daemon is running on the guest
    utils_spice.verify_vdagent(guest_session, test_timeout)
    # Start vdagent daemon
    utils_spice.start_vdagent(guest_session, test_timeout)
    # Make sure virtio driver is running
    utils_spice.verify_virtio(guest_session, test_timeout)
    # Command to copy text and put it in the keyboard, copy on the client
    place_text_in_clipboard(session_to_copy_from, interpreter, script_call,
                            script_params, testing_text, test_timeout)
    # Now test to see if the copied text from the one session can be
    # pasted on the other
    verify_paste_successful(session_to_paste_to, testing_text, interpreter,
                            script_call, test_timeout)
Exemplo n.º 5
0
def copy_and_paste_cpdisabled_neg(session_to_copy_from, session_to_paste_to,
                                  guest_session, params):
    """
    Negative Test: Sending the commands to copy from one session to another,
    for this test cp/paste will be disabled from qemu-kvm, Verify with vdagent
    started that copy/paste will fail.

    @param session_to_copy_from: ssh session of the vm to copy from
    @param session_to_paste_to: ssh session of the vm to paste to
    @param guest_session: guest ssh session
    @param params: Dictionary with the test parameters.
    """
    #Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_params = params.get("script_params", "")
    dst_path = params.get("dst_dir", "guest_script")
    script_call = os.path.join(dst_path, script)
    testing_text = params.get("text_to_test")

    # Before doing the copy and paste, verify vdagent is installed and the
    # daemon is running on the guest
    utils_spice.verify_vdagent(guest_session, test_timeout)
    # Stop vdagent for this negative test
    utils_spice.start_vdagent(guest_session, test_timeout)
    # Make sure virtio driver is running
    utils_spice.verify_virtio(guest_session, test_timeout)
    # Command to copy text and put it in the keyboard, copy on the client
    place_text_in_clipboard(session_to_copy_from, interpreter, script_call,
                            script_params, testing_text, test_timeout)
    # Now test to see if the copied text from the one session can be pasted
    # on the other session
    verify_paste_fails(session_to_paste_to, testing_text, interpreter,
                       script_call, test_timeout)
Exemplo n.º 6
0
def run_fullscreen_setup(test, params, env):
    """
    Simple test for Remote Desktop connection
    Tests expectes that Remote Desktop client (spice/vnc) will be executed
    from within a second guest so we won't be limited to Linux only clients

    The plan is to support remote-viewer at first place

    @param test: QEMU test object.
    @param params: Dictionary with the test parameters.
    @param env: Dictionary with test environment.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    logging.debug("Exporting guest display")
    guest_session.cmd("export DISPLAY=:0.0")
    utils_spice.launch_startx(guest_vm)

    # Get the min, current, and max resolution on the guest
    output = guest_session.cmd("xrandr | grep Screen")
    outputlist = output.split()

    minimum = "640x480"

    current_index = outputlist.index("current")
    current = outputlist[current_index + 1]
    current += outputlist[current_index + 2]
    # Remove trailing comma
    current += outputlist[current_index + 3].replace(",", "")

    maximum = "2560x1600"

    logging.info("Minimum: " + minimum + " Current: " + current +
                 " Maximum: " + maximum)
    if (current != minimum):
        resolution = minimum
    else:
        resolution = maximum

    # Changing the guest resolution
    guest_session.cmd("xrandr -s " + resolution)
    logging.info("The resolution on the guest has been changed from " +
                 current + " to: " + resolution)

    # Start vdagent daemon
    utils_spice.start_vdagent(guest_session, test_timeout)

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()
    client_session = client_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    client_session.close()
    guest_session.close()
Exemplo n.º 7
0
def copy_and_paste_largetext(session_to_copy_from, session_to_paste_to, guest_session, params):
    """
    Sending the commands to copy large text from one session to another, and
    make sure the data is still correct.

    @param session_to_copy_from: ssh session of the vm to copy from
    @param session_to_paste_to: ssh session of the vm to paste to
    @param guest_session: guest ssh session
    @param params: Dictionary with the test parameters.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_write_params = params.get("script_params_writef")
    script_create_params = params.get("script_params_createf")
    dst_path = params.get("dst_dir", "guest_script")
    final_text_path = os.path.join(params.get("dst_dir"), params.get("final_textfile"))
    script_call = os.path.join(dst_path, script)
    string_length = params.get("text_to_test")

    # Before doing the copy and paste, verify vdagent is
    # installed and the daemon is running on the guest
    utils_spice.verify_vdagent(guest_session, test_timeout)
    # Start vdagent
    utils_spice.start_vdagent(guest_session, test_timeout)
    # Make sure virtio driver is running
    utils_spice.verify_virtio(guest_session, test_timeout)

    # Command to copy text and put it in the clipboard
    textfile_checksum = verify_text_copy(
        session_to_copy_from,
        interpreter,
        script_call,
        script_create_params,
        string_length,
        final_text_path,
        test_timeout,
    )
    wait_timeout(30)

    # Verify the paste on the session to paste to
    verify_txt_paste_success(
        session_to_paste_to,
        interpreter,
        script_call,
        script_write_params,
        final_text_path,
        textfile_checksum,
        test_timeout,
    )
Exemplo n.º 8
0
def copyandpasteimg_cpdisabled_neg(session_to_copy_from, session_to_paste_to,
                                       guest_session, params):
    """
    Negative Tests Sending the commands to copy an image from one
    session to another; however, copy-paste will be disabled on the VM
    so the pasting should fail.

    @param session_to_copy_from: ssh session of the vm to copy from
    @param session_to_paste_to: ssh session of the vm to paste to
    @param guest_session: guest ssh session
    @param params: Dictionary with the test parameters.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_set_params = params.get("script_params_img_set")
    script_save_params = params.get("script_params_img_save")
    dst_path = params.get("dst_dir", "guest_script")
    dst_image_path = os.path.join(params.get("dst_dir"),
                                  params.get("image_tocopy_name"))
    final_image_path = os.path.join(params.get("dst_dir"),
                                    params.get("final_image"))
    script_call = os.path.join(dst_path, script)

    # Before doing the copy and paste, verify vdagent is
    # installed and the daemon is running on the guest
    utils_spice.verify_vdagent(guest_session, test_timeout)
    # Stop vdagent for this negative test
    utils_spice.start_vdagent(guest_session, test_timeout)
    # Make sure virtio driver is running
    utils_spice.verify_virtio(guest_session, test_timeout)
    wait_timeout()
    # Command to copy text and put it in the keyboard, copy on the client
    place_img_in_clipboard(session_to_copy_from, interpreter, script_call,
                            script_set_params, dst_image_path, test_timeout)
    # Now test to see if the copied text from the one session can be
    # pasted on the other
    verify_img_paste(session_to_copy_from, interpreter,
                                  script_call, script_save_params,
                                  final_image_path, test_timeout)
    wait_timeout(30)

    # Verify the paste on the session to paste to
    verify_img_paste_fails(session_to_paste_to, interpreter,
                             script_call, script_save_params,
                             final_image_path, test_timeout)
Exemplo n.º 9
0
def copyandpasteimg_cpdisabled_neg(session_to_copy_from, session_to_paste_to,
                                   guest_session, params):
    """
    Negative Tests Sending the commands to copy an image from one
    session to another; however, copy-paste will be disabled on the VM
    so the pasting should fail.

    @param session_to_copy_from: ssh session of the vm to copy from
    @param session_to_paste_to: ssh session of the vm to paste to
    @param guest_session: guest ssh session
    @param params: Dictionary with the test parameters.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_set_params = params.get("script_params_img_set")
    script_save_params = params.get("script_params_img_save")
    dst_path = params.get("dst_dir", "guest_script")
    dst_image_path = os.path.join(params.get("dst_dir"),
                                  params.get("image_tocopy_name"))
    final_image_path = os.path.join(params.get("dst_dir"),
                                    params.get("final_image"))
    script_call = os.path.join(dst_path, script)

    # Before doing the copy and paste, verify vdagent is
    # installed and the daemon is running on the guest
    utils_spice.verify_vdagent(guest_session, test_timeout)
    # Stop vdagent for this negative test
    utils_spice.start_vdagent(guest_session, test_timeout)
    # Make sure virtio driver is running
    utils_spice.verify_virtio(guest_session, test_timeout)
    wait_timeout()
    # Command to copy text and put it in the keyboard, copy on the client
    place_img_in_clipboard(session_to_copy_from, interpreter, script_call,
                           script_set_params, dst_image_path, test_timeout)
    # Now test to see if the copied text from the one session can be
    # pasted on the other
    verify_img_paste(session_to_copy_from, interpreter, script_call,
                     script_save_params, final_image_path, test_timeout)
    wait_timeout(30)

    # Verify the paste on the session to paste to
    verify_img_paste_fails(session_to_paste_to, interpreter, script_call,
                           script_save_params, final_image_path, test_timeout)
Exemplo n.º 10
0
def copy_and_paste_largetext(session_to_copy_from, session_to_paste_to,
                             guest_session, params):
    """
    Sending the commands to copy large text from one session to another, and
    make sure the data is still correct.

    @param session_to_copy_from: ssh session of the vm to copy from
    @param session_to_paste_to: ssh session of the vm to paste to
    @param guest_session: guest ssh session
    @param params: Dictionary with the test parameters.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_write_params = params.get("script_params_writef")
    script_create_params = params.get("script_params_createf")
    dst_path = params.get("dst_dir", "guest_script")
    final_text_path = os.path.join(params.get("dst_dir"),
                                   params.get("final_textfile"))
    script_call = os.path.join(dst_path, script)
    string_length = params.get("text_to_test")

    # Before doing the copy and paste, verify vdagent is
    # installed and the daemon is running on the guest
    utils_spice.verify_vdagent(guest_session, test_timeout)
    # Stop vdagent for this negative test
    utils_spice.start_vdagent(guest_session, test_timeout)
    # Make sure virtio driver is running
    utils_spice.verify_virtio(guest_session, test_timeout)
    wait_timeout()

    # Command to copy text and put it in the clipboard
    textfile_checksum = verify_text_copy(session_to_copy_from, interpreter,
                                         script_call, script_create_params,
                                         string_length, final_text_path,
                                         test_timeout)
    wait_timeout(30)

    # Verify the paste on the session to paste to
    verify_txt_paste_success(session_to_paste_to, interpreter, script_call,
                             script_write_params, final_text_path,
                             textfile_checksum, test_timeout)
Exemplo n.º 11
0
def run(test, params, env):
    """
    Tests spice vdagent (starting, stopping, restarting, and status)

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    vdagent_test = params.get("vdagent_test")

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_root_session = guest_vm.wait_for_login(timeout=int(
        params.get("login_timeout", 360)),
                                                 username="******",
                                                 password="******")

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()
    client_session = client_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    vdagent_status = utils_spice.get_vdagent_status(guest_root_session,
                                                    test_timeout)

    # start test
    if vdagent_test == "start":
        if "running" in vdagent_status:
            # stop the service prior to starting
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
            utils_spice.start_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.start_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is running
        status = utils_spice.get_vdagent_status(guest_root_session,
                                                test_timeout)
        if "running" in status:
            pass
        else:
            raise error.TestFail(
                "Vdagent status is not running after a start attempt.")
    # stop test
    elif vdagent_test == "stop":
        if "stopped" in vdagent_status:
            # start the service prior to stopping the service
            utils_spice.start_vdagent(guest_root_session, test_timeout)
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is stopped
        status = utils_spice.get_vdagent_status(guest_root_session,
                                                test_timeout)
        if "stopped" in status:
            pass
        else:
            print "Status: " + status
            raise error.TestFail(
                "Vdagent status is not stopped after a stop attempt.")
    # restart test when vdagent service is running
    elif vdagent_test == "restart_start":
        if "stopped" in vdagent_status:
            # start the service prior to stopping the service
            utils_spice.start_vdagent(guest_root_session, test_timeout)
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is started
        status = utils_spice.get_vdagent_status(guest_root_session,
                                                test_timeout)
        if "running" in status:
            pass
        else:
            raise error.TestFail(
                "Vdagent status is not started after a restart attempt.")
    # restart test when vdagent service is stopped
    elif vdagent_test == "restart_stop":
        if "running" in vdagent_status:
            # start the service prior to stopping the service
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is started
        status = utils_spice.get_vdagent_status(guest_root_session,
                                                test_timeout)
        if "running" in status:
            pass
        else:
            raise error.TestFail(
                "Vdagent status is not started after a restart attempt.")
    else:
        raise error.TestFail("No test to run, check value of vdagent_test")

    client_session.close()
    guest_root_session.close()
Exemplo n.º 12
0
def run(test, params, env):
    """
    Tests the logging of remote-viewer

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """

    # Get the necessary parameters to run the tests
    log_test = params.get("logtest")
    qxl_logfile = params.get("qxl_log")
    spicevdagent_logfile = params.get("spice_log")
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_params = params.get("script_params", "")
    dst_path = params.get("dst_dir", "guest_script")
    script_call = os.path.join(dst_path, script)
    testing_text = params.get("text_to_test")

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))
    guest_root_session = guest_vm.wait_for_login(timeout=int(
        params.get("login_timeout", 360)),
                                                 username="******",
                                                 password="******")

    scriptdir = os.path.join("scripts", script)
    script_path = utils_misc.get_path(test.virtdir, scriptdir)

    # Copying the clipboard script to the guest to test spice vdagent
    logging.info(
        "Transferring the clipboard script to the guest,"
        "destination directory: %s, source script location: %s", dst_path,
        script_path)
    guest_vm.copy_files_to(script_path, dst_path, timeout=60)

    # Some logging tests need the full desktop environment
    guest_session.cmd("export DISPLAY=:0.0")

    # Logging test for the qxl driver
    if (log_test == 'qxl'):
        logging.info("Running the logging test for the qxl driver")
        guest_root_session.cmd("grep -i qxl " + qxl_logfile)
    # Logging test for spice-vdagent
    elif (log_test == 'spice-vdagent'):
        logging.info("Running the logging test for spice-vdagent daemon")
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)

        # Testing the log after stopping spice-vdagentd
        utils_spice.stop_vdagent(guest_root_session, test_timeout=15)
        output = guest_root_session.cmd("tail -n 3 " + spicevdagent_logfile +
                                        " | grep 'vdagentd quiting'")

        # Testing the log after starting spice-vdagentd
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)
        output = guest_root_session.cmd(
            "tail -n 2 " + spicevdagent_logfile +
            " | grep 'opening vdagent virtio channel'")

        # Testing the log after restart spice-vdagentd
        utils_spice.restart_vdagent(guest_root_session, test_timeout=10)
        output = guest_root_session.cmd(
            "tail -n 2 " + spicevdagent_logfile +
            " | grep 'opening vdagent virtio channel'")

        cmd = ("echo \"SPICE_VDAGENTD_EXTRA_ARGS=-dd\">"
               "/etc/sysconfig/spice-vdagentd")
        guest_root_session.cmd(cmd)
        utils_spice.restart_vdagent(guest_root_session, test_timeout=10)

        # Finally test copying text within the guest
        cmd = "%s %s %s %s" % (interpreter, script_call, script_params,
                               testing_text)

        logging.info("This command here: " + cmd)

        try:
            logging.debug("------------ Script output ------------")
            output = guest_session.cmd(cmd)

            if "The text has been placed into the clipboard." in output:
                logging.info("Copying of text was successful")
            else:
                raise error.TestFail("Copying to the clipboard failed ELSE",
                                     output)
        except:
            raise error.TestFail("Copying to the clipboard failed try" +
                                 " block failed")

        logging.debug("------------ End of script output of the Copying"
                      " Session ------------")

        output = guest_root_session.cmd("tail -n 3 " + spicevdagent_logfile +
                                        " | grep 'clipboard grab'")

    else:
        # Couldn't find the right test to run
        guest_session.close()
        guest_root_session.close()
        raise error.TestFail("Couldn't find the right test to run," +
                             " check cfg files.")
    guest_session.close()
Exemplo n.º 13
0
def run(test, params, env):
    """
    Simple test for Remote Desktop connection
    Tests expectes that Remote Desktop client (spice/vnc) will be executed
    from within a second guest so we won't be limited to Linux only clients

    The plan is to support remote-viewer at first place

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))

    utils_spice.wait_timeout(20)

    for vm in params.get("vms").split():
        utils_spice.clear_interface(env.get_vm(vm),
                                    int(params.get("login_timeout", "360")))

    utils_spice.wait_timeout(20)

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))
    guest_root_session = guest_vm.wait_for_login(username="******",
                                                 password="******")
    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()
    client_session = client_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))
    client_root_session = client_vm.wait_for_login(username="******",
                                                   password="******")

    logging.debug("Exporting client display")
    client_session.cmd("export DISPLAY=:0.0")

    # Get the min, current, and max resolution on the guest
    output = client_session.cmd("xrandr | grep Screen")
    outputlist = output.split()

    minimum = "640x480"

    current_index = outputlist.index("current")
    current = outputlist[current_index + 1]
    current += outputlist[current_index + 2]
    # Remove trailing comma
    current += outputlist[current_index + 3].replace(",", "")

    maximum = "2560x1600"

    logging.info("Minimum: " + minimum + " Current: " + current +
                 " Maximum: " + maximum)
    if(current != minimum):
        newClientResolution = minimum
    else:
        newClientResolution = maximum

    # Changing the guest resolution
    client_session.cmd("xrandr -s " + newClientResolution)
    logging.info("The resolution on the client has been changed from " +
                 current + " to: " + newClientResolution)

    logging.debug("Exporting guest display")
    guest_session.cmd("export DISPLAY=:0.0")

    # Get the min, current, and max resolution on the guest
    output = guest_session.cmd("xrandr | grep Screen")
    outputlist = output.split()

    current_index = outputlist.index("current")
    currentGuestRes = outputlist[current_index + 1]
    currentGuestRes += outputlist[current_index + 2]
    currentGuestRes += outputlist[current_index + 3].replace(",", "")
    logging.info("Current Resolution of Guest: " + currentGuestRes)

    if (newClientResolution == currentGuestRes):
        raise error.TestFail("Client resolution is same as guest resolution!")

    # Start vdagent daemon
    utils_spice.start_vdagent(guest_root_session, test_timeout)

    client_session.close()
    guest_session.close()
Exemplo n.º 14
0
def restart_cppaste_image(session_to_copy_from, session_to_paste_to, guest_session, params):
    """
    Sending the commands to copy an image from one session to another.

    @param session_to_copy_from: ssh session of the vm to copy from
    @param session_to_paste_to: ssh session of the vm to paste to
    @param guest_session: guest ssh session
    @param params: Dictionary with the test parameters.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    image_type = params.get("image_type")
    script_set_params = params.get("script_params_img_set")
    script_save_params = params.get("script_params_img_save")
    dst_path = params.get("dst_dir", "guest_script")
    dst_image_path = os.path.join(params.get("dst_dir"), params.get("image_tocopy_name"))
    dst_image_path_bmp = os.path.join(params.get("dst_dir"), params.get("image_tocopy_name_bmp"))
    final_image_path = os.path.join(params.get("dst_dir"), params.get("final_image"))
    final_image_path_bmp = os.path.join(params.get("dst_dir"), params.get("final_image_bmp"))
    script_call = os.path.join(dst_path, script)

    # Before doing the copy and paste, verify vdagent is
    # installed and the daemon is running on the guest
    utils_spice.verify_vdagent(guest_session, test_timeout)
    # Start vdagent
    utils_spice.start_vdagent(guest_session, test_timeout)
    # Make sure virtio driver is running
    utils_spice.verify_virtio(guest_session, test_timeout)

    if "png" in image_type:
        # Command to copy text and put it in the keyboard, copy on the client
        place_img_in_clipboard(
            session_to_copy_from, interpreter, script_call, script_set_params, dst_image_path, test_timeout
        )
        # Now test to see if the copied text from the one session can be
        # pasted on the other
        image_size = verify_img_paste(
            session_to_copy_from, interpreter, script_call, script_save_params, final_image_path, test_timeout
        )
        wait_timeout(30)

        # Verify the paste on the session to paste to
        verify_img_paste_success(
            session_to_paste_to,
            interpreter,
            script_call,
            script_save_params,
            final_image_path,
            image_size,
            test_timeout,
        )
    else:
        # Testing bmp
        place_img_in_clipboard(
            session_to_copy_from, interpreter, script_call, script_set_params, dst_image_path_bmp, test_timeout
        )

        # Now test to see if the copied text from the one session can be
        # pasted on the other
        image_size = verify_img_paste(
            session_to_copy_from, interpreter, script_call, script_save_params, final_image_path_bmp, test_timeout
        )
        wait_timeout(30)

        # Verify the paste on the session to paste to
        verify_img_paste_success(
            session_to_paste_to,
            interpreter,
            script_call,
            script_save_params,
            final_image_path_bmp,
            image_size,
            test_timeout,
        )
    # Restart vdagent & clear the clipboards.
    utils_spice.restart_vdagent(guest_session, test_timeout)
    clear_cb(session_to_paste_to, params)
    clear_cb(session_to_copy_from, params)
    wait_timeout(5)

    if "png" in image_type:
        # Command to copy text and put it in the keyboard, copy on the client
        place_img_in_clipboard(
            session_to_copy_from, interpreter, script_call, script_set_params, dst_image_path, test_timeout
        )
        # Now test to see if the copied text from the one session can be
        # pasted on the other
        image_size = verify_img_paste(
            session_to_copy_from, interpreter, script_call, script_save_params, final_image_path, test_timeout
        )
        wait_timeout(30)

        # Verify the paste on the session to paste to
        verify_img_paste_success(
            session_to_paste_to,
            interpreter,
            script_call,
            script_save_params,
            final_image_path,
            image_size,
            test_timeout,
        )
    else:
        # Testing bmp
        place_img_in_clipboard(
            session_to_copy_from, interpreter, script_call, script_set_params, dst_image_path_bmp, test_timeout
        )

        # Now test to see if the copied text from the one session can be
        # pasted on the other
        image_size = verify_img_paste(
            session_to_copy_from, interpreter, script_call, script_save_params, final_image_path_bmp, test_timeout
        )
        wait_timeout(30)

        # Verify the paste on the session to paste to
        verify_img_paste_success(
            session_to_paste_to,
            interpreter,
            script_call,
            script_save_params,
            final_image_path_bmp,
            image_size,
            test_timeout,
        )
Exemplo n.º 15
0
def run(test, params, env):
    """
    Tests the logging of remote-viewer

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """

    # Get the necessary parameters to run the tests
    log_test = params.get("logtest")
    qxl_logfile = params.get("qxl_log")
    spicevdagent_logfile = params.get("spice_log")
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_params = params.get("script_params", "")
    dst_path = params.get("dst_dir", "guest_script")
    script_call = os.path.join(dst_path, script)
    testing_text = params.get("text_to_test")

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))
    guest_root_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)),
        username="******", password="******")

    scriptdir = os.path.join("scripts", script)
    script_path = utils_misc.get_path(test.virtdir, scriptdir)

    # Copying the clipboard script to the guest to test spice vdagent
    logging.info("Transferring the clipboard script to the guest,"
                 "destination directory: %s, source script location: %s",
                 dst_path, script_path)
    guest_vm.copy_files_to(script_path, dst_path, timeout=60)

    # Some logging tests need the full desktop environment
    guest_session.cmd("export DISPLAY=:0.0")

    # Logging test for the qxl driver
    if(log_test == 'qxl'):
        logging.info("Running the logging test for the qxl driver")
        guest_root_session.cmd("grep -i qxl " + qxl_logfile)
    # Logging test for spice-vdagent
    elif(log_test == 'spice-vdagent'):
        logging.info("Running the logging test for spice-vdagent daemon")
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)

        # Testing the log after stopping spice-vdagentd
        utils_spice.stop_vdagent(guest_root_session, test_timeout=15)
        output = guest_root_session.cmd("tail -n 3 " + spicevdagent_logfile +
                                        " | grep 'vdagentd quiting'")

        # Testing the log after starting spice-vdagentd
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)
        output = guest_root_session.cmd("tail -n 2 " + spicevdagent_logfile +
                                        " | grep 'opening vdagent virtio channel'")

        # Testing the log after restart spice-vdagentd
        utils_spice.restart_vdagent(guest_root_session, test_timeout=10)
        output = guest_root_session.cmd("tail -n 2 " + spicevdagent_logfile +
                                        " | grep 'opening vdagent virtio channel'")

        cmd = ("echo \"SPICE_VDAGENTD_EXTRA_ARGS=-dd\">"
               "/etc/sysconfig/spice-vdagentd")
        guest_root_session.cmd(cmd)
        utils_spice.restart_vdagent(guest_root_session, test_timeout=10)

        # Finally test copying text within the guest
        cmd = "%s %s %s %s" % (interpreter, script_call,
                               script_params, testing_text)

        logging.info("This command here: " + cmd)

        try:
            logging.debug("------------ Script output ------------")
            output = guest_session.cmd(cmd)

            if "The text has been placed into the clipboard." in output:
                logging.info("Copying of text was successful")
            else:
                raise error.TestFail("Copying to the clipboard failed ELSE",
                                     output)
        except:
            raise error.TestFail("Copying to the clipboard failed try" +
                                 " block failed")

        logging.debug("------------ End of script output of the Copying"
                      " Session ------------")

        output = guest_root_session.cmd("tail -n 3 " + spicevdagent_logfile +
                                        " | grep 'clipboard grab'")

    else:
        # Couldn't find the right test to run
        guest_session.close()
        guest_root_session.close()
        raise error.TestFail("Couldn't find the right test to run,"
                             + " check cfg files.")
    guest_session.close()
Exemplo n.º 16
0
def run(test, params, env):
    """
    Tests spice vdagent (starting, stopping, restarting, and status)

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    vdagent_test = params.get("vdagent_test")

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_root_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)),
        username="******", password="******")

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()
    client_session = client_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    vdagent_status = utils_spice.get_vdagent_status(
        guest_root_session, test_timeout)

    # start test
    if vdagent_test == "start":
        if "running" in vdagent_status:
            # stop the service prior to starting
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
            utils_spice.start_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.start_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is running
        status = utils_spice.get_vdagent_status(
            guest_root_session, test_timeout)
        if "running" in status:
            pass
        else:
            test.fail("Vdagent status is not running after a start attempt.")
    # stop test
    elif vdagent_test == "stop":
        if "stopped" in vdagent_status:
            # start the service prior to stopping the service
            utils_spice.start_vdagent(guest_root_session, test_timeout)
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is stopped
        status = utils_spice.get_vdagent_status(
            guest_root_session, test_timeout)
        if "stopped" in status:
            pass
        else:
            logging.error("Status: " + status)
            test.fail("Vdagent status is not stopped after a stop attempt.")
    # restart test when vdagent service is running
    elif vdagent_test == "restart_start":
        if "stopped" in vdagent_status:
            # start the service prior to stopping the service
            utils_spice.start_vdagent(guest_root_session, test_timeout)
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is started
        status = utils_spice.get_vdagent_status(
            guest_root_session, test_timeout)
        if "running" in status:
            pass
        else:
            test.fail("Vdagent status is not started after a restart attempt.")
    # restart test when vdagent service is stopped
    elif vdagent_test == "restart_stop":
        if "running" in vdagent_status:
            # start the service prior to stopping the service
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is started
        status = utils_spice.get_vdagent_status(
            guest_root_session, test_timeout)
        if "running" in status:
            pass
        else:
            test.fail("Vdagent status is not started after a restart attempt.")
    else:
        test.fail("No test to run, check value of vdagent_test")

    client_session.close()
    guest_root_session.close()
Exemplo n.º 17
0
def run(test, params, env):
    """
    Tests the logging of remote-viewer

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """

    # Get the necessary parameters to run the tests
    log_test = params.get("logtest")
    qxl_logfile = params.get("qxl_log")
    spicevdagent_logfile = params.get("spice_log")
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_params = params.get("script_params", "")
    dst_path = params.get("dst_dir", "guest_script")
    script_call = os.path.join(dst_path, script)
    testing_text = params.get("text_to_test")

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))
    guest_root_session = guest_vm.wait_for_login(timeout=int(
        params.get("login_timeout", 360)),
                                                 username="******",
                                                 password="******")

    scriptdir = os.path.join("scripts", script)
    script_path = utils_misc.get_path(test.virtdir, scriptdir)

    # Copying the clipboard script to the guest to test spice vdagent
    logging.info(
        "Transferring the clipboard script to the guest,"
        "destination directory: %s, source script location: %s", dst_path,
        script_path)
    guest_vm.copy_files_to(script_path, dst_path, timeout=60)

    # Some logging tests need the full desktop environment
    guest_session.cmd("export DISPLAY=:0.0")

    # Logging test for the qxl driver
    if (log_test == 'qxl'):
        logging.info("Running the logging test for the qxl driver")
        guest_root_session.cmd("grep -i qxl " + qxl_logfile)
    # Logging test for spice-vdagent
    elif (log_test == 'spice-vdagent'):

        # Check for RHEL6 or RHEL7
        # RHEL7 uses gsettings and RHEL6 uses gconftool-2
        try:
            release = guest_session.cmd("cat /etc/redhat-release")
            logging.info("Redhat Release: %s", release)
        except:
            test.cancel("Test is only currently supported on "
                        "RHEL and Fedora operating systems")

        if "release 7." in release:
            spice_vdagent_loginfo_cmd = "journalctl" \
                                        " SYSLOG_IDENTIFIER=spice-vdagent" \
                                        " SYSLOG_IDENTIFIER=spice-vdagentd"
        else:
            spice_vdagent_loginfo_cmd = "tail -n 10 " + spicevdagent_logfile

        cmd = ("echo \"SPICE_VDAGENTD_EXTRA_ARGS=-dd\">"
               "/etc/sysconfig/spice-vdagentd")
        guest_root_session.cmd(cmd)

        logging.info("Running the logging test for spice-vdagent daemon")
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)

        # Testing the log after stopping spice-vdagentd
        utils_spice.stop_vdagent(guest_root_session, test_timeout=15)
        cmd = spice_vdagent_loginfo_cmd + " | tail -n 3 | grep \"vdagentd quitting\""
        output = guest_root_session.cmd(cmd)
        logging.debug(output)

        # Testing the log after starting spice-vdagentd
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)
        cmd = spice_vdagent_loginfo_cmd + "| tail -n 7 | grep \"opening vdagent virtio channel\""
        output = guest_root_session.cmd(cmd)
        logging.debug(output)

        # Testing the log after restart spice-vdagentd
        utils_spice.restart_vdagent(guest_root_session, test_timeout=10)
        cmd = spice_vdagent_loginfo_cmd + "| tail -n 7 | grep 'opening vdagent virtio channel'"
        output = guest_root_session.cmd(cmd)
        logging.debug(output)

        # Finally test copying text within the guest
        cmd = "%s %s %s %s" % (interpreter, script_call, script_params,
                               testing_text)
        logging.info("This command here: %s", cmd)

        try:
            logging.debug("------------ Script output ------------")
            output = guest_session.cmd(cmd)

            if "The text has been placed into the clipboard." in output:
                logging.info("Copying of text was successful")
            else:
                test.fail("Copying to the clipboard failed. %s" % output)
        except:
            test.fail("Copying to the clipboard failed try block failed")

        logging.debug("------------ End of script output of the Copying"
                      " Session ------------")

        output = guest_root_session.cmd(spice_vdagent_loginfo_cmd +
                                        "| tail -n 2" +
                                        " | grep 'clipboard grab'")

    else:
        # Couldn't find the right test to run
        guest_session.close()
        guest_root_session.close()
        test.fail("Couldn't find the right test to run, check cfg files.")
    guest_session.close()
Exemplo n.º 18
0
def run_fullscreen_setup(test, params, env):
    """
    Simple test for Remote Desktop connection
    Tests expectes that Remote Desktop client (spice/vnc) will be executed
    from within a second guest so we won't be limited to Linux only clients

    The plan is to support remote-viewer at first place

    @param test: KVM test object.
    @param params: Dictionary with the test parameters.
    @param env: Dictionary with test environment.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
            timeout=int(params.get("login_timeout", 360)))

    try:
        guest_session.cmd("startx &", timeout=15)
    except (aexpect.ShellCmdError, aexpect.ShellStatusError):
        logging.debug("Ignoring an Exception that Occurs from calling startx")
    # Sleep while X session starts
    utils_spice.wait_timeout(15)

    logging.debug("Exporting guest display")
    guest_session.cmd("export DISPLAY=:0.0")

    # Get the min, current, and max resolution on the guest
    output = guest_session.cmd("xrandr | grep Screen")
    outputlist = output.split()

    MINindex = outputlist.index("minimum")
    minimum = outputlist[MINindex + 1]
    minimum += outputlist[MINindex + 2]
    # Remove trailing comma
    minimum += outputlist[MINindex + 3].replace(",", "")

    CURRENTindex = outputlist.index("current")
    current = outputlist[CURRENTindex + 1]
    current += outputlist[CURRENTindex + 2]
    # Remove trailing comma
    current += outputlist[CURRENTindex + 3].replace(",", "")

    MAXindex = outputlist.index("maximum")
    maximum = outputlist[MAXindex + 1]
    maximum += outputlist[MAXindex + 2]
    maximum += outputlist[MAXindex + 3]

    logging.info("Minimum: " + minimum + " Current: " + current +
                 " Maximum: " + maximum)
    if(current != minimum):
        resolution = minimum
    else:
        resolution = maximum

    # Changing the guest resolution
    guest_session.cmd("xrandr -s " + resolution)
    logging.info("The resolution on the guest has been changed from " +
                 current + " to: " + resolution)

    # Start vdagent daemon
    utils_spice.start_vdagent(guest_session, test_timeout)

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()
    client_session = client_vm.wait_for_login(
            timeout=int(params.get("login_timeout", 360)))

    client_session.close()
    guest_session.close()
Exemplo n.º 19
0
def run(test, params, env):
    """
    Tests the logging of remote-viewer

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """

    # Get the necessary parameters to run the tests
    log_test = params.get("logtest")
    qxl_logfile = params.get("qxl_log")
    spicevdagent_logfile = params.get("spice_log")
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_params = params.get("script_params", "")
    dst_path = params.get("dst_dir", "guest_script")
    script_call = os.path.join(dst_path, script)
    testing_text = params.get("text_to_test")

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))
    guest_root_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)),
        username="******", password="******")

    scriptdir = os.path.join("scripts", script)
    script_path = utils_misc.get_path(test.virtdir, scriptdir)

    # Copying the clipboard script to the guest to test spice vdagent
    logging.info("Transferring the clipboard script to the guest,"
                 "destination directory: %s, source script location: %s",
                 dst_path, script_path)
    guest_vm.copy_files_to(script_path, dst_path, timeout=60)

    # Some logging tests need the full desktop environment
    guest_session.cmd("export DISPLAY=:0.0")

    # Logging test for the qxl driver
    if(log_test == 'qxl'):
        logging.info("Running the logging test for the qxl driver")
        guest_root_session.cmd("grep -i qxl " + qxl_logfile)
    # Logging test for spice-vdagent
    elif(log_test == 'spice-vdagent'):

        # Check for RHEL6 or RHEL7
        # RHEL7 uses gsettings and RHEL6 uses gconftool-2
        try:
            release = guest_session.cmd("cat /etc/redhat-release")
            logging.info("Redhat Release: %s" % release)
        except:
            test.cancel("Test is only currently supported on "
                        "RHEL and Fedora operating systems")

        if "release 7." in release:
            spice_vdagent_loginfo_cmd = "journalctl" \
                                        " SYSLOG_IDENTIFIER=spice-vdagent" \
                                        " SYSLOG_IDENTIFIER=spice-vdagentd"
        else:
            spice_vdagent_loginfo_cmd = "tail -n 10 " + spicevdagent_logfile

        cmd = ("echo \"SPICE_VDAGENTD_EXTRA_ARGS=-dd\">"
               "/etc/sysconfig/spice-vdagentd")
        guest_root_session.cmd(cmd)

        logging.info("Running the logging test for spice-vdagent daemon")
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)

        # Testing the log after stopping spice-vdagentd
        utils_spice.stop_vdagent(guest_root_session, test_timeout=15)
        cmd = spice_vdagent_loginfo_cmd + " | tail -n 3 | grep \"vdagentd quitting\""
        output = guest_root_session.cmd(cmd)
        logging.debug(output)

        # Testing the log after starting spice-vdagentd
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)
        cmd = spice_vdagent_loginfo_cmd + "| tail -n 7 | grep \"opening vdagent virtio channel\""
        output = guest_root_session.cmd(cmd)
        logging.debug(output)

        # Testing the log after restart spice-vdagentd
        utils_spice.restart_vdagent(guest_root_session, test_timeout=10)
        cmd = spice_vdagent_loginfo_cmd + "| tail -n 7 | grep 'opening vdagent virtio channel'"
        output = guest_root_session.cmd(cmd)
        logging.debug(output)

        # Finally test copying text within the guest
        cmd = "%s %s %s %s" % (interpreter, script_call,
                               script_params, testing_text)
        logging.info("This command here: " + cmd)

        try:
            logging.debug("------------ Script output ------------")
            output = guest_session.cmd(cmd)

            if "The text has been placed into the clipboard." in output:
                logging.info("Copying of text was successful")
            else:
                test.fail("Copying to the clipboard failed. %s" % output)
        except:
            test.fail("Copying to the clipboard failed try block failed")

        logging.debug("------------ End of script output of the Copying"
                      " Session ------------")

        output = guest_root_session.cmd(spice_vdagent_loginfo_cmd + "| tail -n 2" +
                                        " | grep 'clipboard grab'")

    else:
        # Couldn't find the right test to run
        guest_session.close()
        guest_root_session.close()
        test.fail("Couldn't find the right test to run, check cfg files.")
    guest_session.close()
Exemplo n.º 20
0
def run_fullscreen_setup(test, params, env):
    """
    Simple test for Remote Desktop connection
    Tests expectes that Remote Desktop client (spice/vnc) will be executed
    from within a second guest so we won't be limited to Linux only clients

    The plan is to support remote-viewer at first place

    @param test: KVM test object.
    @param params: Dictionary with the test parameters.
    @param env: Dictionary with test environment.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    try:
        guest_session.cmd("startx &", timeout=15)
    except (aexpect.ShellCmdError, aexpect.ShellStatusError):
        logging.debug("Ignoring an Exception that Occurs from calling startx")
    # Sleep while X session starts
    utils_spice.wait_timeout(15)

    logging.debug("Exporting guest display")
    guest_session.cmd("export DISPLAY=:0.0")

    # Get the min, current, and max resolution on the guest
    output = guest_session.cmd("xrandr | grep Screen")
    outputlist = output.split()

    MINindex = outputlist.index("minimum")
    minimum = outputlist[MINindex + 1]
    minimum += outputlist[MINindex + 2]
    # Remove trailing comma
    minimum += outputlist[MINindex + 3].replace(",", "")

    CURRENTindex = outputlist.index("current")
    current = outputlist[CURRENTindex + 1]
    current += outputlist[CURRENTindex + 2]
    # Remove trailing comma
    current += outputlist[CURRENTindex + 3].replace(",", "")

    MAXindex = outputlist.index("maximum")
    maximum = outputlist[MAXindex + 1]
    maximum += outputlist[MAXindex + 2]
    maximum += outputlist[MAXindex + 3]

    logging.info("Minimum: " + minimum + " Current: " + current +
                 " Maximum: " + maximum)
    if (current != minimum):
        resolution = minimum
    else:
        resolution = maximum

    # Changing the guest resolution
    guest_session.cmd("xrandr -s " + resolution)
    logging.info("The resolution on the guest has been changed from " +
                 current + " to: " + resolution)

    # Start vdagent daemon
    utils_spice.start_vdagent(guest_session, test_timeout)

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()
    client_session = client_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    client_session.close()
    guest_session.close()