Example #1
0
def android_test_setup(testbin):
    utils.green('testing %s' % testbin)

    # send file to phone
    fpath = testbin_to_fpath(testbin)
    shellout(['adb', 'push', fpath, '/data/local/tmp'])

    # launch adb
    threading.Thread(target=invoke_adb_gdb_listen, args=[testbin]).start()

    # connect to adb
    time.sleep(.25)
    adapter = gdb.DebugAdapterGdb()
    adapter.connect('localhost', 31337)
    entry = confirm_initial_module(adapter, testbin)

    return (adapter, entry)
Example #2
0
			adapter.breakpoint_clear(entry)
			(reason, extra) = adapter.step_into()
			expect_single_step(reason)
			(reason, extra) = adapter.step_into()
			expect_single_step(reason)
			(reason, extra) = adapter.step_into()
			expect_single_step(reason)
			# go until executing done
			(reason, extra) = adapter.go()
			assert_equality(reason, DebugAdapter.STOP_REASON.PROCESS_EXITED)

			adapter.quit()
			adapter = None

		for i in range(10):
			utils.green('testing %s %d/10' % (fpath, i+1))
			t = threading.Thread(target=thread_task)
			t.start()
			t.join()

	# return code tests
	for tb in [x for x in testbins if x.startswith('exitcode')]:
		testbin = tb
			
		fpath = testbin_to_fpath()

		# some systems return byte, or low byte of 32-bit code and otheres return 32-bit code
		testvals = [('-11',[245,4294967285]), ('-1',[4294967295,255]), ('-3',[4294967293,253]), ('0',[0]), ('3',[3]), ('7',[7]), ('123',[123])]
		for (arg, expected) in testvals:
			adapter = DebugAdapter.get_adapter_for_current_system()
Example #3
0
        fpath = os.path.join('testbins', fname)
        if platform.system() == 'Windows':
            if fpath.endswith('.exe'):
                testbins.append(fname)
        elif os.access(fpath, os.X_OK):
            testbins.append(fname)
    print('collected the following tests:\n', testbins)

    #--------------------------------------------------------------------------
    # x86/x64 TESTS
    #--------------------------------------------------------------------------

    # exception test
    for testbin in testbins:
        if not testbin.startswith('do_exception'): continue
        utils.green('testing %s' % testbin)

        adapter = DebugAdapter.get_adapter_for_current_system()
        fpath = os.path.join('testbins', testbin)

        # segfault
        adapter.exec(fpath, ['segfault'])
        (reason, extra) = go_initial(adapter, testbin)
        assert reason == DebugAdapter.STOP_REASON.ACCESS_VIOLATION
        adapter.quit()

        # illegal instruction
        adapter.exec(fpath, ['illegalinstr'])
        (reason, extra) = go_initial(adapter, testbin)
        if platform.system() in ['Darwin', 'Linux', 'Windows']:
            # not sure why, I try many supposedly bad instructions, but lldb confirms
Example #4
0
            (reason, extra) = adapter.step_into()
            expect_single_step(reason)
            (reason, extra) = adapter.step_into()
            expect_single_step(reason)
            (reason, extra) = adapter.step_into()
            expect_single_step(reason)
            # go until executing done
            (reason, extra) = adapter.go()
            assert_equality(reason, DebugAdapter.STOP_REASON.PROCESS_EXITED)

            adapter.quit()
            adapter.teardown()
            adapter = None

        for i in range(10):
            utils.green('testing %s %d/10' % (fpath, i + 1))
            t = threading.Thread(target=thread_task)
            t.start()
            t.join()

    # return code tests
    for tb in [x for x in testbins if x.startswith('exitcode')]:
        testbin = tb

        fpath = testbin_to_fpath()

        # some systems return byte, or low byte of 32-bit code and otheres return 32-bit code
        testvals = [('-11', [245, 4294967285]), ('-1', [4294967295, 255]),
                    ('-3', [4294967293, 253]), ('0', [0]), ('3', [3]),
                    ('7', [7]), ('123', [123])]
        for (arg, expected) in testvals: