#! /bin/sh
#
# The HDF4 filenames are created based upon the HDF5 filenames
# without the extension.
#
/usr/bin/cp -f ../testfiles/*.h5 .

# test for converting H5 groups to H4 Vgroups.
valgrind --leak-check=full ./h5toh4 tgroup.h5

# test for converting H5 datasets to H4 SDS's.
valgrind --leak-check=full ./h5toh4 tdset.h5

# test for converting H5 attributes to H4 attributes.
valgrind --leak-check=full ./h5toh4 tattr.h5

# test for converting H5 soft links.
valgrind --leak-check=full ./h5toh4 tslink.h5

# test for converting H5 hard links.
valgrind --leak-check=full ./h5toh4 thlink.h5

# test for converting H5 compound data type to H4 Vdata.
valgrind --leak-check=full ./h5toh4 tcompound.h5

# test for converting H5 compound data type to H4 Vdata. One member datatype is an HDF5 fixed-size string
valgrind --leak-check=full ./h5toh4 tcompound-str.h5

# test for converting all H5 objects at in same file.
valgrind --leak-check=full ./h5toh4 tall.h5

# tests for converting H5 objects with loops.
valgrind --leak-check=full ./h5toh4 tloop.h5

# test for converting extendable H5 datasets to H4 SDS's.
valgrind --leak-check=full ./h5toh4 tdset2.h5

# test for converting extendable H5 datasets with compound data type to H4 Vdata.
valgrind --leak-check=full ./h5toh4 tcompound2.h5


# tests for converting H5 objects from many different pathways.
valgrind --leak-check=full ./h5toh4 tmany.h5

# tests for converting H5 string objects.
valgrind --leak-check=full ./h5toh4 tstr.h5

# tests for converting more H5 string objects.
valgrind --leak-check=full ./h5toh4 tstr2.h5
valgrind --leak-check=full ./h5toh4 timage.h5
valgrind --leak-check=full ./h5toh4 ttable.h5
valgrind --leak-check=full ./h5toh4 tsds_attr.h5
valgrind --leak-check=full ./h5toh4 tsds_dim.h5

#
# The test for conversion are the same as above with the only difference
# being that the HDF4 filenames are given explicitly.
#

rm -rf *.hdf
valgrind --leak-check=full ./h5toh4 tgroup.h5 tgroup.hdf
valgrind --leak-check=full ./h5toh4 tdset.h5 tdset.hdf
valgrind --leak-check=full ./h5toh4 tattr.h5 tattr.hdf
valgrind --leak-check=full ./h5toh4 tslink.h5 tslink.hdf
valgrind --leak-check=full ./h5toh4 thlink.h5 thlink.hdf
valgrind --leak-check=full ./h5toh4 tcompound.h5 tcompound.hdf
valgrind --leak-check=full ./h5toh4 tcompound-str.h5 tcompound-str.hdf
valgrind --leak-check=full ./h5toh4 tall.h5 tall.hdf
valgrind --leak-check=full ./h5toh4 tloop.h5 tloop.hdf
valgrind --leak-check=full ./h5toh4 tdset2.h5 tdset2.hdf
valgrind --leak-check=full ./h5toh4 tcompound2.h5 tcompound2.hdf
valgrind --leak-check=full ./h5toh4 tmany.h5 tmany.hdf
valgrind --leak-check=full ./h5toh4 tstr.h5 tstr.hdf
valgrind --leak-check=full ./h5toh4 tstr2.h5 tstr2.hdf
valgrind --leak-check=full ./h5toh4 timage.h5 timage.hdf
valgrind --leak-check=full ./h5toh4 ttable.h5 ttable.hdf
valgrind --leak-check=full ./h5toh4 tsds_attr.h5 tsds_attr.hdf
valgrind --leak-check=full ./h5toh4 tsds_dim.h5 tsds_dim.hdf

#
# Again, the test for conversion are the same as the first set of test.
# Here, multiple conversion are done on HDF5 files at one time.
#

rm -rf *.hdf
valgrind --leak-check=full ./h5toh4 -m tgroup.h5 tdset.h5 tattr.h5 tslink.h5 thlink.h5
valgrind --leak-check=full ./h5toh4 -m tcompound.h5 tcompound-str.h5 tall.h5
valgrind --leak-check=full ./h5toh4 -m tloop.h5
valgrind --leak-check=full ./h5toh4 -m tdset2.h5 tcompound2.h5 tmany.h5
valgrind --leak-check=full ./h5toh4 -m tstr.h5 tstr2.h5

rm -rf *.hdf
valgrind --leak-check=full ./h5toh4 tgroup.h5 -r 
valgrind --leak-check=full ./h5toh4 tdset.h5 -r
valgrind --leak-check=full ./h5toh4 tattr.h5 -r
valgrind --leak-check=full ./h5toh4 tslink.h5 -r
valgrind --leak-check=full ./h5toh4 thlink.h5 -r
valgrind --leak-check=full ./h5toh4 tcompound.h5 -r
valgrind --leak-check=full ./h5toh4 tcompound-str.h5 -r
valgrind --leak-check=full ./h5toh4 tall.h5 -r
valgrind --leak-check=full ./h5toh4 tloop.h5 -r
valgrind --leak-check=full ./h5toh4 tdset2.h5 -r
valgrind --leak-check=full ./h5toh4 tcompound2.h5 -r
valgrind --leak-check=full ./h5toh4 tmany.h5 -r
valgrind --leak-check=full ./h5toh4 tstr.h5 -r
valgrind --leak-check=full ./h5toh4 tstr2.h5 -r
valgrind --leak-check=full ./h5toh4 timage.h5 -r
valgrind --leak-check=full ./h5toh4 ttable.h5 -r
valgrind --leak-check=full ./h5toh4 tsds_attr.h5 -r
valgrind --leak-check=full ./h5toh4 tsds_dim.h5 -r


rm -rf *.hdf
valgrind --leak-check=full ./h5toh4 tgroup.h5 -r tgroup-r.hdf
valgrind --leak-check=full ./h5toh4 tdset.h5 -r tdset-r.hdf
valgrind --leak-check=full ./h5toh4 tattr.h5 -r tattr-r.hdf
valgrind --leak-check=full ./h5toh4 tslink.h5 -r tslink-r.hdf
valgrind --leak-check=full ./h5toh4 thlink.h5 -r thlink-r.hdf
valgrind --leak-check=full ./h5toh4 tcompound.h5 -r tcompound-r.hdf
valgrind --leak-check=full ./h5toh4 tcompound-str.h5 -r tcompound-str-r.hdf
valgrind --leak-check=full ./h5toh4 tall.h5 -r tall-r.hdf
valgrind --leak-check=full ./h5toh4 tloop.h5 -r tloop-r.hdf
valgrind --leak-check=full ./h5toh4 tdset2.h5 -r tdset2-r.hdf
valgrind --leak-check=full ./h5toh4 tcompound2.h5 -r tcompound2-r.hdf
valgrind --leak-check=full ./h5toh4 tmany.h5 -r tmany-r.hdf
valgrind --leak-check=full ./h5toh4 tstr.h5 -r tstr-r.hdf
valgrind --leak-check=full ./h5toh4 tstr2.h5 -r tstr2-r.hdf
valgrind --leak-check=full ./h5toh4 timage.h5 -r timage-r.hdf
valgrind --leak-check=full ./h5toh4 ttable.h5 -r ttable-r.hdf
valgrind --leak-check=full ./h5toh4 tsds_attr.h5 -r tsds_attr-r.hdf
valgrind --leak-check=full ./h5toh4 tsds_dim.h5 -r tsds_dim-r.hdf

rm -rf *.hdf

