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