Esempio n. 1
0
def get_files_dependent_fuzzers(dependency_files: List[str]) -> List[str]:
    """Returns a list of fuzzer names dependent on |dependency_files|."""
    dependency_files = set(dependency_files)
    dependent_fuzzers = []
    for fuzzer_config in FUZZER_CONFIGS:
        fuzzer = fuzzer_utils.get_fuzzer_from_config(fuzzer_config)
        fuzzer_dependencies = get_fuzzer_dependencies(fuzzer)

        if fuzzer_dependencies.intersection(dependency_files):
            dependent_fuzzers.append(fuzzer)

    return dependent_fuzzers
Esempio n. 2
0
def test_get_fuzzer_from_config(config, expected_result):
    """Test that get_fuzzer_from_config returns the variant for a
    variant and the fuzzer for a non-variant fuzzer."""
    assert fuzzer_utils.get_fuzzer_from_config(config) == expected_result
import pytest

from common import utils
from common import fuzzer_utils
from src_analysis import fuzzer_dependencies

# pylint: disable=protected-access,import-outside-toplevel

VARIANT = 'myvariant'
FUZZER = 'myfuzzer'
VARIANT_CONFIG = {'name': VARIANT, 'fuzzer': FUZZER}
FUZZER_CONFIG = {'fuzzer': FUZZER}
CONFIGS = [VARIANT_CONFIG, FUZZER_CONFIG]
FUZZER_NAMES_TO_UNDERLYING = {
    fuzzer_utils.get_fuzzer_from_config(config): config['fuzzer']
    for config in CONFIGS
}


def test_get_fuzzer_module_name():
    """Tests that get_fuzzer_module_name returns the correct module."""
    assert fuzzer_dependencies._get_fuzzer_module_name(
        FUZZER) == 'fuzzers.myfuzzer.fuzzer'


def test_is_builtin_module():
    """Tests that is_builtin_module returns the correct result for builtin
    modules and non-builtin modules."""
    import time
    assert fuzzer_dependencies.is_builtin_module(time)