Skip to content

Commit 53838c1

Browse files
kiritigowdachiranjeevipattigidi
authored andcommitted
Media Tests - Add rocdecode & rocjpeg (#4025)
## Motivation Add media tests to CI ## Technical Details Replacing #3098 ## Test Plan Add test rocdecode and test rocjpeg ## Test Result All tests should pass ## Submission Checklist - [x] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
1 parent 3716572 commit 53838c1

3 files changed

Lines changed: 221 additions & 0 deletions

File tree

build_tools/github_actions/fetch_test_configurations.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,26 @@ def _get_script_path(script_name: str) -> str:
447447
"windows": 1,
448448
},
449449
},
450+
"rocdecode": {
451+
"job_name": "rocdecode",
452+
"fetch_artifact_args": "--rocdecode --tests",
453+
"timeout_minutes": 10,
454+
"test_script": f"python {_get_script_path('test_rocdecode.py')}",
455+
"platform": ["linux"],
456+
"total_shards_dict": {
457+
"linux": 1,
458+
},
459+
},
460+
"rocjpeg": {
461+
"job_name": "rocjpeg",
462+
"fetch_artifact_args": "--rocjpeg --tests",
463+
"timeout_minutes": 10,
464+
"test_script": f"python {_get_script_path('test_rocjpeg.py')}",
465+
"platform": ["linux"],
466+
"total_shards_dict": {
467+
"linux": 1,
468+
},
469+
},
450470
# aqlprofile tests
451471
"aqlprofile": {
452472
"job_name": "aqlprofile",
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import logging
2+
import os
3+
import re
4+
import shlex
5+
import subprocess
6+
from pathlib import Path
7+
import sys
8+
import platform
9+
10+
logging.basicConfig(level=logging.INFO)
11+
THEROCK_BIN_DIR_STR = os.getenv("THEROCK_BIN_DIR")
12+
if THEROCK_BIN_DIR_STR is None:
13+
logging.info(
14+
"++ Error: env(THEROCK_BIN_DIR) is not set. Please set it before executing tests."
15+
)
16+
sys.exit(1)
17+
THEROCK_BIN_DIR = Path(THEROCK_BIN_DIR_STR)
18+
SCRIPT_DIR = Path(__file__).resolve().parent
19+
THEROCK_DIR = SCRIPT_DIR.parent.parent.parent
20+
THEROCK_TEST_DIR = Path(THEROCK_DIR) / "build"
21+
22+
ROCDECODE_TEST_PATH = str(
23+
Path(THEROCK_BIN_DIR).resolve().parent / "share" / "rocdecode" / "test"
24+
)
25+
if not os.path.isdir(ROCDECODE_TEST_PATH):
26+
logging.info(f"++ Error: rocdecode tests not found in {ROCDECODE_TEST_PATH}")
27+
sys.exit(1)
28+
else:
29+
logging.info(f"++ INFO: rocdecode tests found in {ROCDECODE_TEST_PATH}")
30+
env = os.environ.copy()
31+
32+
33+
# set env variables required for tests
34+
def setup_env(env):
35+
ROCM_PATH = Path(THEROCK_BIN_DIR).resolve().parent
36+
env["ROCM_PATH"] = str(ROCM_PATH)
37+
logging.info(f"++ rocdecode setting ROCM_PATH={ROCM_PATH}")
38+
if platform.system() == "Linux":
39+
HIP_LIB_PATH = Path(THEROCK_BIN_DIR).resolve().parent / "lib"
40+
logging.info(f"++ rocdecode setting LD_LIBRARY_PATH={HIP_LIB_PATH}")
41+
if "LD_LIBRARY_PATH" in env:
42+
env["LD_LIBRARY_PATH"] = f"{HIP_LIB_PATH}:{env['LD_LIBRARY_PATH']}"
43+
else:
44+
env["LD_LIBRARY_PATH"] = str(HIP_LIB_PATH)
45+
else:
46+
logging.info(f"++ rocdecode tests only supported on Linux")
47+
sys.exit(0)
48+
49+
50+
def execute_tests(env):
51+
ROCDECODE_TEST_DIR = Path(THEROCK_TEST_DIR) / "rocdecode-test"
52+
53+
ROCDECODE_TEST_DIR.mkdir(parents=True, exist_ok=True)
54+
55+
# rocdecode tests are shipped as CMake source and must be built on the target
56+
# machine. This serves two purposes:
57+
# 1. Verifies that the installed rocdecode headers and libraries are functional.
58+
# 2. Some test dependencies (e.g. video codec libraries) are not bundled in the
59+
# TheRock artifacts and must be linked from the system at build time.
60+
cmd = [
61+
"cmake",
62+
"-GNinja",
63+
ROCDECODE_TEST_PATH,
64+
]
65+
logging.info(f"++ Exec [{ROCDECODE_TEST_DIR}]$ {shlex.join(cmd)}")
66+
subprocess.run(cmd, cwd=ROCDECODE_TEST_DIR, check=True, env=env)
67+
68+
cmd = [
69+
"ctest",
70+
"-N",
71+
]
72+
logging.info(f"++ Exec [{ROCDECODE_TEST_DIR}]$ {shlex.join(cmd)}")
73+
ctest_list = subprocess.run(
74+
cmd,
75+
cwd=ROCDECODE_TEST_DIR,
76+
check=True,
77+
env=env,
78+
capture_output=True,
79+
text=True,
80+
)
81+
logging.info(ctest_list.stdout)
82+
match = re.search(r"Total Tests:\s*(\d+)", ctest_list.stdout)
83+
if match is None:
84+
raise RuntimeError(
85+
"Failed to determine CTest test count from `ctest -N` output"
86+
)
87+
if int(match.group(1)) == 0:
88+
raise RuntimeError("CTest discovered zero rocdecode tests")
89+
90+
cmd = [
91+
"ctest",
92+
"--extra-verbose",
93+
"--output-on-failure",
94+
]
95+
logging.info(f"++ Exec [{ROCDECODE_TEST_DIR}]$ {shlex.join(cmd)}")
96+
subprocess.run(cmd, cwd=ROCDECODE_TEST_DIR, check=True, env=env)
97+
98+
99+
if __name__ == "__main__":
100+
setup_env(env)
101+
execute_tests(env)
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import logging
2+
import os
3+
import re
4+
import shlex
5+
import subprocess
6+
from pathlib import Path
7+
import sys
8+
import platform
9+
10+
logging.basicConfig(level=logging.INFO)
11+
THEROCK_BIN_DIR_STR = os.getenv("THEROCK_BIN_DIR")
12+
if THEROCK_BIN_DIR_STR is None:
13+
logging.info(
14+
"++ Error: env(THEROCK_BIN_DIR) is not set. Please set it before executing tests."
15+
)
16+
sys.exit(1)
17+
THEROCK_BIN_DIR = Path(THEROCK_BIN_DIR_STR)
18+
SCRIPT_DIR = Path(__file__).resolve().parent
19+
THEROCK_DIR = SCRIPT_DIR.parent.parent.parent
20+
THEROCK_TEST_DIR = Path(THEROCK_DIR) / "build"
21+
22+
ROCJPEG_TEST_PATH = str(
23+
Path(THEROCK_BIN_DIR).resolve().parent / "share" / "rocjpeg" / "test"
24+
)
25+
if not os.path.isdir(ROCJPEG_TEST_PATH):
26+
logging.info(f"++ Error: rocjpeg tests not found in {ROCJPEG_TEST_PATH}")
27+
sys.exit(1)
28+
else:
29+
logging.info(f"++ INFO: rocjpeg tests found in {ROCJPEG_TEST_PATH}")
30+
env = os.environ.copy()
31+
32+
33+
# set env variables required for tests
34+
def setup_env(env):
35+
ROCM_PATH = Path(THEROCK_BIN_DIR).resolve().parent
36+
env["ROCM_PATH"] = str(ROCM_PATH)
37+
logging.info(f"++ rocjpeg setting ROCM_PATH={ROCM_PATH}")
38+
if platform.system() == "Linux":
39+
HIP_LIB_PATH = Path(THEROCK_BIN_DIR).resolve().parent / "lib"
40+
logging.info(f"++ rocjpeg setting LD_LIBRARY_PATH={HIP_LIB_PATH}")
41+
if "LD_LIBRARY_PATH" in env:
42+
env["LD_LIBRARY_PATH"] = f"{HIP_LIB_PATH}:{env['LD_LIBRARY_PATH']}"
43+
else:
44+
env["LD_LIBRARY_PATH"] = str(HIP_LIB_PATH)
45+
else:
46+
logging.info(f"++ rocjpeg tests only supported on Linux")
47+
sys.exit(0)
48+
49+
50+
def execute_tests(env):
51+
ROCJPEG_TEST_DIR = Path(THEROCK_TEST_DIR) / "rocjpeg-test"
52+
ROCJPEG_TEST_DIR.mkdir(parents=True, exist_ok=True)
53+
54+
# rocjpeg tests are shipped as CMake source and must be built on the target
55+
# machine. This serves two purposes:
56+
# 1. Verifies that the installed rocjpeg headers and libraries are functional.
57+
# 2. Some test dependencies are not bundled in the TheRock artifacts and must
58+
# be linked from the system at build time.
59+
cmd = [
60+
"cmake",
61+
"-GNinja",
62+
ROCJPEG_TEST_PATH,
63+
]
64+
logging.info(f"++ Exec [{ROCJPEG_TEST_DIR}]$ {shlex.join(cmd)}")
65+
subprocess.run(cmd, cwd=ROCJPEG_TEST_DIR, check=True, env=env)
66+
67+
cmd = [
68+
"ctest",
69+
"-N",
70+
]
71+
logging.info(f"++ Exec [{ROCJPEG_TEST_DIR}]$ {shlex.join(cmd)}")
72+
ctest_list = subprocess.run(
73+
cmd,
74+
cwd=ROCJPEG_TEST_DIR,
75+
check=True,
76+
env=env,
77+
capture_output=True,
78+
text=True,
79+
)
80+
logging.info(ctest_list.stdout)
81+
match = re.search(r"Total Tests:\s*(\d+)", ctest_list.stdout)
82+
if match is None:
83+
raise RuntimeError(
84+
"Failed to determine CTest test count from `ctest -N` output"
85+
)
86+
if int(match.group(1)) == 0:
87+
raise RuntimeError("CTest discovered zero rocjpeg tests")
88+
89+
cmd = [
90+
"ctest",
91+
"--extra-verbose",
92+
"--output-on-failure",
93+
]
94+
logging.info(f"++ Exec [{ROCJPEG_TEST_DIR}]$ {shlex.join(cmd)}")
95+
subprocess.run(cmd, cwd=ROCJPEG_TEST_DIR, check=True, env=env)
96+
97+
98+
if __name__ == "__main__":
99+
setup_env(env)
100+
execute_tests(env)

0 commit comments

Comments
 (0)