Пример #1
0
def get_device_abis():
    abis = [adb.get_prop('ro.product.cpu.abi')]
    abi2 = adb.get_prop('ro.product.cpu.abi2')
    if abi2 is not None:
        abis.append(abi2)
    if 'armeabi-v7a' in abis:
        abis.append('armeabi-v7a-hard')
    return abis
Пример #2
0
def get_device_abis():
    abis = [adb.get_prop("ro.product.cpu.abi")]
    abi2 = adb.get_prop("ro.product.cpu.abi2")
    if abi2 is not None:
        abis.append(abi2)
    if "armeabi-v7a" in abis:
        abis.append("armeabi-v7a-hard")
    return abis
Пример #3
0
def get_device_abis():
    abis = [adb.get_prop('ro.product.cpu.abi')]
    abi2 = adb.get_prop('ro.product.cpu.abi2')
    if abi2 is not None:
        abis.append(abi2)
    if 'armeabi-v7a' in abis:
        abis.append('armeabi-v7a-hard')
    return abis
Пример #4
0
def get_device_abis():
    # 64-bit devices list their ABIs differently than 32-bit devices. Check all
    # the possible places for stashing ABI info and merge them.
    abi_properties = [
        'ro.product.cpu.abi',
        'ro.product.cpu.abi2',
        'ro.product.cpu.abilist',
    ]
    abis = set()
    for abi_prop in abi_properties:
        prop = adb.get_prop(abi_prop)
        if prop is not None:
            abis.update(prop.split(','))

    if 'armeabi-v7a' in abis:
        abis.add('armeabi-v7a-hard')
    return sorted(list(abis))
Пример #5
0
def can_use_asan(abi, api, toolchain):
    # ASAN is currently only supported for 32-bit ARM and x86...
    if not abi.startswith('armeabi') and not abi == 'x86':
        return False

    # On KitKat and newer...
    if api < 19:
        return False

    # When using clang...
    if toolchain != 'clang':
        return False

    # On rooted devices.
    if int(adb.get_prop('ro.debuggable')) == 0:
        return False

    return True
Пример #6
0
def main():
    os.chdir(os.path.dirname(os.path.realpath(__file__)))

    # Defining _NDK_TESTING_ALL_=yes to put armeabi-v7a-hard in its own
    # libs/armeabi-v7a-hard directoy and tested separately from armeabi-v7a.
    # Some tests are now compiled with both APP_ABI=armeabi-v7a and
    # APP_ABI=armeabi-v7a-hard. Without _NDK_TESTING_ALL_=yes, tests may fail
    # to install due to race condition on the same libs/armeabi-v7a
    if '_NDK_TESTING_ALL_' not in os.environ:
        os.environ['_NDK_TESTING_ALL_'] = 'all'

    args = ArgParser().parse_args()
    ndk_build_flags = []
    if args.abi is not None:
        ndk_build_flags.append('APP_ABI={}'.format(args.abi))
    if args.platform is not None:
        ndk_build_flags.append('APP_PLATFORM={}'.format(args.platform))
    if args.show_commands:
        ndk_build_flags.append('V=1')

    if not os.path.exists(os.path.join('../build/tools/prebuilt-common.sh')):
        sys.exit('Error: Not run from a valid NDK.')

    out_dir = 'out'
    if os.path.exists(out_dir):
        shutil.rmtree(out_dir)
    os.makedirs(out_dir)

    suites = ['awk', 'build', 'device', 'samples']
    if args.suite:
        suites = [args.suite]

    # Do this early so we find any device issues now rather than after we've
    # run all the build tests.
    if 'device' in suites:
        check_adb_works_or_die(args.abi)
        api_level = int(adb.get_prop('ro.build.version.sdk'))

        # PIE is required in L. All of the device tests are written toward the
        # ndk-build defaults, so we need to inform the build that we need PIE
        # if we're running on a newer device.
        if api_level >= 21:
            ndk_build_flags.append('APP_PIE=true')

    os.environ['ANDROID_SERIAL'] = get_test_device()

    runner = tests.TestRunner()
    if 'awk' in suites:
        runner.add_suite('awk', 'awk', AwkTest)
    if 'build' in suites:
        runner.add_suite('build', 'build', BuildTest, args.abi, args.platform,
                         ndk_build_flags)
    if 'samples' in suites:
        runner.add_suite('samples', '../samples', BuildTest, args.abi,
                         args.platform, ndk_build_flags)
    if 'device' in suites:
        runner.add_suite('device', 'device', DeviceTest, args.abi,
                         args.platform, ndk_build_flags)

    test_filters = filters.TestFilter.from_string(args.filter)
    results = runner.run(out_dir, test_filters)

    num_tests = sum(len(s) for s in results.values())
    zero_stats = {'pass': 0, 'skip': 0, 'fail': 0}
    stats = {suite: dict(zero_stats) for suite in suites}
    global_stats = dict(zero_stats)
    for suite, test_results in results.items():
        for result in test_results:
            if result.failed():
                stats[suite]['fail'] += 1
                global_stats['fail'] += 1
            elif result.passed():
                stats[suite]['pass'] += 1
                global_stats['pass'] += 1
            else:
                stats[suite]['skip'] += 1
                global_stats['skip'] += 1

    def format_stats(num_tests, stats, use_color):
        return '{pl} {p}/{t} {fl} {f}/{t} {sl} {s}/{t}'.format(
            pl=util.color_string('PASS', 'green') if use_color else 'PASS',
            fl=util.color_string('FAIL', 'red') if use_color else 'FAIL',
            sl=util.color_string('SKIP', 'yellow') if use_color else 'SKIP',
            p=stats['pass'],
            f=stats['fail'],
            s=stats['skip'],
            t=num_tests)

    use_color = sys.stdin.isatty()
    print()
    print(format_stats(num_tests, global_stats, use_color))
    for suite, test_results in results.items():
        stats_str = format_stats(len(test_results), stats[suite], use_color)
        print()
        print('{}: {}'.format(suite, stats_str))
        for result in test_results:
            if args.show_all or result.failed():
                print(result.to_string(colored=use_color))

    sys.exit(global_stats['fail'] == 0)
Пример #7
0
def get_device_abis():
    abis = [adb.get_prop('ro.product.cpu.abi')]
    abi2 = adb.get_prop('ro.product.cpu.abi2')
    if abi2 is not None:
        abis.append(abi2)
    return abis
Пример #8
0
def main():
    os.chdir(os.path.dirname(os.path.realpath(__file__)))

    # Defining _NDK_TESTING_ALL_=yes to put armeabi-v7a-hard in its own
    # libs/armeabi-v7a-hard directoy and tested separately from armeabi-v7a.
    # Some tests are now compiled with both APP_ABI=armeabi-v7a and
    # APP_ABI=armeabi-v7a-hard. Without _NDK_TESTING_ALL_=yes, tests may fail
    # to install due to race condition on the same libs/armeabi-v7a
    if '_NDK_TESTING_ALL_' not in os.environ:
        os.environ['_NDK_TESTING_ALL_'] = 'all'

    args = ArgParser().parse_args()
    ndk_build_flags = []
    if args.abi is not None:
        ndk_build_flags.append('APP_ABI={}'.format(args.abi))
    if args.platform is not None:
        ndk_build_flags.append('APP_PLATFORM={}'.format(args.platform))
    if args.show_commands:
        ndk_build_flags.append('V=1')

    if not os.path.exists(os.path.join('../build/tools/prebuilt-common.sh')):
        sys.exit('Error: Not run from a valid NDK.')

    out_dir = 'out'
    if os.path.exists(out_dir):
        shutil.rmtree(out_dir)
    os.makedirs(out_dir)

    suites = ['awk', 'build', 'device', 'samples']
    if args.suite:
        suites = [args.suite]

    # Do this early so we find any device issues now rather than after we've
    # run all the build tests.
    if 'device' in suites:
        check_adb_works_or_die(args.abi)
        api_level = int(adb.get_prop('ro.build.version.sdk'))

        # PIE is required in L. All of the device tests are written toward the
        # ndk-build defaults, so we need to inform the build that we need PIE
        # if we're running on a newer device.
        if api_level >= 21:
            ndk_build_flags.append('APP_PIE=true')

    os.environ['ANDROID_SERIAL'] = get_test_device()

    runner = tests.TestRunner()
    if 'awk' in suites:
        runner.add_suite('awk', 'awk', AwkTest)
    if 'build' in suites:
        runner.add_suite('build', 'build', BuildTest, args.abi, args.platform,
                         ndk_build_flags)
    if 'samples' in suites:
        runner.add_suite('samples', '../samples', BuildTest, args.abi,
                         args.platform, ndk_build_flags)
    if 'device' in suites:
        runner.add_suite('device', 'device', DeviceTest, args.abi,
                         args.platform, ndk_build_flags)

    test_filters = filters.TestFilter.from_string(args.filter)
    results = runner.run(out_dir, test_filters)

    num_tests = sum(len(s) for s in results.values())
    zero_stats = {'pass': 0, 'skip': 0, 'fail': 0}
    stats = {suite: dict(zero_stats) for suite in suites}
    global_stats = dict(zero_stats)
    for suite, test_results in results.items():
        for result in test_results:
            if result.failed():
                stats[suite]['fail'] += 1
                global_stats['fail'] += 1
            elif result.passed():
                stats[suite]['pass'] += 1
                global_stats['pass'] += 1
            else:
                stats[suite]['skip'] += 1
                global_stats['skip'] += 1

    def format_stats(num_tests, stats, use_color):
        return '{pl} {p}/{t} {fl} {f}/{t} {sl} {s}/{t}'.format(
            pl=util.color_string('PASS', 'green') if use_color else 'PASS',
            fl=util.color_string('FAIL', 'red') if use_color else 'FAIL',
            sl=util.color_string('SKIP', 'yellow') if use_color else 'SKIP',
            p=stats['pass'], f=stats['fail'],
            s=stats['skip'], t=num_tests)

    use_color = sys.stdin.isatty()
    print()
    print(format_stats(num_tests, global_stats, use_color))
    for suite, test_results in results.items():
        stats_str = format_stats(len(test_results), stats[suite], use_color)
        print()
        print('{}: {}'.format(suite, stats_str))
        for result in test_results:
            if args.show_all or result.failed():
                print(result.to_string(colored=use_color))

    sys.exit(global_stats['fail'] == 0)
Пример #9
0
def main():
    os.chdir(os.path.dirname(os.path.realpath(__file__)))

    # Defining _NDK_TESTING_ALL_=yes to put armeabi-v7a-hard in its own
    # libs/armeabi-v7a-hard directoy and tested separately from armeabi-v7a.
    # Some tests are now compiled with both APP_ABI=armeabi-v7a and
    # APP_ABI=armeabi-v7a-hard. Without _NDK_TESTING_ALL_=yes, tests may fail
    # to install due to race condition on the same libs/armeabi-v7a
    if "_NDK_TESTING_ALL_" not in os.environ:
        os.environ["_NDK_TESTING_ALL_"] = "all"

    args = ArgParser().parse_args()
    ndk_build_flags = []
    if args.abi is not None:
        ndk_build_flags.append("APP_ABI={}".format(args.abi))
    if args.platform is not None:
        ndk_build_flags.append("APP_PLATFORM={}".format(args.platform))
    if args.show_commands:
        ndk_build_flags.append("V=1")

    if not os.path.exists(os.path.join("../build/tools/prebuilt-common.sh")):
        sys.exit("Error: Not run from a valid NDK.")

    out_dir = "out"
    if os.path.exists(out_dir):
        shutil.rmtree(out_dir)
    os.makedirs(out_dir)

    suites = ["awk", "build", "device", "samples"]
    if args.suite:
        suites = [args.suite]

    # Do this early so we find any device issues now rather than after we've
    # run all the build tests.
    if "device" in suites:
        check_adb_works_or_die(args.abi)
        api_level = int(adb.get_prop("ro.build.version.sdk"))

        # PIE is required in L. All of the device tests are written toward the
        # ndk-build defaults, so we need to inform the build that we need PIE
        # if we're running on a newer device.
        if api_level >= 21:
            ndk_build_flags.append("APP_PIE=true")

    os.environ["ANDROID_SERIAL"] = get_test_device()

    runner = tests.TestRunner()
    if "awk" in suites:
        runner.add_suite("awk", "awk", AwkTest)
    if "build" in suites:
        runner.add_suite("build", "build", BuildTest, args.abi, args.platform, ndk_build_flags)
    if "samples" in suites:
        runner.add_suite("samples", "../samples", BuildTest, args.abi, args.platform, ndk_build_flags)
    if "device" in suites:
        runner.add_suite("device", "device", DeviceTest, args.abi, args.platform, ndk_build_flags)

    test_filters = filters.TestFilter.from_string(args.filter)
    results = runner.run(out_dir, test_filters)

    num_tests = sum(len(s) for s in results.values())
    zero_stats = {"pass": 0, "skip": 0, "fail": 0}
    stats = {suite: dict(zero_stats) for suite in suites}
    global_stats = dict(zero_stats)
    for suite, test_results in results.items():
        for result in test_results:
            if result.failed():
                stats[suite]["fail"] += 1
                global_stats["fail"] += 1
            elif result.passed():
                stats[suite]["pass"] += 1
                global_stats["pass"] += 1
            else:
                stats[suite]["skip"] += 1
                global_stats["skip"] += 1

    def format_stats(num_tests, stats, use_color):
        return "{pl} {p}/{t} {fl} {f}/{t} {sl} {s}/{t}".format(
            pl=util.color_string("PASS", "green") if use_color else "PASS",
            fl=util.color_string("FAIL", "red") if use_color else "FAIL",
            sl=util.color_string("SKIP", "yellow") if use_color else "SKIP",
            p=stats["pass"],
            f=stats["fail"],
            s=stats["skip"],
            t=num_tests,
        )

    use_color = sys.stdin.isatty()
    print()
    print(format_stats(num_tests, global_stats, use_color))
    for suite, test_results in results.items():
        stats_str = format_stats(len(test_results), stats[suite], use_color)
        print()
        print("{}: {}".format(suite, stats_str))
        for result in test_results:
            if args.show_all or result.failed():
                print(result.to_string(colored=use_color))

    sys.exit(global_stats["fail"] == 0)
Пример #10
0
def get_device_abis():
    abis = [adb.get_prop('ro.product.cpu.abi')]
    abi2 = adb.get_prop('ro.product.cpu.abi2')
    if abi2 is not None:
        abis.append(abi2)
    return abis
Пример #11
0
def main():
    orig_cwd = os.getcwd()
    os.chdir(os.path.dirname(os.path.realpath(__file__)))

    # Defining _NDK_TESTING_ALL_=yes to put armeabi-v7a-hard in its own
    # libs/armeabi-v7a-hard directory and tested separately from armeabi-v7a.
    # Some tests are now compiled with both APP_ABI=armeabi-v7a and
    # APP_ABI=armeabi-v7a-hard. Without _NDK_TESTING_ALL_=yes, tests may fail
    # to install due to race condition on the same libs/armeabi-v7a
    if '_NDK_TESTING_ALL_' not in os.environ:
        os.environ['_NDK_TESTING_ALL_'] = 'all'

    if 'NDK' not in os.environ:
        os.environ['NDK'] = os.path.dirname(os.getcwd())

    args = ArgParser().parse_args()
    ndk_build_flags = []
    if args.abi is not None:
        ndk_build_flags.append('APP_ABI={}'.format(args.abi))
    if args.platform is not None:
        ndk_build_flags.append('APP_PLATFORM={}'.format(args.platform))
    if args.show_commands:
        ndk_build_flags.append('V=1')

    if not os.path.exists(os.path.join('../build/tools/prebuilt-common.sh')):
        sys.exit('Error: Not run from a valid NDK.')

    out_dir = args.out_dir
    if out_dir is not None:
        if not os.path.isabs(out_dir):
            out_dir = os.path.join(orig_cwd, out_dir)
        if os.path.exists(out_dir):
            shutil.rmtree(out_dir)
        os.makedirs(out_dir)
    else:
        out_dir = tempfile.mkdtemp()
        atexit.register(lambda: shutil.rmtree(out_dir))

    suites = ['awk', 'build', 'device']
    if args.suite:
        suites = [args.suite]

    # Do this early so we find any device issues now rather than after we've
    # run all the build tests.
    if 'device' in suites:
        check_adb_works_or_die(args.abi)
        api_level = int(adb.get_prop('ro.build.version.sdk'))

        # PIE is required in L. All of the device tests are written toward the
        # ndk-build defaults, so we need to inform the build that we need PIE
        # if we're running on a newer device.
        if api_level >= 21:
            ndk_build_flags.append('APP_PIE=true')

        os.environ['ANDROID_SERIAL'] = get_test_device()

        if can_use_asan(args.abi, api_level, args.toolchain):
            asan_device_setup()

        # Do this as part of initialization rather than with a `mkdir -p` later
        # because Gingerbread didn't actually support -p :(
        adb.shell('rm -r /data/local/tmp/ndk-tests')
        adb.shell('mkdir /data/local/tmp/ndk-tests')

    runner = tests.TestRunner()
    if 'awk' in suites:
        runner.add_suite('awk', 'awk', AwkTest)
    if 'build' in suites:
        runner.add_suite('build', 'build', BuildTest, args.abi, args.platform,
                         args.toolchain, ndk_build_flags)
    if 'device' in suites:
        runner.add_suite('device', 'device', DeviceTest, args.abi,
                         args.platform, api_level, args.toolchain,
                         ndk_build_flags)

    test_filters = filters.TestFilter.from_string(args.filter)
    results = runner.run(out_dir, test_filters)

    stats = ResultStats(suites, results)

    use_color = sys.stdin.isatty() and os.name != 'nt'
    printer = printers.StdoutPrinter(use_color=use_color,
                                     show_all=args.show_all)
    printer.print_results(results, stats)
    sys.exit(stats.global_stats['fail'] > 0)