Datasets:

Modalities:
Text
Formats:
json
Size:
< 1K
Tags:
code
DOI:
Libraries:
Datasets
pandas
License:
File size: 2,733 Bytes
bfa61be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29fe9dd
bfa61be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29fe9dd
 
bf4a3cd
bfa61be
 
 
 
 
bf4a3cd
bfa61be
 
 
 
 
bf4a3cd
bfa61be
bf4a3cd
bfa61be
 
 
 
 
 
bf4a3cd
bfa61be
 
 
 
 
 
 
 
bf4a3cd
bfa61be
 
 
 
 
29fe9dd
bfa61be
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
81
#!/usr/bin/env python3
# Copyright 2025 Yingwei Zheng
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


import os
import sys
import json
import subprocess
import llvm_helper
# import resource

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"]
    # _, hard = resource.getrlimit(resource.RLIMIT_AS)
    # resource.setrlimit(resource.RLIMIT_AS, (min(hard, 8 * 1024**3), hard))
    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))