rv_fullscreen.py 3.3 KB
Newer Older
V
Vimal Patel 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
"""
rv_fullscreen.py - remote-viewer full screen
                   Testing the remote-viewer --full-screen option
                   If successfull, the resolution of the guest will
                   take the resolution of the client.

Requires: connected binaries remote-viewer, Xorg, gnome session

"""
import logging
from autotest.client.shared import error
from virttest.aexpect import ShellCmdError


def run_rv_fullscreen(test, params, env):
    """
    Tests the --full-screen option
    Positive test: full_screen param = yes, verify guest res = client res
    Negative test: full_screen param= no, verify guest res != client res

21
    @param test: QEMU test object.
V
Vimal Patel 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
    @param params: Dictionary with the test parameters.
    @param env: Dictionary with test environment.
    """
    # Get the parameters needed for the test
    full_screen = params.get("full_screen")
    guest_vm = env.get_vm(params["guest_vm"])
    client_vm = env.get_vm(params["client_vm"])

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

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

    # Get the resolution of the client & guest
    logging.info("Getting the Resolution on the client")
    client_session.cmd("export DISPLAY=:0.0")

    try:
43 44
        client_session.cmd("xrandr | grep '*' >/tmp/res")
        client_res_raw = client_session.cmd("cat /tmp/res|awk '{print $1}'")
V
Vimal Patel 已提交
45 46 47 48 49 50 51 52 53 54 55 56
        client_res = client_res_raw.split()[0]
    except ShellCmdError:
        raise error.TestFail("Could not get guest resolution, xrandr output:" +
                             " %s" % client_res_raw)
    except IndexError:
        raise error.TestFail("Could not get guest resolution, xrandr output:" +
                             " %s" % client_res_raw)

    logging.info("Getting the Resolution on the guest")
    guest_session.cmd("export DISPLAY=:0.0")

    try:
57 58
        guest_session.cmd("xrandr | grep '*' >/tmp/res")
        guest_res_raw = guest_session.cmd("cat /tmp/res|awk '{print $1}'")
V
Vimal Patel 已提交
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
        guest_res = guest_res_raw.split()[0]
    except ShellCmdError:
        raise error.TestFail("Could not get guest resolution, xrandr output:" +
                             " %s" % guest_res_raw)
    except IndexError:
        raise error.TestFail("Could not get guest resolution, xrandr output:" +
                             " %s" % guest_res_raw)

    logging.info("Here's the information I have: ")
    logging.info("\nClient Resolution: " + client_res)
    logging.info("\nGuest Resolution: " + guest_res)

    # Positive Test, verify the guest takes the resolution of the client
    if full_screen == "yes":
        if(client_res == guest_res):
            logging.info("PASS: Guest resolution is the same as the client")
        else:
76
            raise error.TestFail("Guest resolution differs from the client")
V
Vimal Patel 已提交
77 78 79 80 81
    # Negative Test, verify the resolutions are not equal
    elif full_screen == "no":
        if(client_res != guest_res):
            logging.info("PASS: Guest resolution differs from the client")
        else:
82
            raise error.TestFail("Guest resolution is the same as the client")
V
Vimal Patel 已提交
83 84 85 86 87
    else:
        raise error.TestFail("The test setup is incorrect.")

    client_session.close()
    guest_session.close()