예제 #1
0
파일: config.py 프로젝트: epowers/arc
def _generate_jemalloc_unit_tests():
  paths = build_common.find_all_files(
      'android/external/jemalloc/test/unit', ['.c'], include_tests=True)

  # These tests need -DJEMALLOC_PROF which we do not enable.
  paths.remove('android/external/jemalloc/test/unit/prof_accum.c')
  paths.remove('android/external/jemalloc/test/unit/prof_accum_a.c')
  paths.remove('android/external/jemalloc/test/unit/prof_accum_b.c')
  paths.remove('android/external/jemalloc/test/unit/prof_gdump.c')
  paths.remove('android/external/jemalloc/test/unit/prof_idump.c')

  # Disable some multi-threaded tests flaky under ARM qemu.
  if OPTIONS.is_arm():
    paths.remove('android/external/jemalloc/test/unit/mq.c')
    paths.remove('android/external/jemalloc/test/unit/mtx.c')

  for path in paths:
    name = os.path.splitext(os.path.basename(path))[0]
    n = ninja_generator.TestNinjaGenerator('jemalloc_unit_test_' + name)
    n.add_include_paths(
        'android/external/jemalloc/include',
        'android/external/jemalloc/test/include')
    n.add_c_flags('-Werror')
    n.add_c_flags('-DJEMALLOC_UNIT_TEST')
    if OPTIONS.enable_jemalloc_debug():
      n.add_c_flags('-DJEMALLOC_DEBUG')
    # Needs C99 for "restrict" keyword.
    n.add_c_flags('-std=gnu99')
    n.add_library_deps('libjemalloc_jet.a')
    n.add_library_deps('libjemalloc_unittest.a')
    n.build_default([path])
    n.run(n.link(), enable_valgrind=OPTIONS.enable_valgrind(), rule='run_test')
예제 #2
0
파일: config.py 프로젝트: epowers/arc
def _generate_jemalloc_integration_tests():
  paths = build_common.find_all_files(
      'android/external/jemalloc/test/integration', ['.c'], include_tests=True)

  # Disable some multi-threaded tests flaky under ARM qemu.
  if OPTIONS.is_arm():
    paths.remove('android/external/jemalloc/test/integration/MALLOCX_ARENA.c')
    paths.remove('android/external/jemalloc/test/integration/thread_arena.c')

  for path in paths:
    name = os.path.splitext(os.path.basename(path))[0]
    n = ninja_generator.TestNinjaGenerator('jemalloc_integartion_test_' + name)
    n.add_include_paths(
        'android/external/jemalloc/include',
        'android/external/jemalloc/test/include')
    n.add_c_flags('-Werror')
    n.add_c_flags('-DJEMALLOC_INTEGRATION_TEST')
    if OPTIONS.enable_jemalloc_debug():
      n.add_c_flags('-DJEMALLOC_DEBUG')
    # Needs C99 for "restrict" keyword.
    n.add_c_flags('-std=gnu99')
    n.add_library_deps('libjemalloc.a')
    n.add_library_deps('libjemalloc_integrationtest.a')
    n.build_default([path])
    n.run(n.link(), enable_valgrind=OPTIONS.enable_valgrind(), rule='run_test')
예제 #3
0
def _generate_check_symbols_ninja():
    # If we do not use NDK direct execution, the compatibility is less
    # important.
    if not build_common.use_ndk_direct_execution():
        return

    n = ninja_generator.NinjaGenerator('check_symbols')
    script = staging.as_staging('src/build/check_symbols.py')
    rule_name = 'check_symbols'
    n.rule(rule_name,
           command=('src/build/run_python %s $android_lib $in %s' %
                    (script, build_common.get_test_output_handler())),
           description=(rule_name + ' $in'))

    if OPTIONS.is_arm():
        arch_subdir = 'arch-arm'
    else:
        arch_subdir = 'arch-x86'
    lib_dir = os.path.join(_ANDROID_SYSTEM_IMAGE_DIR, arch_subdir, 'usr/lib')
    for so_file in build_common.find_all_files(lib_dir, suffixes='.so'):
        lib_name = os.path.basename(so_file)
        if lib_name not in ['libc.so', 'libdl.so', 'libm.so']:
            # For now, we only check Bionic.
            # TODO(crbug.com/408548): Extend this for other libraries.
            continue
        result_path = os.path.join(build_common.get_build_dir(),
                                   'check_symbols',
                                   'check_symbols.%s.result' % lib_name)
        n.build(result_path,
                rule_name,
                build_common.get_build_path_for_library(lib_name),
                variables={'android_lib': staging.as_staging(so_file)},
                implicit=[script, staging.as_staging(so_file)])
예제 #4
0
파일: config.py 프로젝트: zhangpf/arc
def _generate_integration_test_ninja():
    n = ninja_generator.ApkFromSdkNinjaGenerator(
        build_common.get_graphics_translation_test_name(),
        base_path='graphics_translation/tests/apk',
        use_ndk=True,
        use_gtest=True)
    sources = build_common.find_all_files(base_paths=[
        'graphics_translation/tests', 'graphics_translation/tests/util'
    ],
                                          suffixes=['.cpp', '.h'],
                                          include_tests=True,
                                          recursive=False)

    # Additional source code dependencies to outside of
    # graphics_translation/tests.
    implicit = [
        'android_libcommon/common/alog.h',
        'graphics_translation/gles/debug.cpp',
        'graphics_translation/gles/debug.h',
        'graphics_translation/gles/texture_codecs.cpp',
        'graphics_translation/gles/texture_codecs.h',
        'src/common/math_test_helpers.h',
        'src/common/matrix.cc',
        'src/common/matrix.h',
        'src/common/vector.cc',
        'src/common/vector.h',
    ]

    n.build_default_all_sources(
        implicit=[staging.as_staging(path) for path in (sources + implicit)])
    n.build_google_test_list(sources)
예제 #5
0
파일: config.py 프로젝트: epowers/arc
def _generate_integration_test_ninja():
  n = ninja_generator.ApkFromSdkNinjaGenerator(
      build_common.get_graphics_translation_test_name(),
      base_path='graphics_translation/tests/apk',
      use_ndk=True, use_gtest=True)
  sources = build_common.find_all_files(
      base_paths=['graphics_translation/tests',
                  'graphics_translation/tests/util'],
      suffixes=['.cpp', '.h'],
      include_tests=True,
      recursive=False)

  # Additional source code dependencies to outside of
  # graphics_translation/tests.
  implicit = [
      'android_libcommon/common/alog.h',
      'graphics_translation/gles/debug.cpp',
      'graphics_translation/gles/debug.h',
      'graphics_translation/gles/texture_codecs.cpp',
      'graphics_translation/gles/texture_codecs.h',
      'src/common/math_test_helpers.h',
      'src/common/matrix.cc',
      'src/common/matrix.h',
      'src/common/vector.cc',
      'src/common/vector.h',
  ]

  n.build_default_all_sources(
      implicit=[staging.as_staging(path) for path in (sources + implicit)])
  n.build_google_test_list(sources)
예제 #6
0
파일: config.py 프로젝트: zhangpf/arc
def _generate_jemalloc_integration_tests():
    paths = build_common.find_all_files(
        'android/external/jemalloc/test/integration', ['.c'],
        include_tests=True)

    # Disable some multi-threaded tests flaky under ARM qemu.
    if OPTIONS.is_arm():
        paths.remove(
            'android/external/jemalloc/test/integration/MALLOCX_ARENA.c')
        paths.remove(
            'android/external/jemalloc/test/integration/thread_arena.c')

    for path in paths:
        name = os.path.splitext(os.path.basename(path))[0]
        n = ninja_generator.TestNinjaGenerator('jemalloc_integartion_test_' +
                                               name)
        n.add_include_paths('android/external/jemalloc/include',
                            'android/external/jemalloc/test/include')
        n.add_c_flags('-Werror')
        n.add_c_flags('-DJEMALLOC_INTEGRATION_TEST')
        if OPTIONS.enable_jemalloc_debug():
            n.add_c_flags('-DJEMALLOC_DEBUG')
        # Needs C99 for "restrict" keyword.
        n.add_c_flags('-std=gnu99')
        n.add_library_deps('libjemalloc.a')
        n.add_library_deps('libjemalloc_integrationtest.a')
        n.build_default([path])
        n.run(n.link(),
              enable_valgrind=OPTIONS.enable_valgrind(),
              rule='run_test')
예제 #7
0
파일: config.py 프로젝트: epowers/arc
def _generate_image_generator_ninja():
  n = ninja_generator.ExecNinjaGenerator(
      build_common.get_graphics_translation_image_generator_name(), host=True,
      base_path='mods/graphics_translation/tests')
  _add_compile_flags(n)
  n.add_defines('HAVE_PTHREADS')
  n.add_include_paths(
      staging.as_staging('android/external/chromium_org/testing/gtest/include'),
      staging.as_staging('android/external/chromium_org/testing/gtest/'))
  sources = build_common.find_all_files(
      ['mods/graphics_translation/tests'],
      suffixes='.cpp',
      include_tests=True,
      use_staging=False)
  sources.extend(
      ['mods/graphics_translation/gles/debug.cpp',
       'mods/graphics_translation/gles/texture_codecs.cpp',
       'src/common/vector.cc',
       'src/common/matrix.cc',
       staging.as_staging(
           'android/external/chromium_org/testing/gtest/src/gtest-all.cc')])
  sources = [x for x in sources if x.find('apk') < 0]
  n.build_default(sources, base_path=None)
  variables = {'my_static_libs': '-lX11 -lGL'}
  n.link(variables=variables)
예제 #8
0
파일: config.py 프로젝트: epowers/arc
def _generate_checkdeps_ninjas():
  if open_source.is_open_source_repo():
    # Do not run checkdeps on the open source repo since some directories
    # checked are not included there.
    return
  n = ninja_generator.NinjaGenerator('checkdeps', target_groups=['lint'])
  checkdeps_script = staging.as_staging(
      'native_client/tools/checkdeps/checkdeps.py')
  n.rule('checkdeps',
         command=('%s -v --root=$root $in_dir > $out.tmp 2>&1 '
                  '&& mv $out.tmp $out '
                  '|| (cat $out.tmp; rm $out.tmp; exit 1)' % checkdeps_script),
         description='checkdeps $in_dir')
  # Detect bad #include lines in src/.
  # TODO(crbug.com/323786): Check #include lines in mods/ too.
  src_dir = os.path.join(build_common.get_arc_root(), 'src')
  src_deps = os.path.join(src_dir, 'DEPS')
  for d in ['common', 'ndk_translation', 'posix_translation']:
    # TODO(crbug.com/323786): Check other directories in src/ too.
    implicit = build_common.find_all_files(
        os.path.join(src_dir, d),
        suffixes=['h', 'c', 'cc', 'cpp', 'java', 'DEPS'],
        include_tests=True, use_staging=False)
    implicit.extend([checkdeps_script, src_deps])
    out = os.path.join(build_common.OUT_DIR, 'checkdeps_%s.txt' % d)
    n.build(out, 'checkdeps', [],
            variables={'root': src_dir, 'in_dir': d},
            implicit=implicit)
예제 #9
0
파일: config.py 프로젝트: zhangpf/arc
def _generate_jemalloc_unit_tests():
    paths = build_common.find_all_files('android/external/jemalloc/test/unit',
                                        ['.c'],
                                        include_tests=True)

    # These tests need -DJEMALLOC_PROF which we do not enable.
    paths.remove('android/external/jemalloc/test/unit/prof_accum.c')
    paths.remove('android/external/jemalloc/test/unit/prof_accum_a.c')
    paths.remove('android/external/jemalloc/test/unit/prof_accum_b.c')
    paths.remove('android/external/jemalloc/test/unit/prof_gdump.c')
    paths.remove('android/external/jemalloc/test/unit/prof_idump.c')

    # Disable some multi-threaded tests flaky under ARM qemu.
    if OPTIONS.is_arm():
        paths.remove('android/external/jemalloc/test/unit/mq.c')
        paths.remove('android/external/jemalloc/test/unit/mtx.c')

    for path in paths:
        name = os.path.splitext(os.path.basename(path))[0]
        n = ninja_generator.TestNinjaGenerator('jemalloc_unit_test_' + name)
        n.add_include_paths('android/external/jemalloc/include',
                            'android/external/jemalloc/test/include')
        n.add_c_flags('-Werror')
        n.add_c_flags('-DJEMALLOC_UNIT_TEST')
        if OPTIONS.enable_jemalloc_debug():
            n.add_c_flags('-DJEMALLOC_DEBUG')
        # Needs C99 for "restrict" keyword.
        n.add_c_flags('-std=gnu99')
        n.add_library_deps('libjemalloc_jet.a')
        n.add_library_deps('libjemalloc_unittest.a')
        n.build_default([path])
        n.run(n.link(),
              enable_valgrind=OPTIONS.enable_valgrind(),
              rule='run_test')
예제 #10
0
파일: config.py 프로젝트: epowers/arc
def _generate_check_symbols_ninja():
  # If we do not use NDK direct execution, the compatibility is less
  # important.
  if not build_common.use_ndk_direct_execution():
    return

  n = ninja_generator.NinjaGenerator('check_symbols')
  script = staging.as_staging('src/build/check_symbols.py')
  rule_name = 'check_symbols'
  n.rule(rule_name,
         command=('src/build/run_python %s $android_lib $in %s' % (
             script, build_common.get_test_output_handler())),
         description=(rule_name + ' $in'))

  if OPTIONS.is_arm():
    arch_subdir = 'arch-arm'
  else:
    arch_subdir = 'arch-x86'
  lib_dir = os.path.join(_ANDROID_SYSTEM_IMAGE_DIR, arch_subdir, 'usr/lib')
  for so_file in build_common.find_all_files(lib_dir, suffixes='.so'):
    lib_name = os.path.basename(so_file)
    if lib_name not in ['libc.so', 'libdl.so', 'libm.so']:
      # For now, we only check Bionic.
      # TODO(crbug.com/408548): Extend this for other libraries.
      continue
    result_path = os.path.join(build_common.get_build_dir(),
                               'check_symbols',
                               'check_symbols.%s.result' % lib_name)
    n.build(result_path, rule_name,
            build_common.get_build_path_for_library(lib_name),
            variables={'android_lib': staging.as_staging(so_file)},
            implicit=[script, staging.as_staging(so_file)])
예제 #11
0
def _generate_checkdeps_ninjas():
    if open_source.is_open_source_repo():
        # Do not run checkdeps on the open source repo since some directories
        # checked are not included there.
        return
    n = ninja_generator.NinjaGenerator('checkdeps', target_groups=['lint'])
    checkdeps_script = staging.as_staging(
        'native_client/tools/checkdeps/checkdeps.py')
    n.rule('checkdeps',
           command=('%s -v --root=$root $in_dir > $out.tmp 2>&1 '
                    '&& mv $out.tmp $out '
                    '|| (cat $out.tmp; rm $out.tmp; exit 1)' %
                    checkdeps_script),
           description='checkdeps $in_dir')
    # Detect bad #include lines in src/.
    # TODO(crbug.com/323786): Check #include lines in mods/ too.
    src_dir = os.path.join(build_common.get_arc_root(), 'src')
    src_deps = os.path.join(src_dir, 'DEPS')
    for d in ['common', 'ndk_translation', 'posix_translation']:
        # TODO(crbug.com/323786): Check other directories in src/ too.
        implicit = build_common.find_all_files(
            os.path.join(src_dir, d),
            suffixes=['h', 'c', 'cc', 'cpp', 'java', 'DEPS'],
            include_tests=True,
            use_staging=False)
        implicit.extend([checkdeps_script, src_deps])
        out = os.path.join(build_common.OUT_DIR, 'checkdeps_%s.txt' % d)
        n.build(out,
                'checkdeps', [],
                variables={
                    'root': src_dir,
                    'in_dir': d
                },
                implicit=implicit)
예제 #12
0
파일: config.py 프로젝트: zhangpf/arc
def _generate_image_generator_ninja():
    n = ninja_generator.ExecNinjaGenerator(
        build_common.get_graphics_translation_image_generator_name(),
        host=True,
        base_path='mods/graphics_translation/tests')
    _add_compile_flags(n)
    n.add_defines('HAVE_PTHREADS')
    n.add_include_paths(
        staging.as_staging(
            'android/external/chromium_org/testing/gtest/include'),
        staging.as_staging('android/external/chromium_org/testing/gtest/'))
    sources = build_common.find_all_files(['mods/graphics_translation/tests'],
                                          suffixes='.cpp',
                                          include_tests=True,
                                          use_staging=False)
    sources.extend([
        'mods/graphics_translation/gles/debug.cpp',
        'mods/graphics_translation/gles/texture_codecs.cpp',
        'src/common/vector.cc', 'src/common/matrix.cc',
        staging.as_staging(
            'android/external/chromium_org/testing/gtest/src/gtest-all.cc')
    ])
    sources = [x for x in sources if x.find('apk') < 0]
    n.build_default(sources, base_path=None)
    variables = {'my_static_libs': '-lX11 -lGL'}
    n.link(variables=variables)
예제 #13
0
def _collect_descendants(paths):
   """Returns the set of descendant files of the directories in |paths|.

   If |paths| includes files in |paths|, the files are included in the returned
   set. Unnecessary files for running integration tests such as temporary files
   created by editor, .pyc, and .ncval files are excluded from the returned set.
   """
   files = [path for path in paths if os.path.isfile(path)]
   dirs = [path for path in paths if os.path.isdir(path)]
   files += build_common.find_all_files(dirs, include_tests=True,
                                        use_staging=False)
   files = [f for f in files if not re.match(r'.*\.(pyc|ncval)', f)]
   return set(files)
예제 #14
0
def _generate_lint_test_ninjas():
    n = ninja_generator.NinjaGenerator('analyze_diffs_test')
    script = 'src/build/analyze_diffs.py'
    n.rule('analyze_diffs_test_fail',
           command=('if %s --under_test $in > $output_path 2>&1; then '
                    '  echo "Expected failure, but there was none"; exit 1; '
                    'else '
                    '  if ! diff $output_path $in.fail > $out; then '
                    '    echo "Differences from expected errors:"; '
                    '    cat $out; '
                    '    rm -f $out; '
                    '    echo "To update: cp $output_path $in.fail"; '
                    '    exit 1; '
                    '  fi; '
                    'fi' % script),
           description='analyze_diffs_test_fail $in')
    n.rule('analyze_diffs_test_success',
           command=('if ! %s --under_test $in > $output_path 2>&1; then '
                    '  echo "Unexpected failure"; cat $output_path; exit 1; '
                    'elif [ -s $output_path ]; then '
                    '  echo "Succeeded but had unexpected output:"; '
                    '  cat $output_path; '
                    '  exit 1; '
                    'else '
                    '  touch $out; '
                    'fi' % script),
           description='analyze_diffs_test_success $in')
    all_mods = build_common.find_all_files([staging.TESTS_MODS_PATH],
                                           include_tests=True)
    out_dir = os.path.join(build_common.get_target_common_dir(),
                           'analyze_diff_tests')
    for f in all_mods:
        no_ext = os.path.splitext(f)[0]
        no_ext_relative = os.path.relpath(no_ext, staging.TESTS_MODS_PATH)
        out_path = os.path.join(out_dir, no_ext_relative)
        output_path = out_path + '.output'
        results_path = out_path + '.results'
        variables = {'output_path': output_path}

        rule = None
        if f.endswith('.fail'):
            rule = 'analyze_diffs_test_fail'
        elif f.endswith('.success'):
            rule = 'analyze_diffs_test_success'
        if rule is not None:
            n.build(results_path,
                    rule,
                    no_ext,
                    variables=variables,
                    implicit=[script],
                    use_staging=False)
예제 #15
0
def _collect_descendants(paths):
    """Returns the set of descendant files of the directories in |paths|.

   If |paths| includes files in |paths|, the files are included in the returned
   set. Unnecessary files for running integration tests such as temporary files
   created by editor, .pyc, and .ncval files are excluded from the returned set.
   """
    files = [path for path in paths if os.path.isfile(path)]
    dirs = [path for path in paths if os.path.isdir(path)]
    files += build_common.find_all_files(dirs,
                                         include_tests=True,
                                         use_staging=False)
    files = [f for f in files if not re.match(r'.*\.(pyc|ncval)', f)]
    return set(files)
예제 #16
0
파일: config.py 프로젝트: epowers/arc
def _generate_lint_test_ninjas():
  n = ninja_generator.NinjaGenerator('analyze_diffs_test')
  script = 'src/build/analyze_diffs.py'
  n.rule('analyze_diffs_test_fail',
         command=('if %s --under_test $in > $output_path 2>&1; then '
                  '  echo "Expected failure, but there was none"; exit 1; '
                  'else '
                  '  if ! diff $output_path $in.fail > $out; then '
                  '    echo "Differences from expected errors:"; '
                  '    cat $out; '
                  '    rm -f $out; '
                  '    echo "To update: cp $output_path $in.fail"; '
                  '    exit 1; '
                  '  fi; '
                  'fi' % script),
         description='analyze_diffs_test_fail $in')
  n.rule('analyze_diffs_test_success',
         command=('if ! %s --under_test $in > $output_path 2>&1; then '
                  '  echo "Unexpected failure"; cat $output_path; exit 1; '
                  'elif [ -s $output_path ]; then '
                  '  echo "Succeeded but had unexpected output:"; '
                  '  cat $output_path; '
                  '  exit 1; '
                  'else '
                  '  touch $out; '
                  'fi' % script),
         description='analyze_diffs_test_success $in')
  all_mods = build_common.find_all_files([staging.TESTS_MODS_PATH],
                                         include_tests=True)
  out_dir = os.path.join(build_common.get_target_common_dir(),
                         'analyze_diff_tests')
  for f in all_mods:
    no_ext = os.path.splitext(f)[0]
    no_ext_relative = os.path.relpath(no_ext, staging.TESTS_MODS_PATH)
    out_path = os.path.join(out_dir, no_ext_relative)
    output_path = out_path + '.output'
    results_path = out_path + '.results'
    variables = {'output_path': output_path}

    rule = None
    if f.endswith('.fail'):
      rule = 'analyze_diffs_test_fail'
    elif f.endswith('.success'):
      rule = 'analyze_diffs_test_success'
    if rule is not None:
      n.build(results_path, rule, no_ext, variables=variables,
              implicit=[script], use_staging=False)
예제 #17
0
파일: config.py 프로젝트: zhangpf/arc
def _generate_libposix_translation():
  compiler_flags = [
      '-Werror', '-fvisibility=hidden', '-fvisibility-inlines-hidden']

  n = ninja_generator.ArchiveNinjaGenerator(
      'libposix_translation_static',
      # libart-gtest and libposix_translation need this
      force_compiler='clang',
      enable_cxx11=True)
  n.add_compiler_flags(*compiler_flags)
  if OPTIONS.is_posix_translation_debug():
    n.add_defines('DEBUG_POSIX_TRANSLATION')
  if OPTIONS.use_verbose_memory_viewer():
    n.add_defines('USE_VERBOSE_MEMORY_VIEWER')
  # For functions in chromium_org/base/ and private headers in ppapi/.
  # TODO(crbug.com/234789): Use public API so that we can depend on
  # nacl_pepper_path instead.
  n.add_ppapi_compile_flags()
  n.add_libchromium_base_compile_flags()
  all_files = build_common.find_all_files(['src/posix_translation'],
                                          ['.cc'])
  n.build_default(all_files).archive()

  n = ninja_generator.SharedObjectNinjaGenerator(
      'libposix_translation',
      is_system_library=True,
      force_compiler='clang',
      enable_cxx11=True)
  n.add_library_deps('libc.so', 'libm.so', 'libdl.so', 'libstlport.so')
  n.add_whole_archive_deps('libposix_translation_static.a')
  # Statically link libchromium_base.a so that we can use unwrapped version of
  # the library.
  # TODO(crbug.com/423063, crbug.com/336316): Statically link libcommon.a into
  # the DSO too for more safety.
  n.add_library_deps('libchromium_base.a')
  n.add_compiler_flags(*compiler_flags)
  n.add_ppapi_link_flags()
  n.build_default([]).link()
예제 #18
0
def _walk(path):
    """List all files under |path|, including subdirectories."""
    return build_common.find_all_files(path,
                                       use_staging=False,
                                       include_tests=True)
예제 #19
0
def _walk(path):
    """List all files under |path|, including subdirectories."""
    return build_common.find_all_files(path, use_staging=False, include_tests=True)