aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/cifuzz
diff options
context:
space:
mode:
Diffstat (limited to 'infra/cifuzz')
-rw-r--r--infra/cifuzz/clusterfuzz_deployment.py27
-rw-r--r--infra/cifuzz/clusterfuzz_deployment_test.py8
-rw-r--r--infra/cifuzz/filestore/github_actions/__init__.py2
-rw-r--r--infra/cifuzz/fuzz_target.py3
-rw-r--r--infra/cifuzz/fuzz_target_test.py2
5 files changed, 30 insertions, 12 deletions
diff --git a/infra/cifuzz/clusterfuzz_deployment.py b/infra/cifuzz/clusterfuzz_deployment.py
index fe5d8814..ef09723d 100644
--- a/infra/cifuzz/clusterfuzz_deployment.py
+++ b/infra/cifuzz/clusterfuzz_deployment.py
@@ -109,8 +109,10 @@ class ClusterFuzzLite(BaseClusterFuzzDeployment):
build_name = self._get_build_name()
try:
+ logging.info('Downloading latest build.')
if self.filestore.download_latest_build(build_name,
self.workspace.clusterfuzz_build):
+ logging.info('Done downloading latest build.')
return self.workspace.clusterfuzz_build
except Exception as err: # pylint: disable=broad-except
logging.error('Could not download latest build because of: %s', err)
@@ -119,11 +121,12 @@ class ClusterFuzzLite(BaseClusterFuzzDeployment):
def download_corpus(self, target_name):
corpus_dir = self.make_empty_corpus_dir(target_name)
- logging.debug('ClusterFuzzLite: downloading corpus for %s to %s.',
- target_name, corpus_dir)
+ logging.info('Downloading corpus for %s to %s.', target_name, corpus_dir)
corpus_name = self._get_corpus_name(target_name)
try:
self.filestore.download_corpus(corpus_name, corpus_dir)
+ logging.info('Done downloading corpus. Contains %d elements.',
+ len(os.listdir(corpus_dir)))
except Exception as err: # pylint: disable=broad-except
logging.error('Failed to download corpus for target: %s. Error: %s',
target_name, str(err))
@@ -141,38 +144,42 @@ class ClusterFuzzLite(BaseClusterFuzzDeployment):
return 'crashes'
def upload_corpus(self, target_name):
- """Upload the corpus produced by |target_name| in |corpus_dir|."""
+ """Upload the corpus produced by |target_name|."""
corpus_dir = self.get_target_corpus_dir(target_name)
logging.info('Uploading corpus in %s for %s.', corpus_dir, target_name)
name = self._get_corpus_name(target_name)
try:
self.filestore.upload_directory(name, corpus_dir)
+ logging.info('Done uploading corpus.')
except Exception as error: # pylint: disable=broad-except
logging.error('Failed to upload corpus for target: %s. Error: %s.',
target_name, error)
def upload_latest_build(self):
- logging.info('Uploading latest build in %s.',
- self.workspace.clusterfuzz_build)
+ """Upload the build produced by CIFuzz as the latest build."""
+ logging.info('Uploading latest build in %s.', self.workspace.out)
build_name = self._get_build_name()
try:
- return self.filestore.upload_directory(build_name,
- self.workspace.clusterfuzz_build)
+ result = self.filestore.upload_directory(build_name, self.workspace.out)
+ logging.info('Done uploading latest build.')
+ return result
except Exception as error: # pylint: disable=broad-except
logging.error('Failed to upload latest build: %s. Error: %s',
- self.workspace.clusterfuzz_build, error)
+ self.workspace.out, error)
def upload_crashes(self):
+ """Uploads crashes."""
if not os.listdir(self.workspace.artifacts):
logging.info('No crashes in %s. Not uploading.', self.workspace.artifacts)
return
crashes_artifact_name = self._get_crashes_artifact_name()
- logging.info('Uploading crashes in %s', self.workspace.artifacts)
+ logging.info('Uploading crashes in %s.', self.workspace.artifacts)
try:
self.filestore.upload_directory(crashes_artifact_name,
self.workspace.artifacts)
+ logging.info('Done uploading crashes.')
except Exception as error: # pylint: disable=broad-except
logging.error('Failed to upload crashes. Error: %s', error)
@@ -239,12 +246,14 @@ class OSSFuzz(BaseClusterFuzzDeployment):
if not latest_build_name:
return None
+ logging.info('Downloading latest build.')
oss_fuzz_build_url = utils.url_join(utils.GCS_BASE_URL,
self.CLUSTERFUZZ_BUILDS,
self.config.oss_fuzz_project_name,
latest_build_name)
if http_utils.download_and_unpack_zip(oss_fuzz_build_url,
self.workspace.clusterfuzz_build):
+ logging.info('Done downloading latest build.')
return self.workspace.clusterfuzz_build
return None
diff --git a/infra/cifuzz/clusterfuzz_deployment_test.py b/infra/cifuzz/clusterfuzz_deployment_test.py
index 1c58a3f3..bf10e054 100644
--- a/infra/cifuzz/clusterfuzz_deployment_test.py
+++ b/infra/cifuzz/clusterfuzz_deployment_test.py
@@ -176,6 +176,14 @@ class ClusterFuzzLiteTest(fake_filesystem_unittest.TestCase):
build."""
self.assertIsNone(self.deployment.download_latest_build())
+ @mock.patch('filestore.github_actions.GithubActionsFilestore.'
+ 'upload_directory')
+ def test_upload_latest_build(self, mocked_upload_directory):
+ """Tests that upload_latest_build works as intended."""
+ self.deployment.upload_latest_build()
+ mocked_upload_directory.assert_called_with('build-address',
+ '/workspace/build-out')
+
class NoClusterFuzzDeploymentTest(fake_filesystem_unittest.TestCase):
"""Tests for NoClusterFuzzDeployment."""
diff --git a/infra/cifuzz/filestore/github_actions/__init__.py b/infra/cifuzz/filestore/github_actions/__init__.py
index c9d04e4a..60d81dcc 100644
--- a/infra/cifuzz/filestore/github_actions/__init__.py
+++ b/infra/cifuzz/filestore/github_actions/__init__.py
@@ -75,7 +75,7 @@ class GithubActionsFilestore(filestore.BaseFilestore):
def _find_artifact(self, name):
"""Finds an artifact using the GitHub API and returns it."""
- logging.debug('listing artifact')
+ logging.debug('Listing artifacts.')
artifacts = self._list_artifacts()
artifact = github_api.find_artifact(name, artifacts)
logging.debug('Artifact: %s.', artifact)
diff --git a/infra/cifuzz/fuzz_target.py b/infra/cifuzz/fuzz_target.py
index 178868fe..4f087ae4 100644
--- a/infra/cifuzz/fuzz_target.py
+++ b/infra/cifuzz/fuzz_target.py
@@ -187,6 +187,7 @@ class FuzzTarget: # pylint: disable=too-many-instance-attributes
ReproduceError if we can't attempt to reproduce the crash.
"""
if not os.path.exists(target_path):
+ logging.info('Target: %s does not exist.', target_path)
raise ReproduceError(f'Target {target_path} not found.')
os.chmod(target_path, stat.S_IRWXO)
@@ -278,7 +279,7 @@ class FuzzTarget: # pylint: disable=too-many-instance-attributes
logging.info('The crash is reproducible on previous build. '
'Code change (pr/commit) did not introduce crash.')
return False
- logging.info('The crash doesn\'t reproduce on previous build. '
+ logging.info('The crash is not reproducible on previous build. '
'Code change (pr/commit) introduced crash.')
return True
diff --git a/infra/cifuzz/fuzz_target_test.py b/infra/cifuzz/fuzz_target_test.py
index 8411a854..5e65d02a 100644
--- a/infra/cifuzz/fuzz_target_test.py
+++ b/infra/cifuzz/fuzz_target_test.py
@@ -195,7 +195,7 @@ class IsCrashReportableTest(fake_filesystem_unittest.TestCase):
self.test_target.out_dir = tmp_dir
self.assertTrue(self.test_target.is_crash_reportable(self.testcase_path))
mocked_info.assert_called_with(
- 'The crash doesn\'t reproduce on previous build. '
+ 'The crash is not reproducible on previous build. '
'Code change (pr/commit) introduced crash.')
# yapf: disable