Skip to content

Commit

Permalink
weird presubmit bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
addisoncrump committed Aug 9, 2024
1 parent 3f43fcf commit e3ce950
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ docker/generated.mk

# Vim backup files.
.*.swp

# Diff files from matplotlib
*-failed-diff.png
Binary file not shown.
27 changes: 7 additions & 20 deletions experiment/measurer/coverage_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,11 @@ def generate_coverage_summary_json(self):
def generate_coverage_report(self):
"""Generates the coverage report and stores in bucket."""
command = [
'llvm-cov',
'show',
'-format=html',
'llvm-cov', 'show', '-no-warn', '-format=html',
f'-path-equivalence=/,{self.source_files_dir}',
f'-output-dir={self.report_dir}',
'-Xdemangler',
'c++filt',
'-Xdemangler',
'-n',
self.binary_file,
f'-instr-profile={self.merged_profdata_file}',
'-no-warn'
f'-output-dir={self.report_dir}', '-Xdemangler', 'c++filt',
'-Xdemangler', '-n', self.binary_file,
f'-instr-profile={self.merged_profdata_file}'
]
result = new_process.execute(command, expect_zero=False)
if result.retcode != 0:
Expand Down Expand Up @@ -265,15 +258,9 @@ def generate_json_summary(coverage_binary,
"""Generates the json summary file from |coverage_binary|
and |profdata_file|."""
command = [
'llvm-cov',
'export',
'-format=text',
'-num-threads=1',
'-region-coverage-gt=0',
'-skip-expansions',
coverage_binary,
f'-instr-profile={profdata_file}',
'-no-warn'
'llvm-cov', 'export', '-no-warn', '-format=text', '-num-threads=1',
'-region-coverage-gt=0', '-skip-expansions', coverage_binary,
f'-instr-profile={profdata_file}'
]

if summary_only:
Expand Down
23 changes: 18 additions & 5 deletions experiment/measurer/measure_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import collections
import gc
import glob
import gzip
import multiprocessing
import json
import os
Expand Down Expand Up @@ -614,16 +615,28 @@ def measure_snapshot_coverage( # pylint: disable=too-many-locals
# Generate profdata and transform it into json form.
snapshot_measurer.generate_coverage_information(cycle)

# Save profdata snapshot.
coverage_archive_dst = exp_path.filestore(
os.path.join(snapshot_measurer.trial_dir, 'coverage',
experiment_utils.get_coverage_archive_name(cycle)))
if filestore_utils.cp(snapshot_measurer.cov_summary_file,
# Compress and save the exported profdata snapshot.
coverage_archive_zipped = os.path.join(
snapshot_measurer.trial_dir, 'coverage',
experiment_utils.get_coverage_archive_name(cycle) + '.gz')

coverage_archive_dir = os.path.dirname(coverage_archive_zipped)
if not os.path.exists(coverage_archive_dir):
os.makedirs(coverage_archive_dir)

with gzip.open(str(coverage_archive_zipped), 'wb') as compressed:
with open(snapshot_measurer.cov_summary_file, 'rb') as uncompressed:
compressed.write(uncompressed.read())

coverage_archive_dst = exp_path.filestore(coverage_archive_zipped)
if filestore_utils.cp(coverage_archive_zipped,
coverage_archive_dst,
expect_zero=False).retcode:
snapshot_logger.warning('Coverage not found for cycle: %d.', cycle)
return None

os.remove(coverage_archive_zipped) # no reason to keep this around

# Run crashes again, parse stacktraces and generate crash signatures.
crashes = snapshot_measurer.process_crashes(cycle)

Expand Down
5 changes: 2 additions & 3 deletions experiment/measurer/test_measure_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,10 @@ def test_generate_summary(mocked_get_coverage_binary, mocked_execute,
snapshot_measurer.generate_summary(CYCLE)

expected = [
'llvm-cov', 'export', '-format=text', '-num-threads=1',
'llvm-cov', 'export', '-no-warn', '-format=text', '-num-threads=1',
'-region-coverage-gt=0', '-skip-expansions',
'/work/coverage-binaries/benchmark-a/fuzz-target',
'-instr-profile=/reports/data.profdata',
'-no-warn'
'-instr-profile=/reports/data.profdata'
]

assert (len(mocked_execute.call_args_list)) == 1
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ redis==4.3.4
rq==1.11.1
scikit-posthocs==0.7.0
scipy==1.9.2
seaborn==0.12.0
seaborn==0.13.2
sqlalchemy==1.4.41
protobuf==3.20.3

Expand Down

0 comments on commit e3ce950

Please sign in to comment.