caliper: convert to new stand-alone test process (#35691)
This commit is contained in:
parent
d8a72b68dd
commit
dc58449bbf
@ -6,8 +6,6 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from llnl.util import tty
|
||||
|
||||
from spack.package import *
|
||||
|
||||
|
||||
@ -149,44 +147,31 @@ def cache_test_sources(self):
|
||||
install test subdirectory for use during `spack test run`."""
|
||||
self.cache_extra_test_sources([join_path("examples", "apps")])
|
||||
|
||||
def run_cxx_example_test(self):
|
||||
"""Run stand alone test: cxx_example"""
|
||||
def test_cxx_example(self):
|
||||
"""build and run cxx-example"""
|
||||
|
||||
test_dir = self.test_suite.current_test_cache_dir.examples.apps
|
||||
exe = "cxx-example"
|
||||
source_file = "cxx-example.cpp"
|
||||
source_file = "{0}.cpp".format(exe)
|
||||
|
||||
if not os.path.isfile(join_path(test_dir, source_file)):
|
||||
tty.warn("Skipping caliper test:" "{0} does not exist".format(source_file))
|
||||
return
|
||||
source_path = find_required_file(
|
||||
self.test_suite.current_test_cache_dir, source_file, expected=1, recursive=True
|
||||
)
|
||||
|
||||
if os.path.exists(self.prefix.lib):
|
||||
lib_dir = self.prefix.lib
|
||||
else:
|
||||
lib_dir = self.prefix.lib64
|
||||
lib_dir = self.prefix.lib if os.path.exists(self.prefix.lib) else self.prefix.lib64
|
||||
|
||||
options = [
|
||||
"-L{0}".format(lib_dir),
|
||||
"-I{0}".format(self.prefix.include),
|
||||
"{0}".format(join_path(test_dir, source_file)),
|
||||
"-o",
|
||||
exe,
|
||||
"-std=c++11",
|
||||
"-lcaliper",
|
||||
"-lstdc++",
|
||||
]
|
||||
cxx = which(os.environ["CXX"])
|
||||
test_dir = os.path.dirname(source_path)
|
||||
with working_dir(test_dir):
|
||||
cxx(
|
||||
"-L{0}".format(lib_dir),
|
||||
"-I{0}".format(self.prefix.include),
|
||||
source_path,
|
||||
"-o",
|
||||
exe,
|
||||
"-std=c++11",
|
||||
"-lcaliper",
|
||||
"-lstdc++",
|
||||
)
|
||||
|
||||
if not self.run_test(
|
||||
exe=os.environ["CXX"],
|
||||
options=options,
|
||||
purpose="test: compile {0} example".format(exe),
|
||||
work_dir=test_dir,
|
||||
):
|
||||
tty.warn("Skipping caliper test: failed to compile example")
|
||||
return
|
||||
|
||||
if not self.run_test(exe, purpose="test: run {0} example".format(exe), work_dir=test_dir):
|
||||
tty.warn("Skipping caliper test: failed to run example")
|
||||
|
||||
def test(self):
|
||||
self.run_cxx_example_test()
|
||||
cxx_example = which(exe)
|
||||
cxx_example()
|
||||
|
Loading…
Reference in New Issue
Block a user