Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove FuzzManagerReporter.quality #441

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 17 additions & 26 deletions grizzly/common/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,11 @@ def _post_submit(self) -> None:


class FuzzManagerReporter(Reporter):
__slots__ = ("_extra_metadata", "quality", "tool")
__slots__ = ("_extra_metadata", "tool")

def __init__(self, tool: str) -> None:
super().__init__()
self._extra_metadata: Dict[str, Any] = {}
self.quality = Quality.UNREDUCED
# remove whitespace and use only lowercase
self.tool = "-".join(tool.lower().split())
assert self.tool, "tool value cannot be empty"
Expand Down Expand Up @@ -262,25 +261,22 @@ def _submit_report(
if report.unstable:
self.add_extra_metadata("unstable_build", True)

# dump test cases and the contained files to working directory
test_case_meta = []
for test_number, test_case in enumerate(reversed(test_cases)):
test_case_meta.append([test_case.adapter_name, test_case.input_fname])
dump_path = report.path / f"{report.prefix}-{test_number}"
dump_path.mkdir(exist_ok=True)
test_case.dump(dump_path, include_details=True)
report.crash_info.configuration.addMetadata(
{"grizzly_input": repr(test_case_meta)}
)
if test_cases:
environ_string = " ".join(
"=".join(kv) for kv in test_cases[0].env_vars.items()
)
report.crash_info.configuration.addMetadata(
{"recorded_envvars": environ_string}
)
self.add_extra_metadata("testcase_count", len(test_cases))
# dump test cases and the contained files to working directory
for test_number, test_case in enumerate(reversed(test_cases)):
dump_path = report.path / f"{report.prefix}-{test_number}"
dump_path.mkdir(exist_ok=True)
test_case.dump(dump_path, include_details=True)
quality = Quality.UNREDUCED
if test_cases[0].env_vars:
# add environment variables to metadata
self.add_extra_metadata(
"recorded_envvars",
" ".join("=".join(kv) for kv in test_cases[0].env_vars.items()),
)
else:
self.quality = Quality.NO_TESTCASE
quality = Quality.NO_TESTCASE
report.crash_info.configuration.addMetadata(self._extra_metadata)

# grab screen log (used in automation)
Expand All @@ -302,12 +298,7 @@ def _submit_report(

# submit results to the FuzzManager server
new_entry = collector.submit(
report.crash_info, testCase=zip_name, testCaseQuality=self.quality.value
report.crash_info, testCase=zip_name, testCaseQuality=quality.value
)
LOG.info(
"Reported: %d, %s, %s",
new_entry["id"],
self.quality.name,
collector.tool,
)
LOG.info("Reported: %d, %s, %s", new_entry["id"], quality.name, collector.tool)
return cast(int, new_entry["id"])
12 changes: 12 additions & 0 deletions grizzly/common/test_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
FailedLaunchReporter,
FilesystemReporter,
FuzzManagerReporter,
Quality,
Reporter,
)
from .storage import TestCase
Expand Down Expand Up @@ -190,6 +191,17 @@ def test_fuzzmanager_reporter_01(mocker, tmp_path, tests, frequent, force, sig_c
assert fake_collector.return_value.submit.call_count == 1
if tests:
assert fake_test.dump.call_count == 1
if fake_collector.return_value.submit.call_count:
if tests:
assert (
fake_collector.return_value.submit.call_args.kwargs["testCaseQuality"]
!= Quality.NO_TESTCASE
)
else:
assert (
fake_collector.return_value.submit.call_args.kwargs["testCaseQuality"]
== Quality.NO_TESTCASE
)


@mark.parametrize(
Expand Down
Loading