Example #1
0
def get_coverage_build(dirpath, rev):
    """Gets a coverage build from a specified server.

    Args:
        dirpath (Path): Directory in which build is to be downloaded in.
        rev (str): Mercurial hash of the required revision

    Returns:
        Path: Path to the js coverage build
    """
    RUN_COV_LOG.info(
        "Obtaining coverage build zip file from TaskCluster, into %s",
        str(dirpath))

    extract_folder = dirpath / "cov-build"
    extract_folder.mkdir(parents=True,
                         exist_ok=True)  # Ensure this dir has been created

    # Use fuzzfetch to obtain build instead of wget
    build_flags = fuzzfetch.BuildFlags(asan=False,
                                       debug=False,
                                       fuzzing=True,
                                       coverage=True,
                                       valgrind=False)
    platform_ = fuzzfetch.fetch.Platform()

    obtained_build = fuzzfetch.Fetcher("js", "central", rev, build_flags,
                                       platform_)
    obtained_build.extract_build(str(extract_folder))

    RUN_COV_LOG.info("Coverage build zip file extracted to this folder: %s",
                     extract_folder.resolve())

    js_cov_bin_name = f'js{".exe" if platform.system() == "Windows" else ""}'
    js_cov_bin = extract_folder / "dist" / "bin" / js_cov_bin_name

    Path.chmod(js_cov_bin,
               Path.stat(js_cov_bin).st_mode
               | 0o111)  # Ensure the js binary is executable
    assert js_cov_bin.is_file()

    # Check that the binary is non-debug.
    assert not queryBuildConfiguration(js_cov_bin, "debug")
    assert queryBuildConfiguration(js_cov_bin, "coverage")

    js_cov_fmconf = extract_folder / "dist" / "bin" / f"{js_cov_bin_name}.fuzzmanagerconf"
    assert js_cov_fmconf.is_file()

    # Check that a coverage build with *.gcno files are present
    js_cov_unified_gcno = extract_folder / "js" / "src" / "Unified_cpp_js_src0.gcno"
    assert js_cov_unified_gcno.is_file()

    return js_cov_bin
Example #2
0
def test_hash_resolution():
    """
    Test shortened hashes are resolved
    """
    flags = fuzzfetch.BuildFlags(
        asan=False,
        tsan=False,
        debug=False,
        fuzzing=False,
        coverage=False,
        valgrind=False,
    )
    rev = "d1001fea6e4c66b98bb4983df49c6e47d2db5ceb"
    build = fuzzfetch.Fetcher("firefox", "central", rev[:12], flags)
    assert build.changeset == rev
Example #3
0
def test_nearest_retrieval(requested, expected, direction, is_namespace):
    """
    Attempt to retrieve a build near the supplied build_id
    """
    flags = fuzzfetch.BuildFlags(
        asan=False,
        tsan=False,
        debug=False,
        fuzzing=False,
        coverage=False,
        valgrind=False,
    )

    # Set freeze_time to a date ahead of the latest mock build
    with freeze_time("2020-08-05"):
        LOG.debug("looking for nearest to %s", requested)
        if is_namespace:
            if fuzzfetch.BuildTask.RE_DATE.match(requested):
                date = requested.replace("-", ".")
                build_id = (
                    "gecko.v2.mozilla-central.pushdate.%s.firefox.linux64-opt"
                    % date)
            else:
                build_id = (
                    "gecko.v2.mozilla-central.revision.%s.firefox.linux64-opt"
                    % requested)
        else:
            build_id = requested

        build = fuzzfetch.Fetcher("firefox",
                                  "central",
                                  build_id,
                                  flags,
                                  nearest=direction)
        if fuzzfetch.BuildTask.RE_DATE.match(expected):
            build_date = datetime.strftime(build.datetime, "%Y-%m-%d")
            assert build_date == expected
        else:
            assert fuzzfetch.BuildTask.RE_REV.match(expected)
            assert build.changeset == expected
Example #4
0
def get_builds_to_test():
    """Get permutations for testing build branches and flags"""
    possible_flags = (
        fuzzfetch.BuildFlags(asan=False,
                             debug=False,
                             fuzzing=False,
                             coverage=False,
                             valgrind=False),  # opt
        fuzzfetch.BuildFlags(asan=False,
                             debug=True,
                             fuzzing=False,
                             coverage=False,
                             valgrind=False),  # debug
        fuzzfetch.BuildFlags(asan=False,
                             debug=False,
                             fuzzing=False,
                             coverage=True,
                             valgrind=False),  # ccov
        fuzzfetch.BuildFlags(asan=True,
                             debug=False,
                             fuzzing=False,
                             coverage=False,
                             valgrind=False),  # asan-opt
        fuzzfetch.BuildFlags(asan=True,
                             debug=False,
                             fuzzing=True,
                             coverage=False,
                             valgrind=False),  # asan-opt-fuzzing
        fuzzfetch.BuildFlags(asan=False,
                             debug=True,
                             fuzzing=True,
                             coverage=False,
                             valgrind=False),  # debug-fuzzing
        fuzzfetch.BuildFlags(asan=False,
                             debug=False,
                             fuzzing=True,
                             coverage=True,
                             valgrind=False),  # ccov-fuzzing
        fuzzfetch.BuildFlags(asan=False,
                             debug=False,
                             fuzzing=False,
                             coverage=False,
                             valgrind=True))  # valgrind-opt
    possible_branches = ("central", "inbound")
    possible_os = ('Android', 'Darwin', 'Linux', 'Windows')
    possible_cpus = ('x86', 'x64', 'arm', 'arm64')

    for branch, flags, os_, cpu in itertools.product(possible_branches,
                                                     possible_flags,
                                                     possible_os,
                                                     possible_cpus):
        try:
            fuzzfetch.fetch.Platform(os_, cpu)
        except fuzzfetch.FetcherException:
            continue
        if flags.coverage and (os_ != "Linux" or cpu != 'x64'
                               or branch != 'central'):
            # coverage builds not done for android/macos/windows
            # coverage builds are only done on central
            continue
        elif flags.asan and cpu != 'x64':
            continue
        elif flags.debug and flags.fuzzing and os_ == 'Windows' and cpu == 'x64':
            continue
        elif flags.debug and flags.fuzzing and os_ == 'Darwin':
            continue
        elif flags.debug and flags.fuzzing and os_ == 'Linux' and cpu == 'x86':
            continue
        elif flags.valgrind and (os_ != 'Linux' or cpu != 'x64'):
            continue
        elif os_ == 'Darwin' and flags.asan and not flags.fuzzing:
            continue
        elif os_ == 'Android' and flags.debug and not flags.fuzzing and cpu != 'arm':
            continue
        elif os_ == 'Android' and flags.fuzzing and (cpu != 'x86' or flags.asan
                                                     or not flags.debug):
            continue
        elif os_ == "Windows" and flags.asan and branch not in {
                "central", "inbound"
        }:
            # asan builds for windows are only done for central/inbound
            continue
        elif os_ == "Windows" and flags.asan and (flags.fuzzing
                                                  or flags.debug):
            # windows only has asan-opt ?
            continue
        elif os_ == "Windows" and cpu != 'x64' and (flags.asan
                                                    or flags.fuzzing):
            # windows asan and fuzzing builds are x64 only atm
            continue
        else:
            yield pytest.param(branch, flags, os_, cpu)
Example #5
0
def get_builds_to_test():
    """Get permutations for testing build branches and flags"""
    possible_flags = (
        fuzzfetch.BuildFlags(asan=False,
                             debug=False,
                             fuzzing=False,
                             coverage=False),  # opt
        fuzzfetch.BuildFlags(asan=False,
                             debug=True,
                             fuzzing=False,
                             coverage=False),  # debug
        fuzzfetch.BuildFlags(asan=False,
                             debug=False,
                             fuzzing=False,
                             coverage=True),  # cov
        fuzzfetch.BuildFlags(asan=True,
                             debug=False,
                             fuzzing=False,
                             coverage=False),  # asan-opt
        fuzzfetch.BuildFlags(asan=True,
                             debug=True,
                             fuzzing=False,
                             coverage=False),  # asan-debug
        fuzzfetch.BuildFlags(asan=True,
                             debug=False,
                             fuzzing=True,
                             coverage=False))  # asan-fuzz
    possible_branches = ("central", "inbound", "esr", "beta", "release")

    for branch, flags, arch_32 in itertools.product(possible_branches,
                                                    possible_flags,
                                                    (False, True)):
        if arch_32 and (
                platform.machine() not in {"AMD64", "x86-64"}
                or  # only try 32-bit on 64-bit platforms
                platform.system() == "Darwin" or  # no 32-bit builds on macos
                flags.asan
                or flags.coverage):  # no 32-bit builds for asan or ccov
            yield pytest.param(branch, flags, arch_32, marks=pytest.mark.skip)
        elif platform.system(
        ) == "Linux" and flags.coverage and branch != "central":
            # coverage builds are only done on central
            yield pytest.param(branch, flags, arch_32, marks=pytest.mark.skip)
        elif platform.system(
        ) == "Linux" and flags.fuzzing and branch == "esr":
            # fuzzing builds not done on esr
            yield pytest.param(branch, flags, arch_32, marks=pytest.mark.skip)
        elif platform.system() == "Darwin" and (flags.asan or flags.coverage):
            # asan/coverage builds not done for macos yet
            yield pytest.param(branch, flags, arch_32, marks=pytest.mark.skip)
        elif platform.system() == "Windows" and flags.asan and branch not in {
                "central", "inbound"
        }:
            # asan builds for windows are only done for central/inbound
            yield pytest.param(branch, flags, arch_32, marks=pytest.mark.skip)
        elif platform.system() == "Windows" and flags.coverage:
            # coverage builds not done for windows yet
            yield pytest.param(branch, flags, arch_32, marks=pytest.mark.skip)
        elif platform.system() == "Windows" and flags.asan and (
                flags.fuzzing or flags.debug):
            # windows only has asan-opt ?
            yield pytest.param(branch, flags, arch_32, marks=pytest.mark.skip)
        elif platform.system() == "Windows" and flags.asan:
            # https://bugzilla.mozilla.org/show_bug.cgi?id=1394543
            yield pytest.param(branch, flags, arch_32, marks=pytest.mark.xfail)
        elif branch == "release":
            yield pytest.param(branch, flags, arch_32,
                               marks=pytest.mark.xfail)  # ?
        else:
            yield pytest.param(branch, flags, arch_32)
Example #6
0
def get_builds_to_test():
    """Get permutations for testing build branches and flags"""
    possible_flags = (
        # opt
        fuzzfetch.BuildFlags(
            asan=False,
            tsan=False,
            debug=False,
            fuzzing=False,
            coverage=False,
            valgrind=False,
        ),
        # debug
        fuzzfetch.BuildFlags(
            asan=False,
            tsan=False,
            debug=True,
            fuzzing=False,
            coverage=False,
            valgrind=False,
        ),
        # ccov
        fuzzfetch.BuildFlags(
            asan=False,
            tsan=False,
            debug=False,
            fuzzing=False,
            coverage=True,
            valgrind=False,
        ),
        # asan-opt
        fuzzfetch.BuildFlags(
            asan=True,
            tsan=False,
            debug=False,
            fuzzing=False,
            coverage=False,
            valgrind=False,
        ),
        # asan-opt-fuzzing
        fuzzfetch.BuildFlags(
            asan=True,
            tsan=False,
            debug=False,
            fuzzing=True,
            coverage=False,
            valgrind=False,
        ),
        # tsan-opt
        fuzzfetch.BuildFlags(
            asan=False,
            tsan=True,
            debug=False,
            fuzzing=False,
            coverage=False,
            valgrind=False,
        ),
        # tsan-opt-fuzzing
        fuzzfetch.BuildFlags(
            asan=False,
            tsan=True,
            debug=False,
            fuzzing=True,
            coverage=False,
            valgrind=False,
        ),
        # debug-fuzzing
        fuzzfetch.BuildFlags(
            asan=False,
            tsan=False,
            debug=True,
            fuzzing=True,
            coverage=False,
            valgrind=False,
        ),
        # ccov-fuzzing
        fuzzfetch.BuildFlags(
            asan=False,
            tsan=False,
            debug=False,
            fuzzing=True,
            coverage=True,
            valgrind=False,
        ),
        # valgrind-opt
        fuzzfetch.BuildFlags(
            asan=False,
            tsan=False,
            debug=False,
            fuzzing=False,
            coverage=False,
            valgrind=True,
        ),
    )
    possible_branches = ("central", "try", "esr-next", "esr-stable")
    possible_os = ("Android", "Darwin", "Linux", "Windows")
    possible_cpus = ("x86", "x64", "arm", "arm64")

    for branch, flags, os_, cpu in itertools.product(possible_branches,
                                                     possible_flags,
                                                     possible_os,
                                                     possible_cpus):
        try:
            fuzzfetch.fetch.Platform(os_, cpu)
        except fuzzfetch.FetcherException:
            continue
        if flags.coverage and (os_ != "Linux" or cpu != "x64"
                               or branch != "central"):
            # coverage builds not done for android/macos/windows
            # coverage builds are only done on central
            continue
        if flags.asan and cpu != "x64":
            continue
        if flags.tsan and (cpu != "x64" or os_ != "Linux"):
            continue
        if flags.tsan and branch.startswith("esr"):
            continue
        if flags.debug and flags.fuzzing and os_ == "Windows" and cpu == "x64":
            continue
        if flags.debug and flags.fuzzing and os_ == "Darwin":
            continue
        if flags.debug and flags.fuzzing and os_ == "Linux" and cpu == "x86":
            continue
        if flags.valgrind and (os_ != "Linux" or cpu != "x64"):
            continue
        if os_ == "Darwin" and flags.asan and not flags.fuzzing:
            continue
        if os_ == "Android" and flags.debug and not flags.fuzzing and cpu != "arm":
            continue
        if (os_ == "Android" and flags.fuzzing
                and (cpu != "x86" or flags.asan or not flags.debug)):
            continue
        if os_ == "Android" and not flags.fuzzing and flags.asan:
            continue
        if os_ == "Windows" and flags.asan and branch != "central":
            # asan builds for windows are only done for central
            continue
        if os_ == "Windows" and flags.asan and (flags.fuzzing or flags.debug):
            # windows only has asan-opt ?
            continue
        if os_ == "Windows" and cpu != "x64" and (flags.asan or flags.fuzzing):
            # windows asan and fuzzing builds are x64 only atm
            continue
        if os_ == "Android" and branch in {"esr-next", "esr-stable"}:
            continue
        if not all(flags) and branch.startswith("esr"):
            # opt builds aren't available for esr
            continue
        if branch == "esr-stable":
            if cpu.startswith("arm"):
                # arm builds aren't available for esr-stable
                continue

        yield pytest.param(branch, flags, os_, cpu)