summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-05-10 01:34:10 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-05-10 01:34:10 -0700
commita1ebdf63f398800427d05f0d8ada4860b745cb82 (patch)
tree248add194e6cf740a334e0f0e6dfedcbff1109d3 /var
parent6c46a5d62371d1dc3e512d5665d0385a5335b238 (diff)
parent0cbaecca60d5852ef0fe0d1378c685ff1dc65fd1 (diff)
downloadspack-a1ebdf63f398800427d05f0d8ada4860b745cb82.tar.gz
spack-a1ebdf63f398800427d05f0d8ada4860b745cb82.tar.bz2
spack-a1ebdf63f398800427d05f0d8ada4860b745cb82.tar.xz
spack-a1ebdf63f398800427d05f0d8ada4860b745cb82.zip
Merge pull request #812 from eschnett/eschnett/hdf5-check-install
Check the installed HDF5 library for consistency
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/hdf5/package.py61
1 files changed, 58 insertions, 3 deletions
diff --git a/var/spack/repos/builtin/packages/hdf5/package.py b/var/spack/repos/builtin/packages/hdf5/package.py
index 470969832f..cae46d3301 100644
--- a/var/spack/repos/builtin/packages/hdf5/package.py
+++ b/var/spack/repos/builtin/packages/hdf5/package.py
@@ -24,6 +24,7 @@
##############################################################################
from spack import *
+import shutil
class Hdf5(Package):
@@ -114,14 +115,16 @@ class Hdf5(Package):
# this is not actually a problem.
extra_args.extend([
"--enable-parallel",
- "CC=%s" % spec['mpi'].prefix.bin + "/mpicc",
+ "CC=%s" % join_path(spec['mpi'].prefix.bin, "mpicc"),
])
if '+cxx' in spec:
- extra_args.append("CXX=%s" % spec['mpi'].prefix.bin + "/mpic++")
+ extra_args.append("CXX=%s" % join_path(spec['mpi'].prefix.bin,
+ "mpic++"))
if '+fortran' in spec:
- extra_args.append("FC=%s" % spec['mpi'].prefix.bin + "/mpifort")
+ extra_args.append("FC=%s" % join_path(spec['mpi'].prefix.bin,
+ "mpifort"))
if '+szip' in spec:
extra_args.append("--with-szlib=%s" % spec['szip'].prefix)
@@ -138,6 +141,58 @@ class Hdf5(Package):
*extra_args)
make()
make("install")
+ self.check_install(spec)
+
+ def check_install(self, spec):
+ "Build and run a small program to test the installed HDF5 library"
+ print "Checking HDF5 installation..."
+ checkdir = "spack-check"
+ with working_dir(checkdir, create=True):
+ source = r"""
+#include <hdf5.h>
+#include <assert.h>
+#include <stdio.h>
+int main(int argc, char **argv) {
+ unsigned majnum, minnum, relnum;
+ herr_t herr = H5get_libversion(&majnum, &minnum, &relnum);
+ assert(!herr);
+ printf("HDF5 version %d.%d.%d %u.%u.%u\n", H5_VERS_MAJOR, H5_VERS_MINOR,
+ H5_VERS_RELEASE, majnum, minnum, relnum);
+ return 0;
+}
+"""
+ expected = """\
+HDF5 version {version} {version}
+""".format(version=str(spec.version))
+ with open("check.c", 'w') as f:
+ f.write(source)
+ if '+mpi' in spec:
+ cc = which(join_path(spec['mpi'].prefix.bin, "mpicc"))
+ else:
+ cc = which('cc')
+ # TODO: Automate these path and library settings
+ cc('-c', "-I%s" % join_path(spec.prefix, "include"), "check.c")
+ cc('-o', "check", "check.o",
+ "-L%s" % join_path(spec.prefix, "lib"), "-lhdf5",
+ "-lz")
+ try:
+ check = Executable('./check')
+ output = check(return_output=True)
+ except:
+ output = ""
+ success = output == expected
+ if not success:
+ print "Produced output does not match expected output."
+ print "Expected output:"
+ print '-'*80
+ print expected
+ print '-'*80
+ print "Produced output:"
+ print '-'*80
+ print output
+ print '-'*80
+ raise RuntimeError("HDF5 install check failed")
+ shutil.rmtree(checkdir)
def url_for_version(self, version):
v = str(version)