示例#1
0
def test_seq(test, send_keys, expected_keysyms):
    ssn = act.klogger_start(test.vmi_g)
    for i in send_keys:
        test.vm_c.send_key(i)
    logged_keys = act.klogger_stop(test.vmi_g, ssn)
    keysyms = map(lambda (ignore, keysym): keysym, logged_keys)
    assert keysyms == expected_keysyms
    ssn.close
示例#2
0
def test_seq(test, send_keys, expected_keysyms):
    ssn = act.klogger_start(test.vmi_g)
    for i in send_keys:
        test.vm_c.send_key(i)
    logged_keys = act.klogger_stop(test.vmi_g, ssn)
    keysyms = map(lambda (_, keysym): keysym, logged_keys)
    assert keysyms == expected_keysyms
    ssn.close()
示例#3
0
def run(vt_test, test_params, env):
    """Test for testing keyboard inputs through spice.

    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
    #test.cmd_g.install_rpm(cfg.xev)
    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.rv_chk_con(test.vmi_c)

    if cfg.ttype == 'type_and_func_keys':
        """Test typewriter and functional keys."""
        keycodes = range(1, 69)
        # Skip Ctrl, RSH, LSH, PtScr, Alt, CpsLk
        skip = [29, 42, 54, 55, 56, 58]
        send_keys = filter(lambda k: k not in skip, keycodes)
        send_keys = map(lambda k: str(hex(k)), send_keys)
        expected_keysyms = [65307, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 45,
                            61, 65288, 65289, 113, 119, 101, 114, 116, 121,
                            117, 105, 111, 112, 91, 93, 65293, 97, 115, 100,
                            102, 103, 104, 106, 107, 108, 59, 39, 96, 92, 122,
                            120, 99, 118, 98, 110, 109, 44, 46, 47, 32, 65470,
                            65471, 65472, 65473, 65474, 65475, 65476, 65477,
                            65478, 65479]
        test_seq(test, send_keys, expected_keysyms)

    if cfg.ttype == 'leds_and_esc_keys':
        escaped = ['insert', 'delete', 'home', 'end', 'pgup', 'pgdn', 'up',
                   'down', 'right', 'left']
        expected_keysyms = [65379, 65535, 65360, 65367,
                            65365, 65366, 65362, 65364, 65363, 65361]
        test_seq(test, escaped, expected_keysyms)

        shortcuts = ['a', 'shift-a', 'shift_r-a', 'ctrl-a', 'ctrl-c', 'ctrl-v',
                     'alt-x']
        expected_keysyms = [97, 65505, 65, 65506, 65, 65507, 97, 65507, 99,
                            65507, 118, 65513, 120]
        test_seq(test, shortcuts, expected_keysyms)

        leds = ['a', 'caps_lock', 'a', 'caps_lock', 'num_lock', 'kp_1',
                'num_lock', 'kp_1']
        expected_keysyms = [97, 65509, 65, 65509, 65407, 65457, 65407, 65436]
        test_seq(test, leds, expected_keysyms)
    if cfg.ttype == 'nonus_layout':
        cmd = utils.Cmd("setxkbmap", "cz")
        act.run(test.vmi_g, cmd)
        keys = ['7', '8', '9', '0', 'alt_r-x', 'alt_r-c', 'alt_r-v']
        expected_keysyms = [253, 225, 237, 233, 65027, 35, 65027, 38, 65027,
                            64]
        test_seq(test, keys, expected_keysyms)
        cmd = utils.Cmd("setxkbmap", "de")
        act.run(test.vmi_g, cmd)
        keys = ['minus', '0x1a', 'alt_r-q', 'alt_r-m']
        expected_keysyms = [223, 252, 65027, 64, 65027, 181]
        test_seq(test, keys, expected_keysyms)
        cmd = utils.Cmd("setxkbmap", "us")
        act.run(test.vmi_g, cmd)
    if cfg.ttype == "leds_migration":
        if test.vm_c.is_rhel6():
            test.vm_c.send_key('num_lock')
        keys1 = ['a', 'kp_1', 'caps_lock', 'num_lock', 'a', 'kp_1']
        keys2 = ['a', 'kp_1', 'caps_lock', 'num_lock']
        expected_keysyms = ['97', '65457', '65509', '65407', '65', '65436',
                            '65', '65436', '65509', '65407']
        ssn = act.klogger_start(test.vmi_g)
        for i in keys1:
            test.vm_c.send_key(i)
        test.vm_g.migrate()
        for i in keys2:
            test.vm_c.send_key(i)
        logged_keys = act.klogger_stop(test.vmi_g, ssn)
        ssn.close
        keysyms = map(lambda (ignore, keysym): keysym, logged_keys)
        assert keysyms == expected_keysyms
示例#4
0
def run(vt_test, test_params, env):
    """Test for testing keyboard inputs through spice.

    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
    #test.cmd_g.install_rpm(cfg.xev)
    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.rv_chk_con(test.vmi_c)

    if cfg.ttype == 'type_and_func_keys':
        """Test typewriter and functional keys."""
        keycodes = range(1, 69)
        # Skip Ctrl, RSH, LSH, PtScr, Alt, CpsLk
        skip = [29, 42, 54, 55, 56, 58]
        send_keys = [hex(k) for k in keycodes if k not in skip]
        expected_keysyms = [
            65307, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 45, 61, 65288,
            65289, 113, 119, 101, 114, 116, 121, 117, 105, 111, 112, 91, 93,
            65293, 97, 115, 100, 102, 103, 104, 106, 107, 108, 59, 39, 96, 92,
            122, 120, 99, 118, 98, 110, 109, 44, 46, 47, 32, 65470, 65471,
            65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479
        ]
        test_seq(test, send_keys, expected_keysyms)

    if cfg.ttype == 'leds_and_esc_keys':
        escaped = [
            'insert', 'delete', 'home', 'end', 'pgup', 'pgdn', 'up', 'down',
            'right', 'left'
        ]
        expected_keysyms = [
            65379, 65535, 65360, 65367, 65365, 65366, 65362, 65364, 65363,
            65361
        ]
        test_seq(test, escaped, expected_keysyms)

        shortcuts = [
            'a', 'shift-a', 'shift_r-a', 'ctrl-a', 'ctrl-c', 'ctrl-v', 'alt-x'
        ]
        expected_keysyms = [
            97, 65505, 65, 65506, 65, 65507, 97, 65507, 99, 65507, 118, 65513,
            120
        ]
        test_seq(test, shortcuts, expected_keysyms)

        leds = [
            'a', 'caps_lock', 'a', 'caps_lock', 'num_lock', 'kp_1', 'num_lock',
            'kp_1'
        ]
        expected_keysyms = [97, 65509, 65, 65509, 65407, 65457, 65407, 65436]
        test_seq(test, leds, expected_keysyms)
    if cfg.ttype == 'nonus_layout':
        cmd = utils.Cmd("setxkbmap", "cz")
        act.run(test.vmi_g, cmd)
        keys = ['7', '8', '9', '0', 'alt_r-x', 'alt_r-c', 'alt_r-v']
        expected_keysyms = [
            253, 225, 237, 233, 65027, 35, 65027, 38, 65027, 64
        ]
        test_seq(test, keys, expected_keysyms)
        cmd = utils.Cmd("setxkbmap", "de")
        act.run(test.vmi_g, cmd)
        keys = ['minus', '0x1a', 'alt_r-q', 'alt_r-m']
        expected_keysyms = [223, 252, 65027, 64, 65027, 181]
        test_seq(test, keys, expected_keysyms)
        cmd = utils.Cmd("setxkbmap", "us")
        act.run(test.vmi_g, cmd)
    if cfg.ttype == "leds_migration":
        if test.vm_c.is_rhel6():
            test.vm_c.send_key('num_lock')
        keys1 = ['a', 'kp_1', 'caps_lock', 'num_lock', 'a', 'kp_1']
        keys2 = ['a', 'kp_1', 'caps_lock', 'num_lock']
        expected_keysyms = [
            '97', '65457', '65509', '65407', '65', '65436', '65', '65436',
            '65509', '65407'
        ]
        ssn = act.klogger_start(test.vmi_g)
        for i in keys1:
            test.vm_c.send_key(i)
        test.vm_g.migrate()
        for i in keys2:
            test.vm_c.send_key(i)
        logged_keys = act.klogger_stop(test.vmi_g, ssn)
        ssn.close()
        keysyms = [key[1] for key in logged_keys]
        assert keysyms == expected_keysyms