|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os |
|
|
import sys |
|
|
import json |
|
|
import subprocess |
|
|
import llvm_helper |
|
|
|
|
|
|
|
|
GOOD = 0 |
|
|
BAD = 1 |
|
|
SKIP = 125 |
|
|
|
|
|
provider = os.environ.get("LAB_PROVIDER") |
|
|
|
|
|
|
|
|
def test(commit_sha: str, issue_path: str) -> int: |
|
|
with open(issue_path) as f: |
|
|
content = f.read() |
|
|
data = json.loads(content) |
|
|
required_binaries = ["opt"] |
|
|
if "lli_expected_out" in content: |
|
|
required_binaries.append("lli") |
|
|
bin_dir = os.path.join(llvm_helper.llvm_build_dir, "bin") |
|
|
os.makedirs(bin_dir, exist_ok=True) |
|
|
bug_type = data["bug_type"] |
|
|
|
|
|
|
|
|
skip_reason = "" |
|
|
try: |
|
|
for binary in required_binaries: |
|
|
target_file = os.path.join(bin_dir, binary) |
|
|
if os.path.exists(target_file): |
|
|
os.remove(target_file) |
|
|
skip_reason = f"failed to build {binary}" |
|
|
subprocess.check_call( |
|
|
[provider, commit_sha, binary, target_file], |
|
|
stdout=subprocess.DEVNULL, |
|
|
stderr=subprocess.DEVNULL, |
|
|
) |
|
|
skip_reason = f"{binary} is not functional" |
|
|
subprocess.check_output([target_file, "--version"]) |
|
|
skip_reason = "test case cannot be reproduced" |
|
|
res, _ = llvm_helper.verify_test_group( |
|
|
repro=True, input=data["tests"], type=bug_type |
|
|
) |
|
|
if res: |
|
|
print(commit_sha, "BAD", file=sys.stderr) |
|
|
return BAD |
|
|
skip_reason = "test case cannot be verified" |
|
|
res, _ = llvm_helper.verify_test_group( |
|
|
repro=False, input=data["tests"], type=bug_type |
|
|
) |
|
|
if res: |
|
|
print(commit_sha, "GOOD", file=sys.stderr) |
|
|
return GOOD |
|
|
except Exception: |
|
|
pass |
|
|
print(commit_sha, f"SKIP (reason={skip_reason})", file=sys.stderr) |
|
|
return SKIP |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
issue_path = sys.argv[1] |
|
|
commit_sha = sys.argv[2] if len(sys.argv) == 3 else llvm_helper.git_execute(["rev-parse", "BISECT_HEAD"]).strip() |
|
|
exit(test(commit_sha, issue_path)) |
|
|
|