tests/darshan-runtime: convert to new stand-alone test process (#37838)
This commit is contained in:
parent
fbb271d804
commit
1d88f690a4
@ -144,70 +144,39 @@ def _copy_test_inputs(self):
|
|||||||
test_inputs = [join_path(self.basepath, "mpi-io-test.c")]
|
test_inputs = [join_path(self.basepath, "mpi-io-test.c")]
|
||||||
self.cache_extra_test_sources(test_inputs)
|
self.cache_extra_test_sources(test_inputs)
|
||||||
|
|
||||||
def _test_intercept(self):
|
def test_mpi_io_test(self):
|
||||||
|
"""build, run, and check outputs"""
|
||||||
|
if "+mpi" not in self.spec:
|
||||||
|
raise SkipTest("Test requires +mpi build")
|
||||||
|
|
||||||
testdir = "intercept-test"
|
testdir = "intercept-test"
|
||||||
|
logname = join_path(os.getcwd(), testdir, "test.darshan")
|
||||||
|
testexe = "mpi-io-test"
|
||||||
|
|
||||||
with working_dir(testdir, create=True):
|
with working_dir(testdir, create=True):
|
||||||
if "+mpi" in self.spec:
|
env["LD_PRELOAD"] = join_path(self.prefix.lib, "libdarshan.so")
|
||||||
# compile a test program
|
env["DARSHAN_LOGFILE"] = logname
|
||||||
logname = join_path(os.getcwd(), "test.darshan")
|
|
||||||
fname = join_path(
|
|
||||||
self.test_suite.current_test_cache_dir,
|
|
||||||
join_path(self.basepath, "mpi-io-test.c"),
|
|
||||||
)
|
|
||||||
cc = Executable(self.spec["mpi"].mpicc)
|
|
||||||
compile_opt = ["-c", fname]
|
|
||||||
link_opt = ["-o", "mpi-io-test", "mpi-io-test.o"]
|
|
||||||
cc(*(compile_opt))
|
|
||||||
cc(*(link_opt))
|
|
||||||
|
|
||||||
# run test program and intercept
|
# compile the program
|
||||||
purpose = "Test running code built against darshan"
|
fname = join_path(
|
||||||
exe = "./mpi-io-test"
|
self.test_suite.current_test_cache_dir, self.basepath, f"{testexe}.c"
|
||||||
options = ["-f", "tmp.dat"]
|
)
|
||||||
status = [0]
|
cc = Executable(self.spec["mpi"].mpicc)
|
||||||
installed = False
|
compile_opt = ["-c", fname]
|
||||||
expected_output = [
|
link_opt = ["-o", "mpi-io-test", "mpi-io-test.o"]
|
||||||
r"Write bandwidth = \d+.\d+ Mbytes/sec",
|
cc(*(compile_opt))
|
||||||
r"Read bandwidth = \d+.\d+ Mbytes/sec",
|
cc(*(link_opt))
|
||||||
]
|
|
||||||
env["LD_PRELOAD"] = "libdarshan.so"
|
|
||||||
env["DARSHAN_LOGFILE"] = logname
|
|
||||||
self.run_test(
|
|
||||||
exe,
|
|
||||||
options,
|
|
||||||
expected_output,
|
|
||||||
status,
|
|
||||||
installed,
|
|
||||||
purpose,
|
|
||||||
skip_missing=False,
|
|
||||||
work_dir=None,
|
|
||||||
)
|
|
||||||
env.pop("LD_PRELOAD")
|
|
||||||
|
|
||||||
import llnl.util.tty as tty
|
# run test program and intercept
|
||||||
|
mpi_io_test = which(join_path(".", testexe))
|
||||||
|
out = mpi_io_test("-f", "tmp.dat", output=str.split, error=str.split)
|
||||||
|
env.pop("LD_PRELOAD")
|
||||||
|
|
||||||
# verify existence of log and size is > 0
|
expected_output = [
|
||||||
tty.msg("Test for existince of log:")
|
r"Write bandwidth = \d+.\d+ Mbytes/sec",
|
||||||
if os.path.exists(logname):
|
r"Read bandwidth = \d+.\d+ Mbytes/sec",
|
||||||
sr = os.stat(logname)
|
]
|
||||||
print("PASSED")
|
check_outputs(expected_output, out)
|
||||||
tty.msg("Test for size of log:")
|
|
||||||
if not sr.st_size > 0:
|
|
||||||
exc = BaseException("log size is 0")
|
|
||||||
m = None
|
|
||||||
if spack.config.get("config:fail_fast", False):
|
|
||||||
raise TestFailure([(exc, m)])
|
|
||||||
else:
|
|
||||||
self.test_failures.append((exc, m))
|
|
||||||
else:
|
|
||||||
print("PASSED")
|
|
||||||
else:
|
|
||||||
exc = BaseException("log does not exist")
|
|
||||||
m = None
|
|
||||||
if spack.config.get("config:fail_fast", False):
|
|
||||||
raise TestFailure([(exc, m)])
|
|
||||||
else:
|
|
||||||
self.test_failures.append((exc, m))
|
|
||||||
|
|
||||||
def test(self):
|
assert os.path.exists(logname), f"Expected {logname} to exist"
|
||||||
self._test_intercept()
|
assert (os.stat(logname)).st_size > 0, f"Expected non-empty {logname}"
|
||||||
|
Loading…
Reference in New Issue
Block a user