コード例 #1
0
def test_validate_fuzzer_config():
    """Tests that validate_fuzzer_config says that a valid fuzzer config name is
    valid and that an invalid one is not."""
    config = {'fuzzer': 'afl', 'name': 'name', 'env': {'a': 'b'}}
    run_experiment.validate_fuzzer_config(config)

    with pytest.raises(Exception) as exception:
        config['fuzzer'] = 'afl:'
        run_experiment.validate_fuzzer_config(config)
    assert 'may only contain' in str(exception.value)

    with pytest.raises(Exception) as exception:
        config['fuzzer'] = 'not_exist'
        run_experiment.validate_fuzzer_config(config)
    assert 'does not exist' in str(exception.value)
    config['fuzzer'] = 'afl'

    with pytest.raises(Exception) as exception:
        config['invalid_key'] = 'invalid'
        run_experiment.validate_fuzzer_config(config)
    assert 'Invalid entry' in str(exception.value)
    del config['invalid_key']

    with pytest.raises(Exception) as exception:
        config['env'] = []
        run_experiment.validate_fuzzer_config(config)
    assert 'must be a dict' in str(exception.value)
コード例 #2
0
def test_validate_fuzzer_config(mock_read):
    """Tests that validate_fuzzer_config says that a valid fuzzer config name is
    valid and that an invalid one is not."""
    mock_read.return_value = {
        'fuzzer': 'afl',
        'variant_name': 'name',
        'env': []
    }
    run_experiment.validate_fuzzer_config('test_fuzzer.yaml')

    with pytest.raises(Exception) as exception:
        mock_read.return_value['fuzzer'] = 'afl:'
        run_experiment.validate_fuzzer_config('test_fuzzer.yaml')
    assert 'may only contain' in str(exception.value)

    with pytest.raises(Exception) as exception:
        mock_read.return_value['fuzzer'] = 'not_exist'
        run_experiment.validate_fuzzer_config('test_fuzzer.yaml')
    assert 'does not exist' in str(exception.value)

    with pytest.raises(Exception) as exception:
        mock_read.return_value['invalid_key'] = 'invalid'
        run_experiment.validate_fuzzer_config('test_fuzzer.yaml')
    assert 'Invalid entry' in str(exception.value)
コード例 #3
0
def test_variant_configs_valid():
    """Ensure that all variant configs (variants.yaml files) are valid."""
    fuzzer_configs = fuzzer_utils.get_fuzzer_configs()
    for config in fuzzer_configs:
        run_experiment.validate_fuzzer_config(config)