|
16 | 16 | import collections |
17 | 17 | import gc |
18 | 18 | import glob |
| 19 | +import gzip |
19 | 20 | import multiprocessing |
20 | 21 | import json |
21 | 22 | import os |
@@ -614,10 +615,33 @@ def measure_snapshot_coverage( # pylint: disable=too-many-locals |
614 | 615 | # Generate profdata and transform it into json form. |
615 | 616 | snapshot_measurer.generate_coverage_information(cycle) |
616 | 617 |
|
| 618 | + # Compress and save the exported profdata snapshot. |
| 619 | + coverage_archive_zipped = os.path.join( |
| 620 | + snapshot_measurer.trial_dir, 'coverage', |
| 621 | + experiment_utils.get_coverage_archive_name(cycle) + '.gz') |
| 622 | + |
| 623 | + coverage_archive_dir = os.path.dirname(coverage_archive_zipped) |
| 624 | + if not os.path.exists(coverage_archive_dir): |
| 625 | + os.makedirs(coverage_archive_dir) |
| 626 | + |
| 627 | + with gzip.open(str(coverage_archive_zipped), 'wb') as compressed: |
| 628 | + with open(snapshot_measurer.cov_summary_file, 'rb') as uncompressed: |
| 629 | + # avoid saving warnings so we can direct import with pandas |
| 630 | + compressed.write(uncompressed.readlines()[-1]) |
| 631 | + |
| 632 | + coverage_archive_dst = exp_path.filestore(coverage_archive_zipped) |
| 633 | + if filestore_utils.cp(coverage_archive_zipped, |
| 634 | + coverage_archive_dst, |
| 635 | + expect_zero=False).retcode: |
| 636 | + snapshot_logger.warning('Coverage not found for cycle: %d.', cycle) |
| 637 | + return None |
| 638 | + |
| 639 | + os.remove(coverage_archive_zipped) # no reason to keep this around |
| 640 | + |
617 | 641 | # Run crashes again, parse stacktraces and generate crash signatures. |
618 | 642 | crashes = snapshot_measurer.process_crashes(cycle) |
619 | 643 |
|
620 | | - # Get the coverage of the new corpus units. |
| 644 | + # Get the coverage summary of the new corpus units. |
621 | 645 | branches_covered = snapshot_measurer.get_current_coverage() |
622 | 646 | fuzzer_stats_data = snapshot_measurer.get_fuzzer_stats(cycle) |
623 | 647 | snapshot = models.Snapshot(time=this_time, |
|
0 commit comments