umpire: old to new test API and refactor (#44957)
* umpire: old to new test format * umpire: old to new test method and refactor * indentation * black reformat * last minute syntax * docstring and checks * black format * change test name * method call correction * Resolve problem with stand-alone tests (or examples) not loading library (Fixes #44960) --------- Co-authored-by: Tamara Dahlgren <dahlgren1@llnl.gov>
This commit is contained in:
parent
0f9434fca4
commit
f371b6f06c
@ -6,8 +6,6 @@
|
|||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
import llnl.util.tty as tty
|
|
||||||
|
|
||||||
from spack.package import *
|
from spack.package import *
|
||||||
|
|
||||||
from .blt import llnl_link_helpers
|
from .blt import llnl_link_helpers
|
||||||
@ -462,37 +460,57 @@ def initconfig_package_entries(self):
|
|||||||
def cmake_args(self):
|
def cmake_args(self):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def test(self):
|
def setup_run_environment(self, env):
|
||||||
|
for library in ["lib", "lib64"]:
|
||||||
|
lib_path = join_path(self.prefix, library)
|
||||||
|
if os.path.exists(lib_path):
|
||||||
|
env.append_path("LD_LIBRARY_PATH", lib_path)
|
||||||
|
|
||||||
|
def run_example(self, exe, expected):
|
||||||
"""Perform stand-alone checks on the installed package."""
|
"""Perform stand-alone checks on the installed package."""
|
||||||
if self.spec.satisfies("@:1") or not os.path.isdir(self.prefix.bin):
|
|
||||||
tty.info("Skipping: checks not installed in bin for v{0}".format(self.version))
|
|
||||||
return
|
|
||||||
|
|
||||||
# Run a subset of examples PROVIDED installed
|
exe_run = which(join_path(self.prefix.bin, exe))
|
||||||
# tutorials with readily checkable outputs.
|
if exe_run is None:
|
||||||
checks = {
|
raise SkipTest(f"{exe} is not installed for version {self.version}")
|
||||||
"malloc": ["99 should be 99"],
|
out = exe_run(output=str.split, error=str.split)
|
||||||
"recipe_dynamic_pool_heuristic": ["in the pool", "releas"],
|
check_outputs(expected, out)
|
||||||
"recipe_no_introspection": ["has allocated", "used"],
|
|
||||||
"strategy_example": ["Available allocators", "HOST"],
|
|
||||||
"tut_copy": ["Copied source data"],
|
|
||||||
"tut_introspection": ["Allocator used is HOST", "size of the allocation"],
|
|
||||||
"tut_memset": ["Set data from HOST"],
|
|
||||||
"tut_move": ["Moved source data", "HOST"],
|
|
||||||
"tut_reallocate": ["Reallocated data"],
|
|
||||||
"vector_allocator": [""],
|
|
||||||
}
|
|
||||||
|
|
||||||
for exe in checks:
|
def test_malloc(self):
|
||||||
expected = checks[exe]
|
"""Run Malloc"""
|
||||||
reason = "test: checking output from {0}".format(exe)
|
self.run_example("malloc", ["99 should be 99"])
|
||||||
self.run_test(
|
|
||||||
exe,
|
def test_recipe_dynamic_pool_heuristic(self):
|
||||||
[],
|
"""Multiple use allocator test"""
|
||||||
expected,
|
self.run_example("recipe_dynamic_pool_heuristic", ["in the pool", "releas"])
|
||||||
0,
|
|
||||||
installed=False,
|
def test_recipe_no_introspection(self):
|
||||||
purpose=reason,
|
"""Test without introspection"""
|
||||||
skip_missing=True,
|
self.run_example("recipe_no_introspection", ["has allocated", "used"])
|
||||||
work_dir=self.prefix.bin,
|
|
||||||
)
|
def test_strategy_example(self):
|
||||||
|
"""Memory allocation strategy test"""
|
||||||
|
self.run_example("strategy_example", ["Available allocators", "HOST"])
|
||||||
|
|
||||||
|
def test_tut_copy(self):
|
||||||
|
"""Copy data test"""
|
||||||
|
self.run_example("tut_copy", ["Copied source data"])
|
||||||
|
|
||||||
|
def test_tut_introspection(self):
|
||||||
|
"""Keep track of pointer allocation test"""
|
||||||
|
self.run_example("tut_introspection", ["Allocator used is HOST", "size of the allocation"])
|
||||||
|
|
||||||
|
def test_tut_memset(self):
|
||||||
|
"""Set entire block of memory to one value test"""
|
||||||
|
self.run_example("tut_memset", ["Set data from HOST"])
|
||||||
|
|
||||||
|
def test_tut_move(self):
|
||||||
|
"""Move memory test"""
|
||||||
|
self.run_example("tut_move", ["Moved source data", "HOST"])
|
||||||
|
|
||||||
|
def test_tut_reallocate(self):
|
||||||
|
"""Reallocate memory test"""
|
||||||
|
self.run_example("tut_reallocate", ["Reallocated data"])
|
||||||
|
|
||||||
|
def test_vector_allocator(self):
|
||||||
|
"""Allocate vector memory test"""
|
||||||
|
self.run_example("vector_allocator", [""])
|
||||||
|
Loading…
Reference in New Issue
Block a user