Skip to content

Commit

Permalink
Added new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriiPerets committed Sep 16, 2024
1 parent cc37e3d commit 774325a
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/bashi/filter_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def compiler_filter(
if UBUNTU in row and row[UBUNTU].version < pkv.parse("20.04"):
reason(
output,
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
)
return False

Expand Down
6 changes: 3 additions & 3 deletions src/bashi/filter_software_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ def software_dependency_filter(
if ALPAKA_ACC_GPU_HIP_ENABLE in row and row[ALPAKA_ACC_GPU_HIP_ENABLE].version != OFF_VER:
reason(
output,
f"ROCm images "
"is not available in UBUNTU "
f"{__ubuntu_version_to_string(row[UBUNTU].version)}",
"ROCm and also the hipcc compiler "
"is not available on Ubuntu "
"older than 20.04",
)
return False
return True
60 changes: 58 additions & 2 deletions tests/test_filter_software_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,65 @@ def test_non_valid_ROCm_images_Ubuntu2004_based_d4(self):
),
reason_msg,
),
f"ROCm images is not available in UBUNTU {UBUNTU_version}",
f"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
)
self.assertEqual(
reason_msg.getvalue(),
f"ROCm images is not available in UBUNTU {UBUNTU_version}",
f"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
)

for host_name, device_name, hip_backend, ubuntu_version, error_msg in [
(
HIPCC,
HIPCC,
ON,
"18.04",
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
),
(
HIPCC,
GCC,
ON,
"18.04",
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
),
(
CLANG,
HIPCC,
ON,
"18.04",
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
),
(
GCC,
HIPCC,
ON,
"18.04",
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
),
(
HIPCC,
CLANG,
ON,
"18.04",
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
),
]:
test_row = OD(
{
HOST_COMPILER: ppv((host_name, 1)),
DEVICE_COMPILER: ppv((device_name, 1)),
ALPAKA_ACC_GPU_HIP_ENABLE: ppv((ALPAKA_ACC_GPU_HIP_ENABLE, hip_backend)),
UBUNTU: ppv((UBUNTU, ubuntu_version)),
},
)
reason_msg = io.StringIO()
self.assertFalse(
software_dependency_filter_typechecked(test_row, reason_msg),
f"{test_row}",
)
self.assertEqual(
reason_msg.getvalue(),
error_msg,
f"{test_row}",
)
63 changes: 59 additions & 4 deletions tests/test_hipcc_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ def test_hipcc_requires_ubuntu2004_not_pass_c19(self):
)
self.assertEqual(
reason_msg1.getvalue(),
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
)

reason_msg2 = io.StringIO()
Expand All @@ -841,7 +841,7 @@ def test_hipcc_requires_ubuntu2004_not_pass_c19(self):
)
self.assertEqual(
reason_msg2.getvalue(),
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
)

reason_msg3 = io.StringIO()
Expand All @@ -859,7 +859,7 @@ def test_hipcc_requires_ubuntu2004_not_pass_c19(self):
)
self.assertEqual(
reason_msg3.getvalue(),
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
)

reason_msg4 = io.StringIO()
Expand All @@ -877,7 +877,62 @@ def test_hipcc_requires_ubuntu2004_not_pass_c19(self):
)
self.assertEqual(
reason_msg4.getvalue(),
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
)
for host_name, device_name, hip_backend, ubuntu_version, error_msg in [
(
HIPCC,
HIPCC,
ON,
"18.04",
"ROCm and also the hipcc compiler is not available on Ubuntu older than 20.04",
),
(
HIPCC,
GCC,
ON,
"18.04",
"host and device compiler name must be the same (except for nvcc)",
),
(
CLANG,
HIPCC,
ON,
"18.04",
"host and device compiler name must be the same (except for nvcc)",
),
(
GCC,
HIPCC,
OFF,
"18.04",
"host and device compiler name must be the same (except for nvcc)",
),
(
HIPCC,
CLANG,
OFF,
"18.04",
"host and device compiler name must be the same (except for nvcc)",
),
]:
test_row = OD(
{
HOST_COMPILER: ppv((host_name, 1)),
DEVICE_COMPILER: ppv((device_name, 1)),
ALPAKA_ACC_GPU_HIP_ENABLE: ppv((ALPAKA_ACC_GPU_HIP_ENABLE, hip_backend)),
UBUNTU: ppv((UBUNTU, ubuntu_version)),
},
)
reason_msg = io.StringIO()
self.assertFalse(
compiler_filter_typechecked(test_row, reason_msg),
f"{test_row}",
)
self.assertEqual(
reason_msg.getvalue(),
error_msg,
f"{test_row}",
)

def test_hip_and_cuda_backend_cannot_be_active_at_the_same_time_b3(self):
Expand Down

0 comments on commit 774325a

Please sign in to comment.