Ejemplo n.º 1
0
 def test_keeping_fuzzer_w_no_coverage(self):
   """Tests that a specific fuzzer is kept if it is deemed affected."""
   with tempfile.TemporaryDirectory() as tmp_dir, mock.patch.object(
       cifuzz, 'get_latest_cov_report_info', return_value=1):
     shutil.copy(self.test_fuzzer_1, tmp_dir)
     shutil.copy(self.test_fuzzer_2, tmp_dir)
     with mock.patch.object(cifuzz,
                            'get_files_covered_by_target',
                            side_effect=[[self.example_file_changed], None]):
       cifuzz.remove_unaffected_fuzzers(EXAMPLE_PROJECT, tmp_dir,
                                        [self.example_file_changed], '')
       self.assertEqual(2, len(os.listdir(tmp_dir)))
Ejemplo n.º 2
0
 def test_no_fuzzers_kept_fuzzer(self):
   """Tests that if there is no affected then all fuzzers are kept."""
   with tempfile.TemporaryDirectory() as tmp_dir, mock.patch.object(
       cifuzz, 'get_latest_cov_report_info', return_value=1):
     shutil.copy(self.test_fuzzer_1, tmp_dir)
     shutil.copy(self.test_fuzzer_2, tmp_dir)
     with mock.patch.object(cifuzz,
                            'get_files_covered_by_target',
                            side_effect=[None, None]):
       cifuzz.remove_unaffected_fuzzers(EXAMPLE_PROJECT, tmp_dir,
                                        [self.example_file_changed], '')
       self.assertEqual(2, len(os.listdir(tmp_dir)))
Ejemplo n.º 3
0
 def test_remove_unaffected_fuzzers(self, side_effect, expected_dir_len):
     """Tests that remove_unaffected_fuzzers has the intended effect."""
     with tempfile.TemporaryDirectory() as tmp_dir, mock.patch(
             'cifuzz.get_latest_cov_report_info', return_value=1):
         with mock.patch.object(
                 cifuzz, 'get_files_covered_by_target') as mocked_get_files:
             mocked_get_files.side_effect = side_effect
             shutil.copy(self.TEST_FUZZER_1, tmp_dir)
             shutil.copy(self.TEST_FUZZER_2, tmp_dir)
             cifuzz.remove_unaffected_fuzzers(EXAMPLE_PROJECT, tmp_dir,
                                              [EXAMPLE_FILE_CHANGED], '')
             self.assertEqual(expected_dir_len, len(os.listdir(tmp_dir)))