From c32093befd2ec9ea02bdc35b2bce0c2e78eb6b27 Mon Sep 17 00:00:00 2001 From: Tyson Smith Date: Thu, 5 Dec 2024 13:14:45 -0800 Subject: [PATCH 1/2] fix: preserve full TestCase.input_fname Also round duration and include duration in test info even when it is zero. --- src/grizzly/common/storage.py | 12 ++++++------ src/grizzly/common/test_storage.py | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/grizzly/common/storage.py b/src/grizzly/common/storage.py index b960ff8c..3ee2569b 100644 --- a/src/grizzly/common/storage.py +++ b/src/grizzly/common/storage.py @@ -46,6 +46,9 @@ class TestFileMap: class TestCase: __slots__ = ( + "_files", + "_in_place", + "_root", "adapter_name", "assets", "assets_path", @@ -57,9 +60,6 @@ class TestCase: "input_fname", "timestamp", "version", - "_files", - "_in_place", - "_root", ) def __init__( @@ -326,14 +326,14 @@ def dump(self, dst_path: Path, include_details: bool = False) -> None: } if self.adapter_name: info["adapter"] = self.adapter_name - if self.duration: - info["duration"] = self.duration + if self.duration is not None: + info["duration"] = round(self.duration, 1) if self.env_vars: info["env"] = self.env_vars if self.hang: info["hang"] = self.hang if self.input_fname: - info["input"] = Path(self.input_fname).name + info["input"] = self.input_fname if self.timestamp: info["timestamp"] = self.timestamp if self.version: diff --git a/src/grizzly/common/test_storage.py b/src/grizzly/common/test_storage.py index f1758c60..98241b00 100644 --- a/src/grizzly/common/test_storage.py +++ b/src/grizzly/common/test_storage.py @@ -355,7 +355,14 @@ def test_testcase_14(tmp_path): assert (dst / "_assets_" / "asset.txt").is_file() -def test_testcase_15(tmp_path): +@mark.parametrize( + "duration, hang, https, input_fname", + [ + (1.2, True, True, "foo/test.name"), + (0, False, False, None), + ], +) +def test_testcase_15(tmp_path, duration, hang, https, input_fname): """test TestCase - dump, load and compare""" asset_path = tmp_path / "assets" asset_path.mkdir() @@ -364,11 +371,11 @@ def test_testcase_15(tmp_path): working = tmp_path / "working" with TestCase("a.html", "adpt") as org: # set non default values - org.duration = 1.23 + org.duration = duration org.env_vars = {"en1": "1", "en2": "2"} - org.https = not org.https - org.hang = not org.hang - org.input_fname = "infile" + org.https = https + org.hang = hang + org.input_fname = input_fname org.add_from_bytes(b"a", org.entry_point) org.assets = {"sample": asset.name} org.assets_path = asset_path From 62f737bcca7ded401b87be261114b9093cf59844 Mon Sep 17 00:00:00 2001 From: Tyson Smith Date: Thu, 5 Dec 2024 13:27:11 -0800 Subject: [PATCH 2/2] fix: don't automatically set TestCase.input_fname This should be done in the adapter if needed. --- src/grizzly/session.py | 2 +- src/grizzly/test_session.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/grizzly/session.py b/src/grizzly/session.py index ac6e4ec4..7e2ffc83 100644 --- a/src/grizzly/session.py +++ b/src/grizzly/session.py @@ -20,7 +20,7 @@ from .common.reporter import Reporter from .common.storage import TestCase -__all__ = ("SessionError", "LogOutputLimiter", "Session") +__all__ = ("LogOutputLimiter", "Session", "SessionError") __author__ = "Tyson Smith" __credits__ = ["Tyson Smith", "Jesse Schwartzentruber"] diff --git a/src/grizzly/test_session.py b/src/grizzly/test_session.py index 4ae4fcaa..71da1145 100644 --- a/src/grizzly/test_session.py +++ b/src/grizzly/test_session.py @@ -34,7 +34,6 @@ def setup(self, input_path, _server_map): def generate(self, testcase, _server_map): assert testcase.adapter_name == self.name - testcase.input_fname = self.fuzz["input"] testcase.add_from_bytes(b"test", testcase.entry_point) if self.remaining is not None: assert self.remaining > 0 @@ -101,7 +100,6 @@ def test_session_01(mocker, harness, profiling, coverage, relaunch, iters, runti runtime_limit=runtime, ) assert session.status.iteration == max_iters - assert session.status.test_name == "file.bin" assert target.close.call_count == max_iters / relaunch assert target.check_result.call_count == max_iters assert target.handle_hang.call_count == 0