summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>2023-05-28 00:46:31 -0700
committerGitHub <noreply@github.com>2023-05-28 09:46:31 +0200
commit1d88f690a48b0a8c22c3475e91c783dd3f2fd823 (patch)
tree5d484dfe877a93786bb30fe6e4c2d81c1d081d99
parentfbb271d804c4579d74ae0d1d292298dff335b23b (diff)
downloadspack-1d88f690a48b0a8c22c3475e91c783dd3f2fd823.tar.gz
spack-1d88f690a48b0a8c22c3475e91c783dd3f2fd823.tar.bz2
spack-1d88f690a48b0a8c22c3475e91c783dd3f2fd823.tar.xz
spack-1d88f690a48b0a8c22c3475e91c783dd3f2fd823.zip
tests/darshan-runtime: convert to new stand-alone test process (#37838)
-rw-r--r--var/spack/repos/builtin/packages/darshan-runtime/package.py99
1 files changed, 34 insertions, 65 deletions
diff --git a/var/spack/repos/builtin/packages/darshan-runtime/package.py b/var/spack/repos/builtin/packages/darshan-runtime/package.py
index f3eff99a7f..b5fd554dce 100644
--- a/var/spack/repos/builtin/packages/darshan-runtime/package.py
+++ b/var/spack/repos/builtin/packages/darshan-runtime/package.py
@@ -144,70 +144,39 @@ class DarshanRuntime(AutotoolsPackage):
test_inputs = [join_path(self.basepath, "mpi-io-test.c")]
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"
+ logname = join_path(os.getcwd(), testdir, "test.darshan")
+ testexe = "mpi-io-test"
+
with working_dir(testdir, create=True):
- if "+mpi" in self.spec:
- # compile a test program
- 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
- purpose = "Test running code built against darshan"
- exe = "./mpi-io-test"
- options = ["-f", "tmp.dat"]
- status = [0]
- installed = False
- expected_output = [
- r"Write bandwidth = \d+.\d+ Mbytes/sec",
- r"Read bandwidth = \d+.\d+ Mbytes/sec",
- ]
- 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
-
- # verify existence of log and size is > 0
- tty.msg("Test for existince of log:")
- if os.path.exists(logname):
- sr = os.stat(logname)
- print("PASSED")
- 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):
- self._test_intercept()
+ env["LD_PRELOAD"] = join_path(self.prefix.lib, "libdarshan.so")
+ env["DARSHAN_LOGFILE"] = logname
+
+ # compile the program
+ fname = join_path(
+ self.test_suite.current_test_cache_dir, self.basepath, f"{testexe}.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
+ mpi_io_test = which(join_path(".", testexe))
+ out = mpi_io_test("-f", "tmp.dat", output=str.split, error=str.split)
+ env.pop("LD_PRELOAD")
+
+ expected_output = [
+ r"Write bandwidth = \d+.\d+ Mbytes/sec",
+ r"Read bandwidth = \d+.\d+ Mbytes/sec",
+ ]
+ check_outputs(expected_output, out)
+
+ assert os.path.exists(logname), f"Expected {logname} to exist"
+ assert (os.stat(logname)).st_size > 0, f"Expected non-empty {logname}"