Exemplo n.º 1
0
def test_info_conn_7():
    dummy = ConnectionInformation(7, bytearray.fromhex('0023023a1a2e'), 0, True, 0xc,
                                  bytearray.fromhex('e98a5eaaff39ecb5ce4447590dfb73a4'), 16,
                                  bytearray.fromhex('dbea2d9c47bc1aa6afe664ff31591aa6'), -87,
                                  bytearray.fromhex('0a00c821ffff8ffa'), bytearray.fromhex('9bff598701000000'),
                                  bytearray.fromhex('00'))

    trace = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         'traces/adbcore/dictionary_tests/info_conn_7.trace')
    args = _parse_argv('')
    args.device = 'adb_replay'
    args.replay = trace

    data_directory = os.path.expanduser('~') + '/.internalblue'

    if not os.path.exists(data_directory):
        os.mkdir(data_directory)

    from internalblue.socket_hooks import hook, ReplaySocket
    hook(ADBCore, ReplaySocket, filename=args.replay)

    connection_methods = [ADBCore(log_level='info', data_directory=data_directory, replay=True)]

    devices = []  # type: List[DeviceTuple]
    devices = connection_methods[0].device_list()

    device = devices[0]
    reference = device[0]
    reference.interface = device[1]
    reference.connect()

    information = reference.readConnectionInformation(7)
    print(information)

    nose.tools.assert_dict_equal(vars(information), vars(dummy))

    reference.shutdown()
Exemplo n.º 2
0
def test_info_conn_9():
    dummy = ConnectionInformation(9, bytearray.fromhex('000000000000'), 0, False, 12,
                                  bytearray.fromhex('00000000000000000000000000000000'), 0, b'', -87,
                                  bytearray.fromhex('0000000000000000'),
                                  bytearray.fromhex('0000000000000000'), bytearray.fromhex('00'))

    trace = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         'traces/adbcore/dictionary_tests/info_conn_9.trace')
    args = _parse_argv('')
    args.device = 'adb_replay'
    args.replay = trace

    data_directory = os.path.expanduser('~') + '/.internalblue'

    if not os.path.exists(data_directory):
        os.mkdir(data_directory)

    from internalblue.socket_hooks import hook, ReplaySocket
    hook(ADBCore, ReplaySocket, filename=args.replay)

    connection_methods = [ADBCore(log_level='info', data_directory=data_directory, replay=True)]

    devices = []  # type: List[DeviceTuple]
    devices = connection_methods[0].device_list()

    device = devices[0]
    reference = device[0]
    reference.interface = device[1]
    reference.connect()

    information = reference.readConnectionInformation(9)
    print(information)

    nose.tools.assert_dict_equal(vars(information), vars(dummy))

    reference.shutdown()
Exemplo n.º 3
0
def test_info_queue():
    dummy = [
        QueueElement(0, 2123152, 4, 16, 0, 16, 2123208, 2123272, 2123268,
                     2123268, 0, 0, 2123332, 2141676, 'tran_HCIEvent'),
        QueueElement(1, 2123332, 8, 31, 0, 31, 2123388, 2123636, 2123436,
                     2123436, 0, 0, 2123636, 2123152, 'tran_ACLData'),
        QueueElement(2, 2123636, 4, 3, 0, 3, 2123692, 2123704, 2123692,
                     2123692, 0, 0, 2123704, 2123332, 'tran_SCOData'),
        QueueElement(3, 2123704, 4, 31, 0, 31, 2123760, 2123884, 2123760,
                     2123760, 0, 0, 2123884, 2123636,
                     'tran_UartBridgeNonHCIEvent'),
        QueueElement(4, 2123884, 4, 20, 0, 20, 2123940, 2124020, 2124000,
                     2124000, 0, 0, 2124020, 2123704, 'tran_DiagData'),
        QueueElement(5, 2124020, 8, 8, 0, 8, 2124076, 2124140, 2124076,
                     2124076, 0, 0, 2124140, 2123884, 'tran_HIDUsbKBEvt'),
        QueueElement(6, 2124140, 8, 6, 0, 6, 2124196, 2124244, 2124196,
                     2124196, 0, 0, 2124244, 2124020, 'tran_HIDUsbMSEvt'),
        QueueElement(7, 2124244, 8, 1, 0, 1, 2100496, 2100504, 2100496,
                     2100496, 0, 0, 2124300, 2124140, 'tran_HIDUsbMSCtrl'),
        QueueElement(8, 2124300, 8, 1, 0, 1, 2100504, 2100512, 2100504,
                     2100504, 0, 0, 2124356, 2124244, 'tran_HIDUsbKBCtrl'),
        QueueElement(9, 2124356, 8, 32, 0, 32, 2124412, 2124668, 2124412,
                     2124412, 0, 0, 2110352, 2124300, 'tran_HidAuxData'),
        QueueElement(10, 2110352, 8, 12, 0, 12, 2192284, 2192380, 2192300,
                     2192300, 0, 0, 2120560, 2124356, 'lm_Cmd'),
        QueueElement(11, 2120560, 4, 8, 0, 8, 2192380, 2192412, 2192400,
                     2192400, 0, 0, 2110408, 2110352, 'hci_HciCommand'),
        QueueElement(12, 2110408, 8, 19, 0, 19, 2192412, 2192564, 2192412,
                     2192412, 0, 0, 2118068, 2120560, 'lm_deferredAction'),
        QueueElement(13, 2118068, 8, 6, 0, 6, 2192564, 2192612, 2192564,
                     2192564, 0, 0, 2141588, 2110408, 'lrmmsm_cmd'),
        QueueElement(14, 2141588, 4, 8, 0, 8, 2141644, 2141676, 2141644,
                     2141644, 0, 0, 2141676, 2118068, 'liteHostEvent'),
        QueueElement(15, 2141676, 4, 16, 0, 16, 2141732, 2141796, 2141732,
                     2141732, 0, 0, 2123152, 2141588, 'litehostRcvdL2capData')
    ]

    trace = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         'traces/adbcore/dictionary_tests/info_queue.trace')
    args = _parse_argv('')
    args.device = 'adb_replay'
    args.replay = trace

    data_directory = os.path.expanduser('~') + '/.internalblue'

    if not os.path.exists(data_directory):
        os.mkdir(data_directory)

    from internalblue.socket_hooks import hook, ReplaySocket
    hook(ADBCore, ReplaySocket, filename=args.replay)

    connection_methods = [
        ADBCore(log_level='info', data_directory=data_directory, replay=True)
    ]

    devices = []  # type: List[DeviceTuple]
    devices = connection_methods[0].device_list()

    device = devices[0]
    reference = device[0]
    reference.interface = device[1]
    reference.connect()

    information = reference.readQueueInformation()
    print(information)

    nose.tools.assert_equal([vars(element) for element in information],
                            [vars(element) for element in dummy])

    reference.shutdown()
Exemplo n.º 4
0
def trace_test(core, tracepath, commands):
    args = _parse_argv("")
    args.device = core_to_device[core]
    args.replay = tracepath
    args.commands = commands + "; quit"
    internalblue_cli("", args=args)
Exemplo n.º 5
0
def test_info_heap_old():
    dummy = [{
        'index': 0,
        'buffer_headers': {
            2194080: 0,
            2193828: 2121160,
            2193864: 2194008,
            2193900: 2194044,
            2193936: 2193864,
            2193972: 2121160,
            2194008: 2193900,
            2194044: 2194080
        },
        'capacity': 8,
        'address': 2121160,
        'next': 2121208,
        'memory_size': 288,
        'waitlist_length': 0,
        'buffer_list': 2193828,
        'memory': 2193828,
        'buffer_size': 32,
        'prev': 2157672,
        'list_length': 7,
        'thread_waitlist': 0
    }, {
        'index': 1,
        'buffer_headers': {
            2194592: 0,
            2194116: 2194184,
            2194184: 2194252,
            2194252: 2194320,
            2194320: 2194388,
            2194388: 2194456,
            2194456: 2194524,
            2194524: 2194592
        },
        'capacity': 8,
        'address': 2121208,
        'next': 2121256,
        'memory_size': 544,
        'waitlist_length': 0,
        'buffer_list': 2194184,
        'memory': 2194116,
        'buffer_size': 64,
        'prev': 2121160,
        'list_length': 7,
        'thread_waitlist': 0
    }, {
        'index': 2,
        'buffer_headers': {
            2196000: 2196268,
            2197072: 0,
            2194660: 2194928,
            2195464: 2195732,
            2196268: 2196536,
            2194928: 2195196,
            2195732: 2196000,
            2196536: 2196804,
            2196804: 2197072,
            2195196: 2195464
        },
        'capacity': 10,
        'address': 2121256,
        'next': 2121352,
        'memory_size': 2680,
        'waitlist_length': 0,
        'buffer_list': 2194660,
        'memory': 2194660,
        'buffer_size': 264,
        'prev': 2121208,
        'list_length': 10,
        'thread_waitlist': 0
    }, {
        'index': 3,
        'buffer_headers': {
            2214480: 2215548,
            2215548: 2216616,
            2216616: 0,
            2213412: 2214480
        },
        'capacity': 4,
        'address': 2121352,
        'next': 2121304,
        'memory_size': 4272,
        'waitlist_length': 0,
        'buffer_list': 2213412,
        'memory': 2213412,
        'buffer_size': 1064,
        'prev': 2121256,
        'list_length': 4,
        'thread_waitlist': 0
    }, {
        'index': 4,
        'buffer_headers': {
            2234124: 0,
            2231932: 2233028,
            2224260: 2225356,
            2219876: 2220972,
            2226452: 2227548,
            2223164: 2224260,
            2228644: 2229740,
            2220972: 2222068,
            2225356: 2226452,
            2230836: 2231932,
            2233028: 2234124,
            2222068: 2223164,
            2227548: 2228644,
            2217684: 2218780,
            2218780: 2219876,
            2229740: 2230836
        },
        'capacity': 16,
        'address': 2121304,
        'next': 2157624,
        'memory_size': 17536,
        'waitlist_length': 0,
        'buffer_list': 2217684,
        'memory': 2217684,
        'buffer_size': 1092,
        'prev': 2121352,
        'list_length': 16,
        'thread_waitlist': 0
    }, {
        'index': 5,
        'buffer_headers': {
            2235264: 2235308,
            2235616: 2235660,
            2235396: 2235440,
            2235528: 2235572,
            2235660: 2235704,
            2235308: 2235352,
            2235440: 2235484,
            2235704: 2235748,
            2235792: 2235836,
            2235220: 2235264,
            2235748: 2235792,
            2235352: 2235396,
            2235572: 2235616,
            2235836: 0,
            2235484: 2235528
        },
        'capacity': 15,
        'address': 2157624,
        'next': 2157672,
        'memory_size': 660,
        'waitlist_length': 0,
        'buffer_list': 2235220,
        'memory': 2235220,
        'buffer_size': 40,
        'prev': 2121304,
        'list_length': 15,
        'thread_waitlist': 0
    }, {
        'index': 6,
        'buffer_headers': {
            2236096: 2236132,
            2236240: 2236276,
            2236132: 2236168,
            2236384: 0,
            2235880: 2235916,
            2236204: 2236240,
            2236348: 2236384,
            2235916: 2235952,
            2235952: 2235988,
            2236168: 2236204,
            2236312: 2236348,
            2235988: 2236024,
            2236024: 2236060,
            2236276: 2236312,
            2236060: 2236096
        },
        'capacity': 15,
        'address': 2157672,
        'next': 2121160,
        'memory_size': 540,
        'waitlist_length': 0,
        'buffer_list': 2235880,
        'memory': 2235880,
        'buffer_size': 32,
        'prev': 2157624,
        'list_length': 15,
        'thread_waitlist': 0
    }]

    trace = os.path.join(
        os.path.dirname(os.path.abspath(__file__)),
        'traces/adbcore/dictionary_tests/info_heap_old.trace')
    args = _parse_argv('')
    args.device = 'adb_replay'
    args.replay = trace

    data_directory = os.path.expanduser('~') + '/.internalblue'

    if not os.path.exists(data_directory):
        os.mkdir(data_directory)

    from internalblue.socket_hooks import hook, ReplaySocket
    hook(ADBCore, ReplaySocket, filename=args.replay)

    connection_methods = [
        ADBCore(log_level='info', data_directory=data_directory, replay=True)
    ]

    devices = []  # type: List[DeviceTuple]
    devices = connection_methods[0].device_list()

    device = devices[0]
    reference = device[0]
    reference.interface = device[1]
    reference.connect()

    information = reference.readHeapInformation()
    print(information)

    nose.tools.assert_equal(information, dummy)

    reference.shutdown()
Exemplo n.º 6
0
def test_info_heap_new():
    dummy = [{
        "index": 0,
        "capacity": 32,
        "address": 2100380,
        "next": 2100412,
        "memory_size": 1152,
        "buffer_list": 2190960,
        "memory": 2190864,
        "buffer_size": 32,
        "buffer_headers": {
            2191872: 2134443254,
            2191620: 2037880954,
            2191368: 375085499,
            2191116: 3147300663,
            2190864: 0,
            2191764: 264196083,
            2191512: 2509895076,
            2191260: 2520551584,
            2191008: 0,
            2191908: 1846542368,
            2191656: 1757769142,
            2191404: 3932721686,
            2191152: 2191184,
            2190900: 28735,
            2191800: 2840650003,
            2191548: 1443923039,
            2191296: 1489683938,
            2191044: 4066066958,
            2191944: 1913651233,
            2191692: 152195353,
            2191440: 2191472,
            2191188: 1557416373,
            2190936: 302056974,
            2191836: 649087106,
            2191584: 3228135896,
            2191332: 3061215438,
            2191080: 720823376,
            2191980: 2196903397,
            2191728: 2191760,
            2191476: 2016717863,
            2191224: 733933656,
            2190972: 101581052
        },
        "list_length": 28
    }, {
        "index": 1,
        "capacity": 50,
        "address": 2100412,
        "next": 2100444,
        "memory_size": 5000,
        "buffer_list": 2191888,
        "memory": 2191888,
        "buffer_size": 96,
        "buffer_headers": {
            2194688: 2418054699,
            2196288: 1950181917,
            2192388: 998902997,
            2193288: 1237870693,
            2196588: 3682344019,
            2194188: 3476501705,
            2191888: 2191984,
            2195288: 1169168150,
            2192788: 733035576,
            2193688: 212170382,
            2195588: 4256985711,
            2194588: 2553343043,
            2196688: 2197224,
            2192288: 1364917638,
            2195888: 19938058,
            2193188: 1183181508,
            2194088: 2389621397,
            2196188: 1101316817,
            2194988: 4119138959,
            2192688: 3404258821,
            2196488: 2957618219,
            2193588: 1015303433,
            2194488: 1542989588,
            2195188: 334177442,
            2192188: 3048389179,
            2193088: 4249806944,
            2195488: 1476670297,
            2193988: 4205996809,
            2196788: 0,
            2194888: 1063521161,
            2195788: 1587397832,
            2192588: 3951930416,
            2193488: 3182543110,
            2196088: 1404536822,
            2194388: 3962928810,
            2192088: 1508747568,
            2196388: 2481150443,
            2192988: 3794218756,
            2193888: 2230011074,
            2195088: 2388733849,
            2194788: 319481313,
            2192488: 1066099460,
            2195388: 2397324227,
            2193388: 3268540448,
            2194288: 2194384,
            2195688: 443293108,
            2191988: 3365837461,
            2192888: 2725717105,
            2195988: 954670552,
            2193788: 2274473962
        },
        "list_length": 50
    }, {
        "index": 2,
        "capacity": 12,
        "address": 2100444,
        "next": 2169260,
        "memory_size": 3264,
        "buffer_list": 2196688,
        "memory": 2196688,
        "buffer_size": 268,
        "buffer_headers": {
            2196960: 1868719728,
            2198048: 2301952667,
            2197504: 2764580300,
            2198592: 4031749240,
            2199408: 3141828370,
            2199680: 2673196138,
            2197776: 655413012,
            2196688: 2197224,
            2198864: 483218198,
            2199136: 2070409995,
            2197232: 4269595008,
            2198320: 2960663615
        },
        "list_length": 11
    }, {
        "index": 3,
        "capacity": 4,
        "address": 2169260,
        "next": 2169292,
        "memory_size": 4288,
        "buffer_list": 2199904,
        "memory": 2199904,
        "buffer_size": 1068,
        "buffer_headers": {
            2199904: 2200972,
            2200976: 3538041113,
            2202048: 1981831315,
            2203120: 2664647264
        },
        "list_length": 4
    }, {
        "index": 4,
        "capacity": 16,
        "address": 2169292,
        "next": 2169324,
        "memory_size": 17536,
        "buffer_list": 2204176,
        "memory": 2204176,
        "buffer_size": 1092,
        "buffer_headers": {
            2206368: 3081486871,
            2208560: 2201211482,
            2218424: 1142812043,
            2210752: 1735894938,
            2219520: 1997110991,
            2207464: 3467810309,
            2220616: 3465059190,
            2217328: 3406578824,
            2215136: 2543784863,
            2204176: 2205268,
            2209656: 3726451979,
            2214040: 3051833507,
            2211848: 3382482014,
            2205272: 2465189202,
            2212944: 2900433384,
            2216232: 619500542
        },
        "list_length": 16
    }, {
        "index": 5,
        "capacity": 15,
        "address": 2169324,
        "next": 2169356,
        "memory_size": 4020,
        "buffer_list": 2221648,
        "memory": 2221648,
        "buffer_size": 264,
        "buffer_headers": {
            2222720: 4187811300,
            2223792: 71320053,
            2223524: 2131726092,
            2222184: 983003111,
            2224060: 1514897371,
            2222988: 2920869383,
            2225132: 670722248,
            2225400: 4011899155,
            2221648: 2221912,
            2224328: 1327684221,
            2222452: 1691084254,
            2223256: 2278527172,
            2224596: 3213868993,
            2221916: 2666878639,
            2224864: 4293236507
        },
        "list_length": 15
    }, {
        "index": 6,
        "capacity": 15,
        "address": 2169356,
        "next": 0,
        "memory_size": 4020,
        "buffer_list": 2225608,
        "memory": 2225608,
        "buffer_size": 264,
        "buffer_headers": {
            2226144: 2468503925,
            2228288: 3769100033,
            2226948: 3003019165,
            2225608: 2225872,
            2228556: 1848533574,
            2226412: 19831529,
            2229360: 3069868169,
            2227216: 2022414238,
            2227752: 2727841579,
            2228824: 1909490602,
            2225876: 2300688060,
            2226680: 210906155,
            2228020: 3166977216,
            2227484: 2262736138,
            2229092: 1991768492
        },
        "list_length": 15
    }]

    trace = os.path.join(
        os.path.dirname(os.path.abspath(__file__)),
        'traces/hcicore/dictionary_tests/info_heap_new.trace')
    args = _parse_argv('')
    args.device = 'adb_replay'
    args.replay = trace

    data_directory = os.path.expanduser('~') + '/.internalblue'

    if not os.path.exists(data_directory):
        os.mkdir(data_directory)

    from internalblue.socket_hooks import hook, ReplaySocket
    hook(HCICore, ReplaySocket, filename=args.replay)

    connection_methods = [
        HCICore(log_level='info', data_directory=data_directory, replay=True)
    ]

    devices = []  # type: List[DeviceTuple]
    devices = connection_methods[0].device_list()

    device = devices[0]
    reference = device[0]
    reference.interface = device[1]
    reference.connect()

    information = reference.readHeapInformation()
    print(information)

    nose.tools.assert_equal(information, dummy)

    reference.shutdown()