summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkuramoto-fj <72247780+kuramoto-fj@users.noreply.github.com>2021-03-12 15:13:38 +0900
committerGitHub <noreply@github.com>2021-03-12 06:13:38 +0000
commit40147d99553e2b7267a96c21499a0b803f58a4bd (patch)
treebfc402bbd28bb73cde451652eb27e5249b263dcd
parent21b2d7109a52746e8aba74888ca681f5037c4359 (diff)
downloadspack-40147d99553e2b7267a96c21499a0b803f58a4bd.tar.gz
spack-40147d99553e2b7267a96c21499a0b803f58a4bd.tar.bz2
spack-40147d99553e2b7267a96c21499a0b803f58a4bd.tar.xz
spack-40147d99553e2b7267a96c21499a0b803f58a4bd.zip
mptensor: Add test method (#21712)
* mptensor: Add test method * mptensor: Reverted the receipe on merged style * mptensor: Changed """ to #
-rw-r--r--var/spack/repos/builtin/packages/mptensor/package.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/mptensor/package.py b/var/spack/repos/builtin/packages/mptensor/package.py
index 84c8eb82f1..6106682279 100644
--- a/var/spack/repos/builtin/packages/mptensor/package.py
+++ b/var/spack/repos/builtin/packages/mptensor/package.py
@@ -25,6 +25,8 @@ class Mptensor(CMakePackage):
depends_on('scalapack', when="+mpi")
depends_on('doxygen@:1.8.11', type="build", when="+doc")
+ test_requires_compiler = True
+
def cmake_args(self):
spec = self.spec
options = []
@@ -53,3 +55,42 @@ class Mptensor(CMakePackage):
])
return options
+
+ @run_after("install")
+ def setup_build_tests(self):
+ """Copy the build test files after the package is installed to an
+ install test subdirectory for use during `spack test run`."""
+ self.cache_extra_test_sources('.')
+
+ def test(self):
+ if "+mpi" not in self.spec:
+ print("Test of mptensor only runs with +mpi option.")
+ else:
+ with working_dir(join_path(self.install_test_root, "tests"), create=False):
+ make("clean")
+ makefile = FileFilter("Makefile")
+ makefile.filter("g++", "{0}".format(spack_cxx), string=True)
+
+ with working_dir(join_path(self.install_test_root), create=False):
+ makefile = FileFilter("Makefile.option")
+ makefile.filter("CXX =.*", "CXX ={0}".format(self.spec["mpi"].mpicxx))
+ makefile.filter(
+ "CXXFLAGS =.*", "CXXFLAGS ={0}".format(self.compiler.cxx11_flag)
+ )
+
+ math_libs = (
+ self.spec["scalapack"].libs
+ + self.spec["lapack"].libs
+ + self.spec["blas"].libs
+ )
+
+ with working_dir(join_path(self.install_test_root, "tests"), create=False):
+ make("LDFLAGS={0}".format(math_libs.ld_flags))
+
+ mpirun = self.spec["mpi"].prefix.bin.mpirun
+ mpiexec = Executable(mpirun)
+ mpiexec("-n", "1", "tensor_test.out")
+
+ # Test of mptensor has checker
+ # and checker is abort when check detect any errors.
+ print("Test of mptensor PASSED !")