switch to the smoke testing included in heffte (#26720)

This commit is contained in:
Miroslav Stoyanov 2021-10-14 11:58:29 -04:00 committed by GitHub
parent 160371f879
commit b64a7fe1ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,6 +28,8 @@ class Heffte(CMakePackage, CudaPackage, ROCmPackage):
patch('threads10.patch', when='@1.0')
patch('fortran200.patch', when='@2.0.0')
depends_on('cmake@3.10:', type=('build', 'run'))
variant('shared', default=True, description='Builds with shared libraries')
variant('fftw', default=False, description='Builds with support for FFTW backend')
variant('mkl', default=False, description='Builds with support for MKL backend')
@ -97,59 +99,12 @@ def cmake_args(self):
return args
@run_after('install')
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([self.examples_src_dir])
def test(self):
cmake_file = join_path(self.install_test_root, 'CMakeLists.txt')
test_bld_dir = join_path(self.install_test_root, '_build')
exe_files = []
mpi_procs = []
with open(cmake_file, 'w') as cmkf:
cmkf.write('cmake_minimum_required(VERSION 3.13)\n\n')
cmkf.write('project(heffte_example LANGUAGES CXX)\n\n')
cmkf.write('find_package(Heffte REQUIRED)\n\n')
if '+fftw' in self.spec:
src_file = '{0}/heffte_example_fftw.cpp'.format(
self.examples_src_dir)
cmkf.write(
'add_executable(hf_fftw {0})\n'.format(src_file))
cmkf.write(
'target_link_libraries(hf_fftw Heffte::Heffte)\n')
exe_files.append('./hf_fftw')
mpi_procs.append(4)
if '+cuda' in self.spec:
src_file = '{0}/heffte_example_cuda.cpp'.format(
self.examples_src_dir)
cmkf.write(
'add_executable(hf_cuda {0})\n'.format(src_file))
cmkf.write(
'target_link_libraries(hf_cuda Heffte::Heffte)\n')
exe_files.append('./hf_cuda')
mpi_procs.append(4)
if '+fortran' in self.spec:
src_file = '{0}/heffte_example_fftw.f90'.format(
self.examples_src_dir)
cmkf.write(
'add_executable(hf_fort {0})\n'.format(src_file))
cmkf.write(
'target_link_libraries(hf_fort Heffte::Fortran)\n')
exe_files.append('./hf_fort')
mpi_procs.append(2)
with working_dir(test_bld_dir, create=True):
cmake('..')
# using the tests installed in <prefix>/share/heffte/testing
cmake_dir = join_path(self.prefix, 'share', 'heffte', 'testing')
test_dir = join_path(self.test_suite.current_test_cache_dir,
'test_install')
with working_dir(test_dir, create=True):
cmake(cmake_dir)
make()
test_args = ['-n', '4', ' ']
mpiexe_f = which('srun', 'mpirun', 'mpiexec')
if mpiexe_f:
for exf, procs in zip(exe_files, mpi_procs):
test_args[-1] = exf
test_args[-2] = str(procs)
reason_str = 'Heffte smoke test, exe: {0}'.format(exf)
self.run_test(mpiexe_f.command, test_args,
purpose=reason_str)
make('test')