def get_coverage(self, repo_path): """Returns the project coverage object for the project.""" try: if not self.filestore.download_coverage( self.COVERAGE_NAME, self.workspace.clusterfuzz_coverage): return None return get_coverage.FilesystemCoverage( repo_path, self.workspace.clusterfuzz_coverage) except (get_coverage.CoverageError, filestore.FilestoreError): return None
def setUp(self): _fuzzer_cov_data = _get_example_curl_coverage() self._expected_file_list = _get_expected_curl_covered_file_list() self.coverage_path = '/coverage' self.filesystem_coverage = get_coverage.FilesystemCoverage( REPO_PATH, self.coverage_path) self.setUpPyfakefs() self.fs.create_file(os.path.join(self.coverage_path, 'fuzzer_stats', FUZZ_TARGET + '.json'), contents=json.dumps(_fuzzer_cov_data))
def get_coverage(self, repo_path): """Returns the project coverage object for the project.""" _make_empty_dir_if_nonexistent(self.workspace.clusterfuzz_coverage) try: if not self.filestore.download_coverage( self.COVERAGE_NAME, self.workspace.clusterfuzz_coverage): logging.error('Could not download coverage.') return None return get_coverage.FilesystemCoverage( repo_path, self.workspace.clusterfuzz_coverage) except (get_coverage.CoverageError, filestore.FilestoreError): logging.error('Could not get coverage.') return None
def get_coverage(self, repo_path): """Returns the project coverage object for the project.""" _make_empty_dir_if_nonexistent(self.workspace.clusterfuzz_coverage) try: if not self.filestore.download_coverage( self.COVERAGE_NAME, self.workspace.clusterfuzz_coverage): logging.error('Could not download coverage.') return None return get_coverage.FilesystemCoverage( repo_path, self.workspace.clusterfuzz_coverage) except Exception as err: # pylint: disable=broad-except logging.error('Could not get coverage: %s.', err) return None
def test_relative_paths(self): """Tests that is_fuzz_target_affected works as intended when the covered files are relative paths.""" with mock.patch.object( get_coverage.FilesystemCoverage, 'get_files_covered_by_target', ) as get_files_covered_by_target: get_files_covered_by_target.return_value = [ '/work/build/../../src/systemd/src/basic/alloc-util.c' ] coverage = get_coverage.FilesystemCoverage('/', '/') self.assertTrue( affected_fuzz_targets.is_fuzz_target_affected( coverage, self.fuzz_target_path, ['/src/systemd/src/basic/alloc-util.c']))