GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python-hwpx/scripts/fuzz/__main__.py at main · VerifiedIdiot/python-hwpx

Expand file tree

/

__main__.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
80 lines (65 loc) · 3.15 KB
/

__main__.py

Copy path

File metadata and controls

80 lines (65 loc) · 3.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# SPDX-License-Identifier: Apache-2.0
"""CLI for seeded HWPX fuzz convergence runs."""
from __future__ import annotations
import argparse
import json
import sys
from pathlib import Path
from .catalog import canonical_json_bytes, operation_catalog
from .runner import load_scenario, run_scenario, run_seed_range
def _parse_args(argv: list[str] | None) -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Run seeded HWPX fuzz scenarios")
subparsers = parser.add_subparsers(dest="command")
catalog_parser = subparsers.add_parser("catalog", help="print the operation catalog")
catalog_parser.set_defaults(command="catalog")
replay_parser = subparsers.add_parser("replay", help="replay one scenario JSON")
replay_parser.add_argument("scenario", help="scenario JSON path")
replay_parser.add_argument("--output", required=True, help="output .hwpx path")
replay_parser.add_argument("--result", help="write result JSON")
run_parser = subparsers.add_parser("run", help="run a seed range")
run_parser.add_argument("--start", type=int, default=0, help="first seed")
run_parser.add_argument("--count", type=int, default=1000, help="number of seeds")
run_parser.add_argument("--out-dir", required=True, help="directory for generated scenarios and HWPX files")
run_parser.add_argument("--report", required=True, help="report JSON path")
run_parser.add_argument("--max-operations", type=int, default=16)
run_parser.add_argument("--regression-dir", help="directory for fossilized failure fixtures")
run_parser.add_argument("--write-regressions", action="store_true", help="write minimized failure fixtures")
run_parser.add_argument("--sample-count", type=int, default=20)
run_parser.add_argument("--sample-dir", help="copy selected visual review samples here")
if argv is None:
argv = sys.argv[1:]
if not argv:
argv = ["run", *argv]
return parser.parse_args(argv)
def main(argv: list[str] | None = None) -> int:
args = _parse_args(argv)
if args.command == "catalog":
print(json.dumps([spec.to_dict() for spec in operation_catalog()], indent=2, sort_keys=True))
return 0
if args.command == "replay":
result = run_scenario(load_scenario(args.scenario), args.output)
payload = result.to_dict()
if args.result:
Path(args.result).write_bytes(canonical_json_bytes(payload) + b"\n")
print(json.dumps(payload, indent=2, sort_keys=True))
return 0 if result.ok else 1
report = run_seed_range(
start=args.start,
count=args.count,
output_dir=args.out_dir,
report_path=args.report,
regression_dir=args.regression_dir,
max_operations=args.max_operations,
write_regressions=args.write_regressions,
sample_count=args.sample_count,
sample_dir=args.sample_dir,
)
print(
"[OK] seeds "
f"{args.start}-{args.start + args.count - 1}: "
f"ok={report['okCount']} failures={report['failureCount']} "
f"report={args.report}"
)
return 0 if report["failureCount"] == 0 else 1
if __name__ == "__main__":
raise SystemExit(main())
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.