| 300 | |
| 301 | |
| 302 | def main(): |
| 303 | parser = argparse.ArgumentParser(description=__doc__) |
| 304 | parser.add_argument("--runner", required=True, help="canonical instrumented test-runner") |
| 305 | parser.add_argument("--llvm-profdata", required=True, help="matching LLVM tool") |
| 306 | parser.add_argument("--output-dir", required=True, help="new owned evidence directory") |
| 307 | args = parser.parse_args() |
| 308 | try: |
| 309 | runner = identity(args.runner) |
| 310 | tool = identity(args.llvm_profdata) |
| 311 | root = Path(args.output_dir).resolve() |
| 312 | root.mkdir(mode=0o700) |
| 313 | except (OSError, ValueError) as exc: |
| 314 | print("INFRASTRUCTURE ERROR: " + str(exc), file=sys.stderr) |
| 315 | return 2 |
| 316 | receipt = {"schema": 1, "fixed_oracle": True, "selector": SELECTOR, |
| 317 | "deadline_seconds": DEADLINE_SECONDS, "reap_grace_seconds": REAP_SECONDS, |
| 318 | "log_bytes_per_stream": LOG_BYTES, "runner": runner, "llvm_profdata": tool, |
| 319 | "cwd": str(Path.cwd()), "cases": [], "overall": "infrastructure_error"} |
| 320 | try: |
| 321 | for mode in ("success", "begin", "end"): |
| 322 | result = run_case(root, mode, runner["path"], tool["path"]) |
| 323 | receipt["cases"].append(result) |
| 324 | print(mode + ": " + result["classification"]) |
| 325 | if result["classification"] in ("infrastructure_error", "unknown_error_precondition"): |
| 326 | break |
| 327 | unchanged = identity(runner["path"]) == runner and identity(tool["path"]) == tool |
| 328 | if not unchanged: |
| 329 | receipt["error"] = "runner or llvm-profdata changed during proof" |
| 330 | classes = [case["classification"] for case in receipt["cases"]] |
| 331 | if unchanged and len(classes) == 3 and all(item in ("pass", "regression_failure") for item in classes): |
| 332 | receipt["overall"] = "regression_failure" if "regression_failure" in classes else "pass" |
| 333 | except (OSError, ValueError, KeyboardInterrupt) as exc: |
| 334 | receipt["error"] = type(exc).__name__ + ": " + str(exc) |
| 335 | finally: |
| 336 | save_json(root / "result.json", receipt) |
| 337 | return {"pass": 0, "regression_failure": 1, "infrastructure_error": 2}[receipt["overall"]] |
| 338 | |
| 339 | |
| 340 | if __name__ == "__main__": |