diff options
author | Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> | 2023-06-26 03:40:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-26 12:40:03 +0200 |
commit | 05b6ac16bcc3c8bb802cbd6af0bd3b10bd15a258 (patch) | |
tree | 55f2f6702eb724b49a138ed8dc2ad119dfa601a6 /var/spack/repos/builtin/packages/mpich/package.py | |
parent | 81647122645477ee42c40e0683de044a4e7722fc (diff) | |
download | spack-05b6ac16bcc3c8bb802cbd6af0bd3b10bd15a258.tar.gz spack-05b6ac16bcc3c8bb802cbd6af0bd3b10bd15a258.tar.bz2 spack-05b6ac16bcc3c8bb802cbd6af0bd3b10bd15a258.tar.xz spack-05b6ac16bcc3c8bb802cbd6af0bd3b10bd15a258.zip |
tests/*mpi*: convert to new stand-alone test process (#35802)
Diffstat (limited to 'var/spack/repos/builtin/packages/mpich/package.py')
-rw-r--r-- | var/spack/repos/builtin/packages/mpich/package.py | 62 |
1 files changed, 41 insertions, 21 deletions
diff --git a/var/spack/repos/builtin/packages/mpich/package.py b/var/spack/repos/builtin/packages/mpich/package.py index 581f4d0d31..e07b7c4759 100644 --- a/var/spack/repos/builtin/packages/mpich/package.py +++ b/var/spack/repos/builtin/packages/mpich/package.py @@ -600,27 +600,47 @@ with '-Wl,-commons,use_dylibs' and without install test subdirectory for use during `spack test run`.""" self.cache_extra_test_sources(["examples", join_path("test", "mpi")]) - def run_mpich_test(self, example_dir, exe): - """Run stand alone tests""" - - test_dir = join_path(self.test_suite.current_test_cache_dir, example_dir) - exe_source = join_path(test_dir, "{0}.c".format(exe)) - - if not os.path.isfile(exe_source): - print("Skipping {0} test".format(exe)) - return + def mpi_launcher(self): + """Determine the appropriate launcher.""" + commands = [ + join_path(self.spec.prefix.bin, "mpirun"), + join_path(self.spec.prefix.bin, "mpiexec"), + ] + if "+slurm" in self.spec: + commands.insert(0, join_path(self.spec["slurm"].prefix.bin)) + return which(*commands) + + def run_mpich_test(self, subdir, exe, num_procs=1): + """Compile and run the test program.""" + path = self.test_suite.current_test_cache_dir.join(subdir) + with working_dir(path): + src = f"{exe}.c" + if not os.path.isfile(src): + raise SkipTest(f"{src} is missing") + + mpicc = which(os.environ["MPICC"]) + mpicc("-Wall", "-g", "-o", exe, src) + if num_procs > 1: + launcher = self.mpi_launcher() + if launcher is not None: + launcher("-n", str(num_procs), exe) + return + + test_exe = which(exe) + test_exe() + + def test_cpi(self): + """build and run cpi""" + self.run_mpich_test("examples", "cpi") - self.run_test( - self.prefix.bin.mpicc, - options=[exe_source, "-Wall", "-g", "-o", exe], - purpose="test: generate {0} file".format(exe), - work_dir=test_dir, - ) + def test_finalized(self): + """build and run finalized""" + self.run_mpich_test(join_path("test", "mpi", "init"), "finalized") - self.run_test(exe, purpose="test: run {0} example".format(exe), work_dir=test_dir) + def test_manyrma(self): + """build and run manyrma""" + self.run_mpich_test(join_path("test", "mpi", "perf"), "manyrma", 2) - def test(self): - self.run_mpich_test(join_path("test", "mpi", "init"), "finalized") - self.run_mpich_test(join_path("test", "mpi", "basic"), "sendrecv") - self.run_mpich_test(join_path("test", "mpi", "perf"), "manyrma") - self.run_mpich_test("examples", "cpi") + def test_sendrecv(self): + """build and run sendrecv""" + self.run_mpich_test(join_path("test", "mpi", "basic"), "sendrecv", 2) |