forked from taichi-dev/taichi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_c_api_compat_test.py
64 lines (53 loc) · 1.77 KB
/
run_c_api_compat_test.py
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
"""
Ensure AOT modules compiled by old versions of Taichi is compatible with the
latest Taichi Runtime.
"""
import glob
import os
import subprocess
from pathlib import Path
import yaml
BASE = (Path(__file__).parent / "cpp").resolve()
run_dict = {}
def init_dict(run_dict, aot_files):
test_config_path = BASE / "cpptests.yaml"
with open(test_config_path, "r") as f:
test_config = yaml.safe_load(f.read())
for x in aot_files:
path_name = Path(x).name[:-3]
run_dict[path_name] = []
for binary in test_config:
binpath = Path(BASE / binary["binary"]).resolve()
if not binpath.exists():
continue
for test in binary["tests"]:
if "--arch=vulkan" not in test.get("args", ""):
continue
run_dict[Path(test["script"]).stem].append(
[
str(binpath),
f"--gtest_filter={test['test']}",
]
)
def run():
aot_files = glob.glob(f"{BASE}/aot/python_scripts/*.py")
init_dict(run_dict, aot_files)
print(run_dict)
for x in aot_files:
path_name = Path(x).stem
os.environ["TAICHI_AOT_FOLDER_PATH"] = f"{BASE}/aot/python_scripts/{path_name}"
if len(os.listdir(f"{BASE}/aot/python_scripts/" + path_name)) == 0:
continue
for i in run_dict[path_name]:
print(i)
try:
subprocess.check_call(i)
except subprocess.SubprocessError:
print(os.environ["TAICHI_AOT_FOLDER_PATH"])
print(path_name)
print(os.listdir(os.environ["TAICHI_AOT_FOLDER_PATH"]))
continue
except FileNotFoundError:
continue
if __name__ == "__main__":
run()