Skip to content

Commit d951635

Browse files
authored
Upload crash artifacts per target by its name. (#6660)
Rather than always upload to the "current" artifact.
1 parent f460c03 commit d951635

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

infra/cifuzz/clusterfuzz_deployment.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,6 @@ def _get_corpus_name(self, target_name): # pylint: disable=no-self-use
148148
"""Returns the name of the corpus artifact."""
149149
return target_name
150150

151-
def _get_crashes_artifact_name(self): # pylint: disable=no-self-use
152-
"""Returns the name of the crashes artifact."""
153-
return 'current'
154-
155151
def upload_corpus(self, target_name, corpus_dir, replace=False):
156152
"""Upload the corpus produced by |target_name|."""
157153
logging.info('Uploading corpus in %s for %s.', corpus_dir, target_name)
@@ -177,19 +173,24 @@ def upload_build(self, commit):
177173

178174
def upload_crashes(self):
179175
"""Uploads crashes."""
180-
if not os.listdir(self.workspace.artifacts):
176+
artifact_dirs = os.listdir(self.workspace.artifacts)
177+
if not artifact_dirs:
181178
logging.info('No crashes in %s. Not uploading.', self.workspace.artifacts)
182179
return
183180

184-
crashes_artifact_name = self._get_crashes_artifact_name()
181+
for crash_target in artifact_dirs:
182+
artifact_dir = os.path.join(self.workspace.artifacts, crash_target)
183+
if not os.path.isdir(artifact_dir):
184+
logging.warning('%s is not an expected artifact directory, skipping.',
185+
crash_target)
186+
continue
185187

186-
logging.info('Uploading crashes in %s.', self.workspace.artifacts)
187-
try:
188-
self.filestore.upload_crashes(crashes_artifact_name,
189-
self.workspace.artifacts)
190-
logging.info('Done uploading crashes.')
191-
except Exception as error: # pylint: disable=broad-except
192-
logging.error('Failed to upload crashes. Error: %s', error)
188+
logging.info('Uploading crashes in %s.', artifact_dir)
189+
try:
190+
self.filestore.upload_crashes(crash_target, artifact_dir)
191+
logging.info('Done uploading crashes.')
192+
except Exception as error: # pylint: disable=broad-except
193+
logging.error('Failed to upload crashes. Error: %s', error)
193194

194195
def upload_coverage(self):
195196
"""Uploads the coverage report to the filestore."""

0 commit comments

Comments
 (0)