tests/papyrus: convert to new stand-alone test process (#38627)
This commit is contained in:
parent
adde84e663
commit
8d72b8dd63
@ -40,68 +40,83 @@ def setup_run_environment(self, env):
|
||||
def cache_test_sources(self):
|
||||
"""Copy the example source files after the package is installed to an
|
||||
install test subdirectory for use during `spack test run`."""
|
||||
self.cache_extra_test_sources([join_path("kv", "tests")])
|
||||
self.cache_extra_test_sources(join_path("kv", "tests"))
|
||||
|
||||
def run_example_tests(self):
|
||||
"""Run all c & c++ stand alone test"""
|
||||
@property
|
||||
def _lib_dir(self):
|
||||
"""Path to the installed library root."""
|
||||
return self.prefix.lib64 if os.path.isdir(self.prefix.lib64) else self.prefix.lib
|
||||
|
||||
example_dir = join_path(self.test_suite.current_test_cache_dir, "kv", "tests")
|
||||
def _build_and_run_kv_test(self, test):
|
||||
"""build and run a kv/tests test"""
|
||||
|
||||
if not os.path.exists(example_dir):
|
||||
print("Skipping all test")
|
||||
return
|
||||
test_dir = join_path(self.test_suite.current_test_cache_dir.kv.tests, test)
|
||||
if not os.path.exists(test_dir):
|
||||
raise SkipTest(f"Example directory ({test_dir}) is missing")
|
||||
|
||||
if os.path.isdir(self.prefix.lib64):
|
||||
lib_dir = self.prefix.lib64
|
||||
else:
|
||||
lib_dir = self.prefix.lib
|
||||
with working_dir(test_dir):
|
||||
options = [
|
||||
f"test{test}.c",
|
||||
f"-I{self.prefix.include}",
|
||||
f"-L{self._lib_dir}",
|
||||
"-lpapyruskv",
|
||||
"-g",
|
||||
"-o",
|
||||
test,
|
||||
"-lpthread",
|
||||
"-lm",
|
||||
]
|
||||
|
||||
example_list = [
|
||||
"01_open_close",
|
||||
"02_put_get",
|
||||
"03_barrier",
|
||||
"04_delete",
|
||||
"05_fence",
|
||||
"06_signal",
|
||||
"07_consistency",
|
||||
"08_protect",
|
||||
"09_cache",
|
||||
"10_checkpoint",
|
||||
"11_restart",
|
||||
"12_free",
|
||||
]
|
||||
mpicxx = which(self.spec["mpi"].mpicxx)
|
||||
mpicxx(*options)
|
||||
|
||||
for example in example_list:
|
||||
test_dir = join_path(self.test_suite.current_test_cache_dir, "kv", "tests", example)
|
||||
test_example = "test{0}.c".format(example)
|
||||
mpirun = which(self.spec["mpi"].prefix.bin.mpirun)
|
||||
mpirun("-np", "4", test)
|
||||
|
||||
if not os.path.exists(test_dir):
|
||||
print("Skipping {0} test".format(example))
|
||||
continue
|
||||
def test_01_open_close(self):
|
||||
"""build and run test01_open_close"""
|
||||
self._build_and_run_kv_test("01_open_close")
|
||||
|
||||
self.run_test(
|
||||
self.spec["mpi"].mpicxx,
|
||||
options=[
|
||||
"{0}".format(join_path(test_dir, test_example)),
|
||||
"-I{0}".format(join_path(self.prefix, "include")),
|
||||
"-L{0}".format(lib_dir),
|
||||
"-lpapyruskv",
|
||||
"-g",
|
||||
"-o",
|
||||
example,
|
||||
"-lpthread",
|
||||
"-lm",
|
||||
],
|
||||
purpose="test: compile {0} example".format(example),
|
||||
work_dir=test_dir,
|
||||
)
|
||||
def test_02_put_get(self):
|
||||
"""build and run test02_put_get"""
|
||||
self._build_and_run_kv_test("02_put_get")
|
||||
|
||||
self.run_test(
|
||||
self.spec["mpi"].prefix.bin.mpirun,
|
||||
options=["-np", "4", example],
|
||||
purpose="test: run {0} example".format(example),
|
||||
work_dir=test_dir,
|
||||
)
|
||||
def test_03_barrier(self):
|
||||
"""build and run test03_barrier"""
|
||||
self._build_and_run_kv_test("03_barrier")
|
||||
|
||||
# def test(self):
|
||||
# self.run_example_tests()
|
||||
def test_04_delete(self):
|
||||
"""build and run test 04_delete"""
|
||||
self._build_and_run_kv_test("04_delete")
|
||||
|
||||
def test_05_fence(self):
|
||||
"""build and run test05_fence"""
|
||||
self._build_and_run_kv_test("05_fence")
|
||||
|
||||
def test_06_signal(self):
|
||||
"""build and run test06_signal"""
|
||||
self._build_and_run_kv_test("06_signal")
|
||||
|
||||
def test_07_consistency(self):
|
||||
"""build and run test07_consistency"""
|
||||
self._build_and_run_kv_test("07_consistency")
|
||||
|
||||
def test_08_protect(self):
|
||||
"""build and run test08_protect"""
|
||||
self._build_and_run_kv_test("08_protect")
|
||||
|
||||
def test_09_cache(self):
|
||||
"""build and run test09_cache"""
|
||||
self._build_and_run_kv_test("09_cache")
|
||||
|
||||
def test_10_checkpoint(self):
|
||||
"""build and run test10_checkpoint"""
|
||||
self._build_and_run_kv_test("10_checkpoint")
|
||||
|
||||
def test_11_restart(self):
|
||||
"""build and run test11_restart"""
|
||||
self._build_and_run_kv_test("11_restart")
|
||||
|
||||
def test_12_free(self):
|
||||
"""build and run test12_free"""
|
||||
self._build_and_run_kv_test("12_free")
|
||||
|
Loading…
Reference in New Issue
Block a user