setup hdf5 test

deblank
pull/4831/head
Michael Hirsch, Ph.D 6 years ago
parent 1ebaeadf60
commit 4d54a22b49
No known key found for this signature in database
GPG Key ID: 6D23CDADAB0294F9
  1. 1
      ciimage/Dockerfile
  2. 9
      mesonbuild/dependencies/misc.py
  3. 32
      test cases/frameworks/25 hdf5/main.c
  4. 31
      test cases/frameworks/25 hdf5/main.cpp
  5. 17
      test cases/frameworks/25 hdf5/main.f90
  6. 33
      test cases/frameworks/25 hdf5/meson.build

@ -20,6 +20,7 @@ RUN sed -i '/^#\sdeb-src /s/^#//' "/etc/apt/sources.list" \
&& apt-get -y install --no-install-recommends wine-stable \
&& apt-get -y install llvm-dev libclang-dev \
&& apt-get -y install libgcrypt11-dev \
&& apt-get -y install libhdf5-dev \
&& dub fetch urld && dub build urld --compiler=gdc \
&& dub fetch dubtestproject \
&& dub build dubtestproject:test1 --compiler=ldc2 \

@ -57,16 +57,17 @@ class HDF5Dependency(ExternalDependency):
for larg in link_args:
lpath = Path(larg)
if lpath.is_file():
if language == 'c':
lang_link_args.append(str(lpath.parent / (lpath.stem + '_hl' + lpath.suffix)))
lang_link_args.append(larg)
elif language == 'cpp':
if language == 'cpp':
lang_link_args.append(str(lpath.parent / (lpath.stem + '_hl_cpp' + lpath.suffix)))
lang_link_args.append(str(lpath.parent / (lpath.stem + '_cpp' + lpath.suffix)))
elif language == 'fortran':
lang_link_args.append(str(lpath.parent / (lpath.stem + 'hl_fortran' + lpath.suffix)))
lang_link_args.append(str(lpath.parent / (lpath.stem + '_fortran' + lpath.suffix)))
# C is used by other languages
lang_link_args.append(str(lpath.parent / (lpath.stem + '_hl' + lpath.suffix)))
lang_link_args.append(larg)
self.link_args = lang_link_args
self.version = pkgdep.get_version()
self.is_found = True

@ -0,0 +1,32 @@
#include <stdio.h>
#include <stdlib.h>
#include "hdf5.h"
int main(void)
{
herr_t ier;
unsigned maj;
unsigned min;
unsigned rel;
ier = H5open();
if (ier) {
fprintf(stderr,"Unable to initialize HDF5: %d\n", ier);
return EXIT_FAILURE;
}
ier = H5get_libversion(&maj, &min, &rel);
if (ier) {
fprintf(stderr,"HDF5 did not initialize!\n");
return EXIT_FAILURE;
}
printf("C HDF5 version %d.%d.%d\n", maj, min, rel);
ier = H5close();
if (ier) {
fprintf(stderr,"Unable to close HDF5: %d\n", ier);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

@ -0,0 +1,31 @@
#include <iostream>
#include "hdf5.h"
int main(void)
{
herr_t ier;
unsigned maj;
unsigned min;
unsigned rel;
ier = H5open();
if (ier) {
std::cerr << "Unable to initialize HDF5: %d" << ier << std::endl;
return EXIT_FAILURE;
}
ier = H5get_libversion(&maj, &min, &rel);
if (ier) {
std::cerr << "HDF5 did not initialize!" << std::endl;
return EXIT_FAILURE;
}
printf("C++ HDF5 version %d.%d.%d\n", maj, min, rel);
ier = H5close();
if (ier) {
std::cerr << "Unable to close HDF5: %d" << ier << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

@ -0,0 +1,17 @@
use hdf5
implicit none
integer :: ier, major, minor, rel
call h5open_f(ier)
if (ier /= 0) error stop 'Unable to initialize HDF5'
call h5get_libversion_f(major, minor, rel, ier)
if (ier /= 0) error stop 'Unable to check HDF5 version'
print '(A,I1,A1,I0.2,A1,I1)','Fortran HDF5 version ',major,'.',minor,'.',rel
call h5close_f(ier)
if (ier /= 0) error stop 'Unable to close HDF5 library'
end program

@ -0,0 +1,33 @@
project('hdf5_test', 'c', 'cpp', 'fortran')
# --- C tests
h5c = dependency('hdf5', language : 'c', required : false)
if not h5c.found()
error('MESON_SKIP_TEST: HDF5 not found, skipping.')
endif
exec = executable('exec', 'main.c',
dependencies : h5c)
test('HDF5 C', exec)
# --- C++ tests
h5cpp = dependency('hdf5', language : 'cpp')
execpp = executable('execpp', 'main.cpp',
dependencies : h5cpp)
test('HDF5 C++', execpp)
# --- Fortran tests
h5f = dependency('hdf5', language : 'fortran')
exef = executable('exef', 'main.f90',
dependencies : h5f)
test('HDF5 Fortran', exef)
# Check we can apply a version constraint
if h5c.version() != 'unknown'
dependency('hdf5', version: '>=@0@'.format(h5c.version()))
endif
Loading…
Cancel
Save