Bugfix: Kokkos stand alone test (#29403)
* Use the cmake in the user's path * Use test_suite cache * Clean up the code
This commit is contained in:
parent
685e3d7ae9
commit
63b981dba4
@ -4,6 +4,8 @@
|
|||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
|
from llnl.util import tty
|
||||||
|
|
||||||
from spack import *
|
from spack import *
|
||||||
|
|
||||||
|
|
||||||
@ -292,7 +294,21 @@ def cmake_args(self):
|
|||||||
|
|
||||||
return options
|
return options
|
||||||
|
|
||||||
test_script_relative_path = "scripts/spack_test"
|
test_script_relative_path = join_path('scripts', 'spack_test')
|
||||||
|
|
||||||
|
# TODO: Replace this method and its 'get' use for cmake path with
|
||||||
|
# join_path(self.spec['cmake'].prefix.bin, 'cmake') once stand-alone
|
||||||
|
# tests can access build dependencies through self.spec['cmake'].
|
||||||
|
def cmake_bin(self, set=True):
|
||||||
|
"""(Hack) Set/get cmake dependency path."""
|
||||||
|
filepath = join_path(self.install_test_root, 'cmake_bin_path.txt')
|
||||||
|
if set:
|
||||||
|
with open(filepath, 'w') as out_file:
|
||||||
|
cmake_bin = join_path(self.spec['cmake'].prefix.bin, 'cmake')
|
||||||
|
out_file.write('{0}\n'.format(cmake_bin))
|
||||||
|
elif os.path.isfile(filepath):
|
||||||
|
with open(filepath, 'r') as in_file:
|
||||||
|
return in_file.read().strip()
|
||||||
|
|
||||||
@run_after('install')
|
@run_after('install')
|
||||||
def setup_build_tests(self):
|
def setup_build_tests(self):
|
||||||
@ -311,28 +327,43 @@ def setup_build_tests(self):
|
|||||||
"-DSPACK_PACKAGE_INSTALL_DIR:PATH={0}".format(self.prefix)]
|
"-DSPACK_PACKAGE_INSTALL_DIR:PATH={0}".format(self.prefix)]
|
||||||
cmake(*cmake_args)
|
cmake(*cmake_args)
|
||||||
self.cache_extra_test_sources(cmake_out_path)
|
self.cache_extra_test_sources(cmake_out_path)
|
||||||
|
self.cmake_bin(set=True)
|
||||||
|
|
||||||
def build_tests(self):
|
def build_tests(self, cmake_path):
|
||||||
"""Build test."""
|
"""Build test."""
|
||||||
cmake_path = join_path(self.install_test_root,
|
cmake_bin = self.cmake_bin(set=False)
|
||||||
self.test_script_relative_path, 'out')
|
|
||||||
cmake_args = [cmake_path, '-DEXECUTABLE_OUTPUT_PATH=' + cmake_path]
|
|
||||||
cmake(*cmake_args)
|
|
||||||
make()
|
|
||||||
|
|
||||||
def run_tests(self):
|
if not cmake_bin:
|
||||||
|
tty.msg('Skipping kokkos test: cmake_bin_path.txt not found')
|
||||||
|
return
|
||||||
|
|
||||||
|
cmake_args = [cmake_path, '-DEXECUTABLE_OUTPUT_PATH=' + cmake_path]
|
||||||
|
|
||||||
|
if not self.run_test(cmake_bin,
|
||||||
|
options=cmake_args,
|
||||||
|
purpose='Generate the Makefile'):
|
||||||
|
tty.warn('Skipping kokkos test: failed to generate Makefile')
|
||||||
|
return
|
||||||
|
|
||||||
|
if not self.run_test('make',
|
||||||
|
purpose='Build test software'):
|
||||||
|
tty.warn('Skipping kokkos test: failed to build test')
|
||||||
|
|
||||||
|
def run_tests(self, cmake_path):
|
||||||
"""Run test."""
|
"""Run test."""
|
||||||
reason = 'Checking ability to execute.'
|
if not self.run_test('make',
|
||||||
run_path = join_path(self.install_test_root,
|
options=[cmake_path, 'test'],
|
||||||
self.test_script_relative_path, 'out')
|
purpose='Checking ability to execute.'):
|
||||||
self.run_test('make', [run_path, 'test'], [], installed=False, purpose=reason)
|
tty.warn('Failed to run kokkos test')
|
||||||
|
|
||||||
def test(self):
|
def test(self):
|
||||||
# Skip if unsupported version
|
# Skip if unsupported version
|
||||||
cmake_path = join_path(self.install_test_root,
|
cmake_path = join_path(self.test_suite.current_test_cache_dir,
|
||||||
self.test_script_relative_path, 'out')
|
self.test_script_relative_path, 'out')
|
||||||
|
|
||||||
if not os.path.exists(cmake_path):
|
if not os.path.exists(cmake_path):
|
||||||
print('Skipping smoke tests: {0} is missing'.format(cmake_path))
|
tty.warn('Skipping smoke tests: {0} is missing'.format(cmake_path))
|
||||||
return
|
return
|
||||||
self.build_tests()
|
|
||||||
self.run_tests()
|
self.build_tests(cmake_path)
|
||||||
|
self.run_tests(cmake_path)
|
||||||
|
Loading…
Reference in New Issue
Block a user