raja: new test API (#45184)
* raja: new test API * raja: tweak test method names and docstrings * raja: restore running tests under proper directory * raja: cleanup skiptest message and example call * raja: Tweak expected outputs to match current * raja: test_views -> test_stencil_offset_layout --------- Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>
This commit is contained in:
parent
374d94edf7
commit
b61cd74707
@ -400,57 +400,69 @@ def cmake_args(self):
|
|||||||
@property
|
@property
|
||||||
def build_relpath(self):
|
def build_relpath(self):
|
||||||
"""Relative path to the cmake build subdirectory."""
|
"""Relative path to the cmake build subdirectory."""
|
||||||
return join_path("..", self.build_dirname)
|
return join_path("..", self.builder.build_dirname)
|
||||||
|
|
||||||
@run_after("install")
|
@run_after("install")
|
||||||
def setup_build_tests(self):
|
def setup_build_tests(self):
|
||||||
"""Copy the build test files after the package is installed to a
|
"""Copy the build test files after the package is installed to a
|
||||||
relative install test subdirectory for use during `spack test run`."""
|
relative install test subdirectory for use during `spack test run`."""
|
||||||
# Now copy the relative files
|
# Now copy the relative files
|
||||||
self.cache_extra_test_sources(self.build_relpath)
|
cache_extra_test_sources(self, self.build_relpath)
|
||||||
|
|
||||||
# Ensure the path exists since relying on a relative path at the
|
# Ensure the path exists since relying on a relative path at the
|
||||||
# same level as the normal stage source path.
|
# same level as the normal stage source path.
|
||||||
mkdirp(self.install_test_root)
|
mkdirp(install_test_root(self))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _extra_tests_path(self):
|
def _extra_tests_path(self):
|
||||||
# TODO: The tests should be converted to re-build and run examples
|
# TODO: The tests should be converted to re-build and run examples
|
||||||
# TODO: using the installed libraries.
|
# TODO: using the installed libraries.
|
||||||
return join_path(self.install_test_root, self.build_relpath, "bin")
|
return join_path(install_test_root(self), self.build_relpath, "bin")
|
||||||
|
|
||||||
def _test_examples(self):
|
def run_example(self, exe, expected):
|
||||||
"""Perform very basic checks on a subset of copied examples."""
|
"""run and check outputs of the example"""
|
||||||
checks = [
|
with working_dir(self._extra_tests_path):
|
||||||
(
|
example = which(exe)
|
||||||
"ex5_line-of-sight_solution",
|
if example is None:
|
||||||
[r"RAJA sequential", r"RAJA OpenMP", r"result -- PASS"],
|
raise SkipTest(f"{exe} was not built")
|
||||||
),
|
|
||||||
(
|
|
||||||
"ex6_stencil-offset-layout_solution",
|
|
||||||
[r"RAJA Views \(permuted\)", r"result -- PASS"],
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"ex8_tiled-matrix-transpose_solution",
|
|
||||||
[r"parallel top inner loop", r"collapsed inner loops", r"result -- PASS"],
|
|
||||||
),
|
|
||||||
("kernel-dynamic-tile", [r"Running index", r"(24,24)"]),
|
|
||||||
("plugin-example", [r"Launching host kernel for the 10 time"]),
|
|
||||||
("tut_batched-matrix-multiply", [r"result -- PASS"]),
|
|
||||||
("wave-eqn", [r"Max Error = 2", r"Evolved solution to time"]),
|
|
||||||
]
|
|
||||||
for exe, expected in checks:
|
|
||||||
reason = "test: checking output of {0} for {1}".format(exe, expected)
|
|
||||||
self.run_test(
|
|
||||||
exe,
|
|
||||||
[],
|
|
||||||
expected,
|
|
||||||
installed=False,
|
|
||||||
purpose=reason,
|
|
||||||
skip_missing=True,
|
|
||||||
work_dir=self._extra_tests_path,
|
|
||||||
)
|
|
||||||
|
|
||||||
def test(self):
|
out = example(output=str.split, error=str.split)
|
||||||
"""Perform smoke tests."""
|
check_outputs(expected, out)
|
||||||
self._test_examples()
|
|
||||||
|
def test_line_of_sight(self):
|
||||||
|
"""check line of sight example"""
|
||||||
|
self.run_example(
|
||||||
|
"ex5_line-of-sight_solution",
|
||||||
|
[r"C-style sequential", r"RAJA sequential", r"result -- PASS"],
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_stencil_offset_layout(self):
|
||||||
|
"""check stencil offset layout"""
|
||||||
|
self.run_example(
|
||||||
|
"ex6_stencil-offset-layout_solution", [r"RAJA Views \(permuted\)", r"result -- PASS"]
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_tiled_matrix(self):
|
||||||
|
"""check tiled matrix transpose"""
|
||||||
|
self.run_example(
|
||||||
|
"ex8_tiled-matrix-transpose_solution",
|
||||||
|
[r"C-version", r"RAJA sequential", r"result -- PASS"],
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_dynamic_tile(self):
|
||||||
|
"""check kernel dynamic tile"""
|
||||||
|
self.run_example("kernel-dynamic-tile", [r"Running index", r"(24,24)"])
|
||||||
|
|
||||||
|
def test_plugin_example(self):
|
||||||
|
"""check plugin example"""
|
||||||
|
self.run_example("plugin-example", [r"Launching host kernel for the 10 time"])
|
||||||
|
|
||||||
|
def test_matrix_multiply(self):
|
||||||
|
"""check batched matrix multiple tutorial"""
|
||||||
|
self.run_example(
|
||||||
|
"tut_batched-matrix-multiply", [r"batched matrix multiplication", r"result -- PASS"]
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_wave_equation(self):
|
||||||
|
"""check wave equation"""
|
||||||
|
self.run_example("wave-eqn", [r"Max Error = 2", r"Evolved solution to time"])
|
||||||
|
Loading…
Reference in New Issue
Block a user