def __exit__(self, exc_type, exc_value, traceback):
     # Unfortunately there are a lot of unicode files that python doesn't handle properly
     # so we will let windows handle it..
     if platform.system() == "Windows":
         run(["rmdir", "/s", "/q", self.name])
     else:
         shutil.rmtree(self.name)
def run_tests(out_dir, jobs, check_symbols, additional_opts):
    if check_symbols:
        run_symbols_test(out_dir)

    if platform.system() == "Windows":

        if "--skip-emulator-check" in additional_opts:
            pass
        else:
            run_binary_exists(out_dir)

        run_emugen_test(out_dir)
        run_ctest(out_dir, jobs)
    else:
        with TemporaryDirectory() as tmpdir:
            logging.info("Running tests with TMPDIR=%s", tmpdir)
            run(
                [
                    os.path.join(get_qemu_root(), "android", "scripts", "unix",
                                 "run_tests.sh"),
                    "--out-dir=%s" % out_dir,
                    "--verbose",
                    "--verbose",
                    "-j",
                    jobs,
                ] + additional_opts,
                out_dir,
                {"TMPDIR": tmpdir},
            )
Example #3
0
def configure():
    """Configures the cmake project."""

    # Clear out the existing directory.
    if FLAGS.clean:
        if os.path.exists(FLAGS.out):
            logging.info('Clearing out %s', FLAGS.out)
            shutil.rmtree(FLAGS.out)
        if not os.path.exists(FLAGS.out):
            os.makedirs(FLAGS.out)

    # Configure..
    cmake_cmd = [get_cmake(), '-B%s' % FLAGS.out]

    # Setup the right toolchain/compiler configuration.
    cmake_cmd += Toolchain.from_string(FLAGS.target).to_cmd()
    cmake_cmd += Crash.from_string(FLAGS.crash).to_cmd()
    cmake_cmd += BuildConfig.from_string(FLAGS.config).to_cmd()

    # Make darwin and msvc builds have QtWebEngine support for the default
    # build.
    if FLAGS.target == "darwin" or FLAGS.target == "windows":
        FLAGS.qtwebengine = True
    cmake_cmd += ['-DQTWEBENGINE=%s' % FLAGS.qtwebengine]

    if FLAGS.cmake_option:
        flags = ['-D%s' % x for x in FLAGS.cmake_option]
        logging.warn('Dangerously adding the following flags to cmake: %s',
                     flags)
        cmake_cmd += flags

    if FLAGS.sdk_revision:
        sdk_revision = FLAGS.sdk_revision
    else:
        sdk_revision = read_simple_properties(
            os.path.join(get_aosp_root(), 'external', 'qemu',
                         'source.properties'))['Pkg.Revision']
    cmake_cmd += ['-DOPTION_SDK_TOOLS_REVISION=%s' % sdk_revision]

    if FLAGS.sdk_build_number:
        cmake_cmd += [
            '-DOPTION_SDK_TOOLS_BUILD_NUMBER=%s' % FLAGS.sdk_build_number
        ]
    if FLAGS.sanitizer:
        cmake_cmd += ['-DOPTION_ASAN=%s' % (','.join(FLAGS.sanitizer))]

    if FLAGS.minbuild:
        cmake_cmd += ['-DOPTION_MINBUILD=%s' % FLAGS.minbuild]

    if FLAGS.gfxstream:
        cmake_cmd += ['-DGFXSTREAM=%s' % FLAGS.gfxstream]

    cmake_cmd += Generator.from_string(FLAGS.generator).to_cmd()
    cmake_cmd += [get_qemu_root()]

    # Make sure we fixup clang in windows builds
    if platform.system() == 'Windows':
        fixup_windows_clang()

    run(cmake_cmd, FLAGS.out)
def run_emugen_test(out_dir):
    emugen = os.path.abspath(os.path.join(out_dir, 'emugen%s' % EXE_POSTFIX))
    if platform.system() != 'Windows':
        cmd = [
            os.path.join(get_qemu_root(), 'android', 'android-emugl', 'host',
                         'tools', 'emugen', 'tests', 'run-tests.sh'),
            '--emugen=%s' % emugen
        ]
        run(cmd, out_dir)
    else:
        logging.info('gen_tests not supported on windows yet.')
def main(argv=None):
    del argv  # Unused.

    version = sys.version_info
    logging.info(
        "Running under Python {0[0]}.{0[1]}.{0[2]}, Platform: {1}".format(
            version, platform.platform()))

    configure()
    if FLAGS.build == "config":
        print("You can now build with: %s " % " ".join(get_build_cmd()))
        return

    # Build
    run(get_build_cmd())

    # Test.
    if FLAGS.tests:
        cross_compile = platform.system().lower() != FLAGS.target
        if not cross_compile:
            run_tests_opts = []
            if FLAGS.gfxstream or FLAGS.crosvm or FLAGS.gfxstream_only:
                run_tests_opts.append("--skip-emulator-check")

            run_tests(FLAGS.out, FLAGS.test_jobs, FLAGS.crash != "none",
                      run_tests_opts)
        else:
            logging.info("Not running tests for cross compile.")

    # Create a distribution if needed.
    if FLAGS.dist:
        data = {
            "aosp": get_aosp_root(),
            "target": FLAGS.target,
            "sdk_build_number": FLAGS.sdk_build_number,
            "config": FLAGS.config,
        }

        create_distribution(FLAGS.dist, FLAGS.out, data)

    if platform.system() != "Windows" and FLAGS.config == "debug":
        overrides = open(
            os.path.join(get_qemu_root(), "android", "asan_overrides")).read()
        print("Debug build enabled.")
        print(
            "ASAN may be in use; recommend disabling some ASAN checks as build is not"
        )
        print("universally ASANified. This can be done with")
        print()
        print(". android/envsetup.sh")
        print("")
        print("or export ASAN_OPTIONS=%s" % overrides)
def run_tests(out_dir, jobs, additional_opts):
    if platform.system() == 'Windows':
        run_binary_exists(out_dir)
        run_emugen_test(out_dir)
        run_ctest(out_dir, jobs)
    else:
        with TemporaryDirectory() as tmpdir:
            logging.info("Running tests with TMPDIR=%s", tmpdir)
            run([
                os.path.join(get_qemu_root(), 'android', 'scripts', 'unix',
                             'run_tests.sh'),
                '--out-dir=%s' % out_dir, '--verbose', '--verbose', '-j', jobs
            ] + additional_opts, out_dir, {'TMPDIR': tmpdir})
Example #7
0
def main(argv=None):
    del argv  # Unused.

    version = sys.version_info
    logging.info(
        'Running under Python {0[0]}.{0[1]}.{0[2]}, Platform: {1}'.format(
            version, platform.platform()))

    configure()
    if FLAGS.build == 'config':
        print('You can now build with: %s ' % ' '.join(get_build_cmd()))
        return

    # Build
    run(get_build_cmd())

    # Test.
    if FLAGS.tests:
        cross_compile = platform.system().lower() != FLAGS.target
        if not cross_compile:
            run_tests(FLAGS.out, FLAGS.test_jobs)
        else:
            logging.info("Not running tests for cross compile.")

    # Create a distribution if needed.
    if FLAGS.dist:
        data = {
            'aosp': get_aosp_root(),
            'target': FLAGS.target,
            'sdk_build_number': FLAGS.sdk_build_number,
            'config': FLAGS.config
        }

        create_distribution(FLAGS.dist, FLAGS.out, data)

    if platform.system() != 'Windows' and FLAGS.config == 'debug':
        overrides = open(
            os.path.join(get_qemu_root(), 'android', 'asan_overrides')).read()
        print("Debug build enabled.")
        print(
            "ASAN may be in use; recommend disabling some ASAN checks as build is not"
        )
        print("universally ASANified. This can be done with")
        print()
        print(". android/envsetup.sh")
        print("")
        print("or export ASAN_OPTIONS=%s" % overrides)
def run_emugen_test(out_dir):
    emugen = os.path.abspath(os.path.join(out_dir, "emugen%s" % EXE_POSTFIX))
    if platform.system() != "Windows":
        cmd = [
            os.path.join(
                get_qemu_root(),
                "android",
                "android-emugl",
                "host",
                "tools",
                "emugen",
                "tests",
                "run-tests.sh",
            ),
            "--emugen=%s" % emugen,
        ]
        run(cmd, out_dir)
    else:
        logging.info("gen_tests not supported on windows yet.")
def run_ctest(out_dir, jobs):
    cmd = [get_ctest(), "-j", jobs, "--output-on-failure"]
    with TemporaryDirectory() as tmpdir:
        logging.info("Running tests with TMP=%s", tmpdir)
        run(cmd, out_dir, {"TMP": tmpdir, "TEMP": tmpdir})
Example #10
0
def run_ctest(out_dir, jobs):
    cmd = [get_ctest(), '-j', jobs, '--output-on-failure']
    with TemporaryDirectory() as tmpdir:
        logging.info("Running tests with TMP=%s", tmpdir)
        run(cmd, out_dir, {'TMP': tmpdir, 'TEMP': tmpdir})