diff options
author | Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> | 2021-05-25 07:24:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-25 07:24:32 -0700 |
commit | 929d1de3e58e9bd774688a95d70a12f9d60aee13 (patch) | |
tree | f98b64c450bef7d86525efcb8f457c795ad62895 /var | |
parent | 56e7e2a406264479bca32f3d46013fa10ca49c21 (diff) | |
download | spack-929d1de3e58e9bd774688a95d70a12f9d60aee13.tar.gz spack-929d1de3e58e9bd774688a95d70a12f9d60aee13.tar.bz2 spack-929d1de3e58e9bd774688a95d70a12f9d60aee13.tar.xz spack-929d1de3e58e9bd774688a95d70a12f9d60aee13.zip |
Stand-alone/Smoke tests: copy cached test sources to test stage (#23713)
Diffstat (limited to 'var')
4 files changed, 72 insertions, 47 deletions
diff --git a/var/spack/repos/builtin.mock/packages/trivial-smoke-test/package.py b/var/spack/repos/builtin.mock/packages/trivial-smoke-test/package.py new file mode 100644 index 0000000000..6dbdd07ea8 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/trivial-smoke-test/package.py @@ -0,0 +1,25 @@ +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack import * + + +class TrivialSmokeTest(Package): + """This package is a stub with trivial smoke test features.""" + homepage = "http://www.example.com/trivial_test" + url = "http://www.unit-test-should-replace-this-url/trivial_test-1.0.tar.gz" + + version('1.0', 'foobarbaz') + + test_source_filename = 'cached_file.in' + + @run_before('install') + def create_extra_test_source(self): + mkdirp(self.install_test_root) + touch(join_path(self.install_test_root, self.test_source_filename)) + + @run_after('install') + def copy_test_sources(self): + self.cache_extra_test_sources([self.test_source_filename]) diff --git a/var/spack/repos/builtin.mock/packages/trivial-smoke-test/test/test_file.in b/var/spack/repos/builtin.mock/packages/trivial-smoke-test/test/test_file.in new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/trivial-smoke-test/test/test_file.in diff --git a/var/spack/repos/builtin/packages/hypre/package.py b/var/spack/repos/builtin/packages/hypre/package.py index 43213507c4..3b8c6cd3c1 100644 --- a/var/spack/repos/builtin/packages/hypre/package.py +++ b/var/spack/repos/builtin/packages/hypre/package.py @@ -220,26 +220,36 @@ class Hypre(Package, CudaPackage): '-rhsone') make("install") + extra_install_tests = join_path('src', 'examples') + @run_after('install') def cache_test_sources(self): - srcs = ['src/examples'] - self.cache_extra_test_sources(srcs) + self.cache_extra_test_sources(self.extra_install_tests) + + @property + def _cached_tests_work_dir(self): + """The working directory for cached test sources.""" + return join_path(self.test_suite.current_test_cache_dir, + self.extra_install_tests) def test(self): """Perform smoke test on installed HYPRE package.""" - - if '+mpi' in self.spec: - examples_dir = join_path(self.install_test_root, 'src/examples') - with working_dir(examples_dir, create=False): - make("HYPRE_DIR=" + self.prefix, "bigint") - - reason = "test: ensuring HYPRE examples run" - self.run_test('./ex5big', [], [], installed=True, - purpose=reason, skip_missing=True, work_dir='.') - self.run_test('./ex15big', [], [], installed=True, - purpose=reason, skip_missing=True, work_dir='.') - - make("distclean") + if '+mpi' not in self.spec: + print('Skipping: HYPRE must be installed with +mpi to run tests') + return + + # Build copied and cached test examples + self.run_test('make', + ['HYPRE_DIR={0}'.format(self.prefix), 'bigint'], + purpose='test: building selected examples', + work_dir=self._cached_tests_work_dir) + + # Run the examples built above + for exe in ['./ex5big', './ex15big']: + self.run_test(exe, [], [], installed=False, + purpose='test: ensuring {0} runs'.format(exe), + skip_missing=True, + work_dir=self._cached_tests_work_dir) @property def headers(self): diff --git a/var/spack/repos/builtin/packages/openmpi/package.py b/var/spack/repos/builtin/packages/openmpi/package.py index 697171a02a..67809c7ce9 100644 --- a/var/spack/repos/builtin/packages/openmpi/package.py +++ b/var/spack/repos/builtin/packages/openmpi/package.py @@ -891,9 +891,10 @@ class Openmpi(AutotoolsPackage): 'shmemrun': ls, } - for exe in checks: - options, expected, status = checks[exe] - reason = 'test: checking {0} output'.format(exe) + for binary in checks: + options, expected, status = checks[binary] + exe = join_path(self.prefix.bin, binary) + reason = 'test: checking {0} output'.format(binary) self.run_test(exe, options, expected, status, installed=True, purpose=reason, skip_missing=True) @@ -942,36 +943,28 @@ class Openmpi(AutotoolsPackage): 'shmemcxx': comp_vers, } - for exe in checks: - expected = checks[exe] + for binary in checks: + expected = checks[binary] purpose = 'test: ensuring version of {0} is {1}' \ - .format(exe, expected) + .format(binary, expected) + exe = join_path(self.prefix.bin, binary) self.run_test(exe, '--version', expected, installed=True, purpose=purpose, skip_missing=True) - def _test_build_examples(self): - # Build the examples copied during installation and return "status" - reason = 'test: ensuring ability to build the examples' - return self.run_test('make', ['all'], [], - purpose=reason, - work_dir=join_path(self.install_test_root, - self.extra_install_tests)) - - def _test_clean_examples(self): - # Clean up any example build files - reason = 'test: ensuring copied examples cleaned up' - return self.run_test('make', ['clean'], [], - purpose=reason, - work_dir=join_path(self.install_test_root, - self.extra_install_tests)) + @property + def _cached_tests_work_dir(self): + """The working directory for cached test sources.""" + return join_path(self.test_suite.current_test_cache_dir, + self.extra_install_tests) def _test_examples(self): - # First ensure can build copied examples - if not self._test_build_examples(): - self._test_clean_examples() - return + """Run test examples copied from source at build-time.""" + # Build the copied, cached test examples + self.run_test('make', ['all'], [], + purpose='test: building cached test examples', + work_dir=self._cached_tests_work_dir) - # Now run examples with known, simple-to-verify results + # Run examples with known, simple-to-verify results have_spml = self.spec.satisfies('@2.0.0:2.1.6') hello_world = (['Hello, world', 'I am', '0 of', '1'], 0) @@ -1015,14 +1008,11 @@ class Openmpi(AutotoolsPackage): .format(exe, status) self.run_test(exe, [], expected, status, installed=False, purpose=reason, skip_missing=True, - work_dir=join_path(self.install_test_root, - self.extra_install_tests)) - - self._test_clean_examples() + work_dir=self._cached_tests_work_dir) def test(self): - """Perform smoke tests on the installed package.""" - # Simple version check tests on known packages + """Perform stand-alone/smoke tests on the installed package.""" + # Simple version check tests on selected installed binaries self._test_check_versions() # Test the operation of selected executables |