tests/ginkgo: converted to new stand-alone test process (#35730)

* Ginkgo: converted to new stand-alone test process

* ginkgo: update string formatting, compiler setting
This commit is contained in:
Tamara Dahlgren 2023-06-06 11:58:53 -07:00 committed by GitHub
parent e5d5efb4c1
commit 815b210fc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,8 @@ class Ginkgo(CMakePackage, CudaPackage, ROCmPackage):
homepage = "https://ginkgo-project.github.io/"
git = "https://github.com/ginkgo-project/ginkgo.git"
test_requires_compiler = True
maintainers("tcojean", "hartwiganzt")
tags = ["e4s"]
@ -160,33 +162,32 @@ def cmake_args(self):
)
return args
extra_install_tests = join_path("test", "test_install")
@property
def extra_install_tests(self):
return "test_install" if self.spec.satisfies("@1.3.0") else "test"
@run_after("install")
def cache_test_sources(self):
self.cache_extra_test_sources(self.extra_install_tests)
@property
def _cached_tests_src_dir(self):
"""The cached smoke test source directory."""
return join_path(self.test_suite.current_test_cache_dir, self.extra_install_tests)
def _cached_tests_src_dir(self, script):
"""The cached smoke test source directory for the script."""
subdir = script if self.spec.satisfies("@1.4.0:") else ""
return join_path(self.test_suite.current_test_cache_dir, self.extra_install_tests, subdir)
@property
def _cached_tests_work_dir(self):
"""The working directory for cached test sources."""
return join_path(self._cached_tests_src_dir, "build")
def _build_and_run_test(self, script):
"""Build and run the test against the installation."""
src_dir = self._cached_tests_src_dir(script)
def _build_test(self):
cmake_bin = join_path(self.spec["cmake"].prefix.bin, "cmake")
cmake_args = [
"-DCMAKE_C_COMPILER={0}".format(self.compiler.cc),
"-DCMAKE_CXX_COMPILER={0}".format(self.compiler.cxx),
self._cached_tests_src_dir,
f"-DCMAKE_C_COMPILER={os.environ['CC']}",
f"-DCMAKE_CXX_COMPILER={os.environ['CXX']}",
src_dir,
]
# Fix: For HIP tests, add the ARCH compilation flags when not present
if "+rocm" in self.spec:
src_path = join_path(self._cached_tests_src_dir, "CMakeLists.txt")
src_path = join_path(src_dir, "CMakeLists.txt")
cmakelists = open(src_path, "rt")
data = cmakelists.read()
data = data.replace(
@ -198,43 +199,39 @@ def _build_test(self):
cmakelists.write(data)
cmakelists.close()
if not self.run_test(
cmake_bin,
options=cmake_args,
purpose="Generate the Makefile",
work_dir=self._cached_tests_work_dir,
):
print("Skipping Ginkgo test: failed to generate Makefile")
return
cmake = which(self.spec["cmake"].prefix.bin.cmake)
make = which("make")
with working_dir(src_dir):
cmake(*cmake_args)
make()
exe = which(script)
output = exe(output=str.split, error=str.split)
assert "correctly detected and is complete" in output
if not self.run_test(
"make", purpose="Build test software", work_dir=self._cached_tests_work_dir
):
print("Skipping Ginkgo test: failed to build test")
return
def test_install(self):
"""build, run and check results of test_install"""
if not self.spec.satisfies("@1.3.0:"):
raise SkipTest("Test is only available for v1.3.0:")
def test(self):
"""Run the smoke tests."""
# For now only 1.4.0 and later releases support this scheme.
if self.spec.satisfies("@:1.3.0"):
print("SKIPPED: smoke tests not supported with this Ginkgo version.")
return
self._build_and_run_test("test_install")
self._build_test()
def test_install_cuda(self):
"""build, run and check results of test_install_cuda"""
if not self.spec.satisfies("@1.4.0: +cuda"):
raise SkipTest("Test is only available for v1.4.0: +cuda")
# Perform the test(s) created by setup_build_tests.
files = [
("test_install", [r"REFERENCE", r"correctly detected and is complete"]),
("test_install_cuda", [r"CUDA", r"correctly detected and is complete"]),
("test_install_hip", [r"HIP", r"correctly detected and is complete"]),
]
for f, expected in files:
self.run_test(
f,
[],
expected,
skip_missing=True,
installed=False,
purpose="test: Running {0}".format(f),
work_dir=self._cached_tests_work_dir,
)
self._build_and_run_test("test_install_cuda")
def test_install_hip(self):
"""build, run and check results of test_install_hip"""
if not self.spec.satisfies("@1.4.0: +rocm"):
raise SkipTest("Test is only available for v1.4.0: +rocm")
self._build_and_run_test("test_install_hip")
def test_exportbuild(self):
"""build, run and check results of test_exportbuild"""
if not self.spec.satisfies("@1.4.0:"):
raise SkipTest("Test is only available for v1.4.0:")
self._build_and_run_test("test_exportbuild")