summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorTamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>2023-07-05 01:34:15 -0700
committerGitHub <noreply@github.com>2023-07-05 10:34:15 +0200
commit8d72b8dd63e7f0b0cb9053e0ea43266c3d46424a (patch)
tree48c36f5a9d7c5004fd845df5943c06f7845bd47a /var
parentadde84e66362cfc135cbc0d3f208588ec87e796e (diff)
downloadspack-8d72b8dd63e7f0b0cb9053e0ea43266c3d46424a.tar.gz
spack-8d72b8dd63e7f0b0cb9053e0ea43266c3d46424a.tar.bz2
spack-8d72b8dd63e7f0b0cb9053e0ea43266c3d46424a.tar.xz
spack-8d72b8dd63e7f0b0cb9053e0ea43266c3d46424a.zip
tests/papyrus: convert to new stand-alone test process (#38627)
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/papyrus/package.py145
1 files changed, 80 insertions, 65 deletions
diff --git a/var/spack/repos/builtin/packages/papyrus/package.py b/var/spack/repos/builtin/packages/papyrus/package.py
index ab790a29d4..f4bab12765 100644
--- a/var/spack/repos/builtin/packages/papyrus/package.py
+++ b/var/spack/repos/builtin/packages/papyrus/package.py
@@ -40,68 +40,83 @@ class Papyrus(CMakePackage):
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")])
-
- def run_example_tests(self):
- """Run all c & c++ stand alone test"""
-
- example_dir = join_path(self.test_suite.current_test_cache_dir, "kv", "tests")
-
- if not os.path.exists(example_dir):
- print("Skipping all test")
- return
-
- if os.path.isdir(self.prefix.lib64):
- lib_dir = self.prefix.lib64
- else:
- lib_dir = self.prefix.lib
-
- 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",
- ]
-
- 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)
-
- if not os.path.exists(test_dir):
- print("Skipping {0} test".format(example))
- continue
-
- 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,
- )
-
- 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(self):
- # self.run_example_tests()
+ self.cache_extra_test_sources(join_path("kv", "tests"))
+
+ @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
+
+ def _build_and_run_kv_test(self, test):
+ """build and run a kv/tests test"""
+
+ 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")
+
+ 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",
+ ]
+
+ mpicxx = which(self.spec["mpi"].mpicxx)
+ mpicxx(*options)
+
+ mpirun = which(self.spec["mpi"].prefix.bin.mpirun)
+ mpirun("-np", "4", test)
+
+ def test_01_open_close(self):
+ """build and run test01_open_close"""
+ self._build_and_run_kv_test("01_open_close")
+
+ def test_02_put_get(self):
+ """build and run test02_put_get"""
+ self._build_and_run_kv_test("02_put_get")
+
+ def test_03_barrier(self):
+ """build and run test03_barrier"""
+ self._build_and_run_kv_test("03_barrier")
+
+ 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")