forked from ROCm/TheRock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_rocdecode.py
More file actions
80 lines (68 loc) · 2.35 KB
/
test_rocdecode.py
File metadata and controls
80 lines (68 loc) · 2.35 KB
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
import logging
import os
import shlex
import subprocess
from pathlib import Path
import sys
import platform
logging.basicConfig(level=logging.INFO)
THEROCK_BIN_DIR_STR = os.getenv("THEROCK_BIN_DIR")
if THEROCK_BIN_DIR_STR is None:
logging.info(
"++ Error: env(THEROCK_BIN_DIR) is not set. Please set it before executing tests."
)
sys.exit(1)
THEROCK_BIN_DIR = Path(THEROCK_BIN_DIR_STR)
SCRIPT_DIR = Path(__file__).resolve().parent
THEROCK_DIR = SCRIPT_DIR.parent.parent.parent
THEROCK_TEST_DIR = Path(THEROCK_DIR) / "build"
ROCDECODE_TEST_PATH = str(
Path(THEROCK_BIN_DIR).resolve().parent / "share" / "rocdecode" / "test"
)
if not os.path.isdir(ROCDECODE_TEST_PATH):
logging.info(f"++ Error: rocdecode tests not found in {ROCDECODE_TEST_PATH}")
sys.exit(1)
else:
logging.info(f"++ INFO: rocdecode tests found in {ROCDECODE_TEST_PATH}")
env = os.environ.copy()
# set env variables required for tests
def setup_env(env):
ROCM_PATH = Path(THEROCK_BIN_DIR).resolve().parent
env["ROCM_PATH"] = str(ROCM_PATH)
logging.info(f"++ rocdecode setting ROCM_PATH={ROCM_PATH}")
if platform.system() == "Linux":
HIP_LIB_PATH = Path(THEROCK_BIN_DIR).resolve().parent / "lib"
logging.info(f"++ rocdecode setting LD_LIBRARY_PATH={HIP_LIB_PATH}")
if "LD_LIBRARY_PATH" in env:
env["LD_LIBRARY_PATH"] = f"{HIP_LIB_PATH}:{env['LD_LIBRARY_PATH']}"
else:
env["LD_LIBRARY_PATH"] = str(HIP_LIB_PATH)
else:
logging.info(f"++ rocdecode tests only supported on Linux")
exit()
def execute_tests(env):
ROCDECODE_TEST_DIR = Path(THEROCK_TEST_DIR) / "rocdecode-test"
cmd = [
"mkdir",
"-p",
"rocdecode-test",
]
logging.info(f"++ Exec [{THEROCK_TEST_DIR}]$ {shlex.join(cmd)}")
subprocess.run(cmd, cwd=THEROCK_TEST_DIR, check=True, env=env)
cmd = [
"cmake",
"-GNinja",
ROCDECODE_TEST_PATH,
]
logging.info(f"++ Exec [{ROCDECODE_TEST_DIR}]$ {shlex.join(cmd)}")
subprocess.run(cmd, cwd=ROCDECODE_TEST_DIR, check=True, env=env)
cmd = [
"ctest",
"-VV",
"--output-on-failure",
]
logging.info(f"++ Exec [{ROCDECODE_TEST_DIR}]$ {shlex.join(cmd)}")
subprocess.run(cmd, cwd=ROCDECODE_TEST_DIR, check=True, env=env)
if __name__ == "__main__":
setup_env(env)
execute_tests(env)