Skip to content

Commit

Permalink
[replay] Report results by default
Browse files Browse the repository at this point in the history
  • Loading branch information
tysmith committed Dec 27, 2023
1 parent 5d27e5c commit 1691b04
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 27 deletions.
4 changes: 2 additions & 2 deletions grizzly/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def __init__(self):
)
self.reporter_grp.add_argument(
"-l",
"-o",
"--logs",
default=Path.cwd(),
type=Path,
Expand Down Expand Up @@ -287,8 +288,7 @@ def sanity_check(self, args):
self.parser.error("--log-limit must be >= 0")
args.log_limit *= 1_048_576

# if logs is specified, we need it to be a directory (whether existent or not)
if args.logs and args.logs.is_file():
if args.logs.is_file():
self.parser.error("--logs cannot be a file")

if args.memory < 0:
Expand Down
4 changes: 0 additions & 4 deletions grizzly/reduce/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ class ReduceCommonArgs(ReplayCommonArgs):
def __init__(self):
"""Initialize argument parser."""
super().__init__()

# these arguments have defaults that vary from ReplayCommonArgs
self.parser.set_defaults(logs=Path.cwd())

reduce_args = self.parser.add_argument_group("Reduce Arguments")
reduce_args.add_argument(
"--no-analysis",
Expand Down
20 changes: 16 additions & 4 deletions grizzly/replay/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
class ReplayCommonArgs(CommonArgs):
def __init__(self):
super().__init__()
self.parser.set_defaults(logs=None)

replay_args = self.parser.add_argument_group("Replay Arguments")
replay_args.set_defaults(entry_point=None)
Expand Down Expand Up @@ -66,9 +65,6 @@ def sanity_check(self, args):
if args.idle_threshold and args.idle_delay <= 0:
self.parser.error("--idle-delay value must be positive")

if args.logs is None and (args.pernosco or args.rr):
self.parser.error("--logs must be set when using rr")

if args.min_crashes < 1:
self.parser.error("--min-crashes value must be positive")

Expand All @@ -85,6 +81,11 @@ def __init__(self):
super().__init__()
self.parser.add_argument("input", type=Path, nargs="+", help=LOCAL_INPUT_HELP)

self.reporter_grp.add_argument(
"--disable-reporting",
action="store_true",
help="Do not report or save results.",
)
self.launcher_grp.add_argument(
"--entry-point",
type=Path,
Expand All @@ -109,13 +110,24 @@ def __init__(self):
super().__init__()
self.parser.add_argument("input", type=int, help="Bugzilla BugID to replay")

self.reporter_grp.add_argument(
"--disable-reporting",
action="store_true",
help="Do not report or save results.",
)


class ReplayFuzzManagerIDArgs(ReplayCommonArgs):
def __init__(self):
"""Initialize argument parser."""
super().__init__()
self.parser.add_argument("input", type=int, help="FuzzManager ID to replay")

self.reporter_grp.add_argument(
"--disable-reporting",
action="store_true",
help="Do not report or save results.",
)
self.parser.add_argument(
"--test-index",
type=int,
Expand Down
2 changes: 1 addition & 1 deletion grizzly/replay/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def main(cls, args):
LOG.info("Results detected, signature does not match")
else:
LOG.info("No results detected")
if results and (args.logs or args.fuzzmanager):
if results and not args.disable_reporting:
# add target assets to test cases
if not target.asset_mgr.is_empty():
for test in testcases:
Expand Down
11 changes: 1 addition & 10 deletions grizzly/replay/test_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"""
unit tests for grizzly.replay.args
"""
from platform import system

from pytest import mark, param, raises
from pytest import mark, raises

from .args import ReplayArgs, ReplayFuzzManagerIDArgs, ReplayFuzzManagerIDQualityArgs

Expand Down Expand Up @@ -47,13 +45,6 @@ def test_replay_args_01(capsys, mocker, tmp_path):
(["--min-crashes", "0"], "error: --min-crashes value must be positive", 1),
# test invalid repeat value
(["--repeat", "-1"], "error: --repeat value must be positive", 1),
# test running with rr without --logs set
param(
["--rr"],
"error: --logs must be set when using rr",
1,
marks=[mark.skipif(system() != "Linux", reason="Linux only")],
),
# test missing signature file
(["--sig", "missing"], "error: signature file not found", 1),
# test --no-harness with multiple inputs
Expand Down
9 changes: 3 additions & 6 deletions grizzly/replay/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def test_main_01(mocker, server, tmp_path):
args = mocker.Mock(
any_crash=False,
asset=[],
disable_reporting=False,
entry_point=None,
fuzzmanager=False,
idle_delay=0,
Expand Down Expand Up @@ -133,7 +134,6 @@ def test_main_02(mocker, server, tmp_path, repro_results):
args = mocker.Mock(
any_crash=False,
asset=[],
fuzzmanager=False,
idle_delay=0,
idle_threshold=0,
ignore=[],
Expand Down Expand Up @@ -202,7 +202,6 @@ def test_main_03(mocker, load_plugin, load_testcases, signature, result):
# setup args
args = mocker.Mock(
asset=[],
fuzzmanager=False,
ignore=["timeout"] if signature else [],
input=["test"],
min_crashes=1,
Expand Down Expand Up @@ -295,6 +294,7 @@ def test_main_05(mocker, server, tmp_path):
# setup args
args = mocker.Mock(
asset=[["from_cmdline", str(asset)]],
disable_reporting=False,
entry_point=None,
fuzzmanager=False,
idle_delay=0,
Expand Down Expand Up @@ -370,7 +370,6 @@ def test_main_06(
(tmp_path / "test.html").touch()
args = mocker.Mock(
asset=[],
fuzzmanager=False,
idle_delay=0,
idle_threshold=0,
ignore=["fake", "timeout"],
Expand Down Expand Up @@ -420,6 +419,7 @@ def test_main_07(mocker, server, tmp_path):
args = mocker.Mock(
any_crash=False,
asset=[],
disable_reporting=False,
entry_point=None,
fuzzmanager=True,
idle_delay=0,
Expand Down Expand Up @@ -461,7 +461,6 @@ def test_main_08(mocker, tmp_path, https_supported):
adapter="fake",
binary=Path("bin"),
input=[tmp_path / "test.html"],
fuzzmanager=False,
launch_attempts=1,
min_crashes=1,
relaunch=1,
Expand Down Expand Up @@ -502,12 +501,10 @@ def test_main_09(mocker, server, tmp_path):
adapter="fake",
binary=Path("bin"),
entry_point=None,
fuzzmanager=False,
idle_delay=0,
idle_threshold=0,
input=[input_path],
launch_attempts=1,
logs=None,
min_crashes=1,
post_launch_delay=-1,
relaunch=1,
Expand Down

0 comments on commit 1691b04

Please sign in to comment.