Skip to content

Commit

Permalink
✏️ fix words and unnecessary files
Browse files Browse the repository at this point in the history
  • Loading branch information
MeditationDuck committed Oct 10, 2024
1 parent 88f6daa commit c3edb7f
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 68 deletions.
8 changes: 0 additions & 8 deletions wake/.gitignore

This file was deleted.

24 changes: 12 additions & 12 deletions wake/cli/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,19 +443,19 @@ def get_shrink_argument_path(shrink_path_str) -> Path:
raise click.BadParameter(f"Invalid crash log index: {index}")
return Path(crash_logs[index])

def get_shrank_argument_path(shrinked_path_str) -> Path:
def get_shrank_argument_path(shrank_path_str) -> Path:
try:
shrinked_path = Path(shrinked_path_str)
if not shrinked_path.exists():
raise ValueError(f"Shrinked file not found: {shrinked_path}")
return shrinked_path
shrank_path = Path(shrank_path_str)
if not shrank_path.exists():
raise ValueError(f"Shrank data file not found: {shrank_path}")
return shrank_path
except ValueError:
pass
shrank_data_path = get_config().project_root_path / ".wake" / "logs" / "shrinked"
shrank_data_path = get_config().project_root_path / ".wake" / "logs" / "shrank"
if not shrank_data_path.exists():
raise click.BadParameter(f"Shrinked file not found: {shrank_data_path}")
raise click.BadParameter(f"Shrank data file not found: {shrank_data_path}")

index = int(shrinked_path_str)
index = int(shrank_path_str)
shrank_files = sorted(shrank_data_path.glob("*.bin"), key=os.path.getmtime, reverse=True)
if abs(index) > len(shrank_files):
raise click.BadParameter(f"Invalid crash log index: {index}")
Expand All @@ -478,19 +478,19 @@ def get_shrank_argument_path(shrinked_path_str) -> Path:
assert beginning_random_state_bytes is not None, "Unexpected file format"
set_sequence_initial_internal_state(beginning_random_state_bytes)
if pytest_path_specified:
assert path == pytest_args[0], "Shrinked test file path must be same as the test file path in pytest_args"
assert path == pytest_args[0], "crash log file path must be same as the test file path in pytest_args"
else:
pytest_args.insert(0, path)

if shrank:
set_fuzz_mode(2)
shrank_data_path = get_shrank_argument_path(shrank)
from wake.testing.fuzzing.fuzz_shrink import ShrinkedInfoFile
from wake.testing.fuzzing.fuzz_shrink import ShrankInfoFile
with open(shrank_data_path, 'rb') as f:
store_data: ShrinkedInfoFile = pickle.load(f)
store_data: ShrankInfoFile = pickle.load(f)
target_fuzz_path = store_data.target_fuzz_path
if pytest_path_specified:
assert target_fuzz_path == pytest_args[0], "Shrinked test file path must be same as the test file path in pytest_args"
assert target_fuzz_path == pytest_args[0], "Shrank data file path must be same as the test file path in pytest_args"
else:
pytest_args.insert(0, target_fuzz_path)
set_shrank_path(shrank_data_path)
Expand Down
Empty file removed wake/scripts/__init__.py
Empty file.
8 changes: 0 additions & 8 deletions wake/scripts/deploy.py

This file was deleted.

18 changes: 9 additions & 9 deletions wake/testing/fuzzing/fuzz_shrink.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class FlowStateForFile:
before_inv_random_state: bytes = b""

@dataclass
class ShrinkedInfoFile:
class ShrankInfoFile:
target_fuzz_path: str
initial_state: bytes
required_flows: List[FlowStateForFile]
Expand Down Expand Up @@ -195,11 +195,11 @@ def shrank_reproduce(test_class: type[FuzzTest], dry_run: bool = False):

flows: List[Callable] = __get_methods(test_instance, "flow")
invariants: List[Callable] = __get_methods(test_instance, "invariant")
shrinked_path = get_shrank_path()
if shrinked_path is None:
raise Exception("Shrinked path not found")
with open(shrinked_path, 'rb') as f:
store_data: ShrinkedInfoFile = pickle.load(f)
shrank_path = get_shrank_path()
if shrank_path is None:
raise Exception("Shrank data file path not found")
with open(shrank_path, 'rb') as f:
store_data: ShrankInfoFile = pickle.load(f)

random.setstate(pickle.loads(store_data.initial_state))
test_instance._flow_num = 0
Expand Down Expand Up @@ -582,7 +582,7 @@ def shrink_test(test_class: type[FuzzTest], flows_count: int):
print("")
project_root_path = get_config().project_root_path

crash_logs_dir = project_root_path / ".wake" / "logs" / "shrinked"
crash_logs_dir = project_root_path / ".wake" / "logs" / "shrank"

crash_logs_dir.mkdir(parents=True, exist_ok=True)
# write crash log file.
Expand Down Expand Up @@ -610,15 +610,15 @@ def shrink_test(test_class: type[FuzzTest], flows_count: int):
before_inv_random_state=flow_states[i].before_inv_random_state
))

store_data: ShrinkedInfoFile = ShrinkedInfoFile(
store_data: ShrankInfoFile = ShrankInfoFile(
target_fuzz_path=relative_test_path,
initial_state=get_sequence_initial_internal_state(),
required_flows=required_flows
)
# Write to a JSON file
with open(crash_log_file, 'wb') as f:
pickle.dump(store_data, f)
print(f"shrinked file written to {crash_log_file}")
print(f"Shrank data file written to {crash_log_file}")



Expand Down
Empty file removed wake/tests/__init__.py
Empty file.
11 changes: 0 additions & 11 deletions wake/tests/test_default.py

This file was deleted.

20 changes: 0 additions & 20 deletions wake/wake.toml

This file was deleted.

0 comments on commit c3edb7f

Please sign in to comment.