Exemple #1
0
    def test_empty_weights(self):
        """Ensure that we select with even weights if none are specified."""
        fuzzer_selection.select_fuzz_target(['target_0', 'target_1'], {})

        expected_target_0 = fuzzer_selection.WeightedTarget('target_0', 1.0)
        expected_target_1 = fuzzer_selection.WeightedTarget('target_1', 1.0)
        self.mock.random_weighted_choice.assert_called_once_with(
            [expected_target_0, expected_target_1])
Exemple #2
0
    def test_weights_for_some_targets(self):
        """Ensure that we use weights we applicable, and defaults where not."""
        fuzzer_selection.select_fuzz_target(
            ['weighted_0', 'weighted_1', 'unweighted_0'], {
                'weighted_0': 2.0,
                'weighted_1': 0.5
            })

        expected_weighted_0 = fuzzer_selection.WeightedTarget(
            'weighted_0', 2.0)
        expected_weighted_1 = fuzzer_selection.WeightedTarget(
            'weighted_1', 0.5)
        expected_unweighted_0 = fuzzer_selection.WeightedTarget(
            'unweighted_0', 1.0)

        self.mock.random_weighted_choice.assert_called_once_with(
            [expected_weighted_0, expected_weighted_1, expected_unweighted_0])