diff --git a/tests/io_all.c b/tests/io_all.c index f99a4e6..d77cbfc 100644 --- a/tests/io_all.c +++ b/tests/io_all.c @@ -1,7 +1,4 @@ -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif #include "trexio.h" #include #include @@ -16,14 +13,16 @@ int main() { /*============== Main test launcher ================*/ int rc; -#ifdef HAVE_HDF5 - rc = system("rm -f test_all.h5"); - assert (rc == 0); - test_write("test_all.h5", TREXIO_HDF5); - test_read ("test_all.h5", TREXIO_HDF5); - rc = system("rm -f test_all.h5"); - assert (rc == 0); -#endif + + bool have_hdf5 = trexio_has_backend(TREXIO_HDF5); + if(have_hdf5) { + rc = system("rm -f -- test_all.h5"); + assert (rc == 0); + test_write("test_all.h5", TREXIO_HDF5); + test_read ("test_all.h5", TREXIO_HDF5); + rc = system("rm -f -- test_all.h5"); + assert (rc == 0); + } rc = system("rm -rf test_all.dir"); assert (rc == 0); diff --git a/tests/test_f.f90 b/tests/test_f.f90 index fe36f43..7c4b141 100644 --- a/tests/test_f.f90 +++ b/tests/test_f.f90 @@ -1,6 +1,9 @@ program test_trexio use trexio + use, intrinsic :: iso_c_binding implicit none + + logical :: have_hdf5 print * , "============================================" print'(a,a)' , " TREXIO VERSION STRING : ", TREXIO_PACKAGE_VERSION @@ -19,14 +22,17 @@ program test_trexio ! No way to conditionally check whether compilation was done with HDF5 ! So temporarily disable the test for HDF5 back end at the moment -! call system('rm -rf test_write_f.h5') -! print *, 'call test_write(''test_write_f.h5'', TREXIO_HDF5)' -! call test_write('test_write_f.h5', TREXIO_HDF5) -! print *, 'call test_read(''test_write_f.h5'', TREXIO_HDF5)' -! call test_read('test_write_f.h5', TREXIO_HDF5) -! call system('rm -rf test_write_f.h5') -! -! call test_read_void('test_write_f.h5', TREXIO_HDF5) + have_hdf5 = trexio_has_backend(TREXIO_HDF5) + if (have_hdf5) then + call system('rm -f -- test_write_f.h5') + print *, 'call test_write(''test_write_f.h5'', TREXIO_HDF5)' + call test_write('test_write_f.h5', TREXIO_HDF5) + print *, 'call test_read(''test_write_f.h5'', TREXIO_HDF5)' + call test_read('test_write_f.h5', TREXIO_HDF5) + call system('rm -f -- test_write_f.h5') + + call test_read_void('test_write_f.h5', TREXIO_HDF5) + endif end program test_trexio