From 6447ec6ff5007a5cc15882f2bcd661de62a5c619 Mon Sep 17 00:00:00 2001 From: Sergei Shudler Date: Mon, 8 Feb 2021 11:21:52 -0800 Subject: Smoke test for parallel-netcdf package (#21400) --- .../builtin/packages/parallel-netcdf/package.py | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/parallel-netcdf/package.py b/var/spack/repos/builtin/packages/parallel-netcdf/package.py index 8f0ee740eb..648756d727 100644 --- a/var/spack/repos/builtin/packages/parallel-netcdf/package.py +++ b/var/spack/repos/builtin/packages/parallel-netcdf/package.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack import * +import os class ParallelNetcdf(AutotoolsPackage): @@ -19,6 +20,8 @@ class ParallelNetcdf(AutotoolsPackage): maintainers = ['skosukhin'] + test_requires_compiler = True + def url_for_version(self, version): if version >= Version('1.11.0'): url = "https://parallel-netcdf.github.io/Release/pnetcdf-{0}.tar.gz" @@ -169,3 +172,32 @@ class ParallelNetcdf(AutotoolsPackage): args.append('--enable-burst-buffering') return args + + examples_src_dir = 'examples/CXX' + + @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): + test_dir = join_path(self.install_test_root, self.examples_src_dir) + # pnetcdf has many examples to serve as a suitable smoke check. + # column_wise was chosen based on the E4S test suite. Other + # examples should work as well. + test_exe = 'column_wise' + options = ['{0}.cpp'.format(test_exe), '-o', test_exe, '-lpnetcdf'] + reason = 'test: compiling and linking pnetcdf example' + self.run_test(self.spec['mpi'].mpicxx, options, [], + installed=False, purpose=reason, work_dir=test_dir) + mpiexe_list = ['mpirun', 'mpiexec', 'srun'] + for mpiexe in mpiexe_list: + if os.path.isfile(mpiexe): + self.run_test(mpiexe, ['-n', '4', test_exe], [], + installed=False, + purpose='test: pnetcdf smoke test', + skip_missing=True, + work_dir=test_dir) + break + self.run_test('rm', ['-f', test_exe], work_dir=test_dir) -- cgit v1.2.3-70-g09d2