Esempio n. 1
0
def test_echo_pipe() -> None:
    line = 'addr 0xffffffffc084eee0 | addr global_void_ptr'

    ret = invoke(MOCK_PROGRAM, [], line)

    assert len(ret) == 2
    assert ret[0].value_() == 0xffffffffc084eee0
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('void *'))
    assert ret[1].value_() == 0xffff88d26353c108
    assert sdb.type_equals(ret[1].type_, MOCK_PROGRAM.type('void **'))
Esempio n. 2
0
def test_multiple_args() -> None:
    line = 'echo 0 1'

    ret = invoke(MOCK_PROGRAM, [], line)

    assert len(ret) == 2
    assert ret[0].value_() == 0
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('void *'))
    assert ret[1].value_() == 1
    assert sdb.type_equals(ret[1].type_, MOCK_PROGRAM.type('void *'))
Esempio n. 3
0
def test_piped_invocations() -> None:
    line = 'addr global_int | addr 0xffffffffc084eee0 global_void_ptr'

    ret = invoke(MOCK_PROGRAM, [], line)

    assert len(ret) == 3
    assert ret[0].value_() == 0xffffffffc0000000
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('int *'))
    assert ret[1].value_() == 0xffffffffc084eee0
    assert sdb.type_equals(ret[1].type_, MOCK_PROGRAM.type('void *'))
    assert ret[2].value_() == 0xffff88d26353c108
    assert sdb.type_equals(ret[2].type_, MOCK_PROGRAM.type('void **'))
Esempio n. 4
0
def test_multiple_piped() -> None:
    line = 'echo'
    objs = [
        drgn.Object(MOCK_PROGRAM, 'void *', value=0),
        drgn.Object(MOCK_PROGRAM, 'int', value=1),
    ]

    ret = invoke(MOCK_PROGRAM, objs, line)

    assert len(ret) == 2
    assert ret[0].value_() == 0
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('void *'))
    assert ret[1].value_() == 1
    assert sdb.type_equals(ret[1].type_, MOCK_PROGRAM.type('int'))
Esempio n. 5
0
def test_multi_void_ptr_input_value_match_ne() -> None:
    line = 'filter "obj != 1"'
    objs = [
        drgn.Object(MOCK_PROGRAM, 'void *', value=0),
        drgn.Object(MOCK_PROGRAM, 'void *', value=1),
        drgn.Object(MOCK_PROGRAM, 'void *', value=2),
    ]

    ret = invoke(MOCK_PROGRAM, objs, line)

    assert len(ret) == 2
    assert ret[0].value_() == 0
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('void *'))
    assert ret[1].value_() == 2
    assert sdb.type_equals(ret[1].type_, MOCK_PROGRAM.type('void *'))
Esempio n. 6
0
def test_single_arg() -> None:
    line = 'echo 1'

    ret = invoke(MOCK_PROGRAM, [], line)

    assert len(ret) == 1
    assert ret[0].value_() == 1
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('void *'))
Esempio n. 7
0
def test_double_cast() -> None:
    line = 'addr global_int | cast unsigned int | cast char *'

    ret = invoke(MOCK_PROGRAM, [], line)

    assert len(ret) == 1
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('char *'))
    assert ret[0].value_() == 0xc0000000
Esempio n. 8
0
def test_pipe_input_pointer_to_int() -> None:
    line = 'addr global_int | cast unsigned int'

    ret = invoke(MOCK_PROGRAM, [], line)

    assert len(ret) == 1
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('unsigned int'))
    assert ret[0].value_() == 0xc0000000
Esempio n. 9
0
def test_str_pipe_input() -> None:
    line = 'addr global_int | cast void *'

    ret = invoke(MOCK_PROGRAM, [], line)

    assert len(ret) == 1
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('void *'))
    assert ret[0].value_() == 0xffffffffc0000000
Esempio n. 10
0
def test_plain_address() -> None:
    line = 'addr 0xffffffffc084eee0'

    ret = invoke(MOCK_PROGRAM, [], line)

    assert len(ret) == 1
    assert ret[0].value_() == 0xffffffffc084eee0
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('void *'))
Esempio n. 11
0
def test_single_object() -> None:
    line = 'addr global_int'

    ret = invoke(MOCK_PROGRAM, [], line)

    assert len(ret) == 1
    assert ret[0].value_() == 0xffffffffc0000000
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('int *'))
Esempio n. 12
0
def test_test_piped_int() -> None:
    line = 'echo'
    objs = [drgn.Object(MOCK_PROGRAM, 'int', value=1)]

    ret = invoke(MOCK_PROGRAM, objs, line)

    assert len(ret) == 1
    assert ret[0].value_() == 1
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('int'))
Esempio n. 13
0
def test_piped_and_args_combo() -> None:
    line = 'echo 0 1'
    objs = [
        drgn.Object(MOCK_PROGRAM, 'void *', value=0),
        drgn.Object(MOCK_PROGRAM, 'int', value=1),
    ]

    ret = invoke(MOCK_PROGRAM, objs, line)

    assert len(ret) == 4
    assert ret[0].value_() == 0
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('void *'))
    assert ret[1].value_() == 1
    assert sdb.type_equals(ret[1].type_, MOCK_PROGRAM.type('int'))
    assert ret[2].value_() == 0
    assert sdb.type_equals(ret[2].type_, MOCK_PROGRAM.type('void *'))
    assert ret[3].value_() == 1
    assert sdb.type_equals(ret[3].type_, MOCK_PROGRAM.type('void *'))
Esempio n. 14
0
def test_invoke_pipe_input() -> None:
    line = 'cast void *'
    objs = [MOCK_PROGRAM['global_int']]

    ret = invoke(MOCK_PROGRAM, objs, line)

    assert len(ret) == 1
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('void *'))
    assert ret[0].value_() == 0x01020304
Esempio n. 15
0
def test_multi_echo_combo() -> None:
    line = 'echo 2 3 | echo 4'
    objs = [
        drgn.Object(MOCK_PROGRAM, 'void *', value=0),
        drgn.Object(MOCK_PROGRAM, 'int', value=1),
    ]

    ret = invoke(MOCK_PROGRAM, objs, line)

    assert len(ret) == 5
    assert ret[0].value_() == 0
    assert sdb.type_equals(ret[0].type_, MOCK_PROGRAM.type('void *'))
    assert ret[1].value_() == 1
    assert sdb.type_equals(ret[1].type_, MOCK_PROGRAM.type('int'))
    assert ret[2].value_() == 2
    assert sdb.type_equals(ret[2].type_, MOCK_PROGRAM.type('void *'))
    assert ret[3].value_() == 3
    assert sdb.type_equals(ret[3].type_, MOCK_PROGRAM.type('void *'))
    assert ret[4].value_() == 4
    assert sdb.type_equals(ret[4].type_, MOCK_PROGRAM.type('void *'))