From 72fd501ebfa7d6f9a82f3c1339edf1a7100e6f5d Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Thu, 11 Apr 2002 18:57:24 -0500 Subject: [svn-r5173] Purpose: Compatibility with v1.5 Description: Modified a little to match V1.5's fill value changes. These files are forward compatibility testing. Platforms tested: Linux 2.2 --- test/Makefile.in | 10 ++--- test/fill_new.h5 | Bin 0 -> 2304 bytes test/fillval.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++- test/gen_old_fill.c | 59 ++++++++++++++++++++++++++ 4 files changed, 182 insertions(+), 6 deletions(-) create mode 100644 test/fill_new.h5 create mode 100644 test/gen_old_fill.c diff --git a/test/Makefile.in b/test/Makefile.in index dbc3c53..0ebbdb8 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -58,11 +58,11 @@ CLEAN=$(TIMINGS) ## overlap with other tests. TEST_SRC=big.c bittests.c cmpd_dset.c dsets.c dtypes.c extend.c \ - external.c fillval.c flush1.c flush2.c gheap.c h5test.c hyperslab.c \ - istore.c lheap.c links.c mount.c mtime.c ohdr.c stab.c tarray.c \ - tattr.c tconfig.c testhdf5.c testmeta.c tfile.c tgenprop.c th5s.c \ - titerate.c tmeta.c trefer.c tselect.c ttime.c ttbbt.c tvltypes.c tvlstr.c \ - tmisc.c unlink.c enum.c ttsafe.c ttsafe_dcreate.c ttsafe_error.c \ + external.c fillval.c flush1.c flush2.c gheap.c h5test.c \ + hyperslab.c istore.c lheap.c links.c mount.c mtime.c ohdr.c stab.c \ + tarray.c tattr.c tconfig.c testhdf5.c testmeta.c tfile.c tgenprop.c \ + th5s.c titerate.c tmeta.c trefer.c tselect.c ttime.c ttbbt.c tvltypes.c \ + tvlstr.c tmisc.c unlink.c enum.c ttsafe.c ttsafe_dcreate.c ttsafe_error.c \ ttsafe_cancel.c ttsafe_acreate.c gass_write.c gass_read.c gass_append.c \ srb_read.c srb_write.c srb_append.c stream_test.c diff --git a/test/fill_new.h5 b/test/fill_new.h5 new file mode 100644 index 0000000..29fdf98 Binary files /dev/null and b/test/fill_new.h5 differ diff --git a/test/fillval.c b/test/fillval.c index c794ff9..c8ecf2e 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -25,6 +25,10 @@ const char *FILENAME[] = { NULL }; +/* The fill_new.h5 is generated from gen_new_fill.c in HDF5 'test' directory + * from v1.5 and thereafter. To get this data file, simply compile + * gen_new_file.c with HDF5 library(v1.5 or thereafter) and run it. */ +#define FILE_COMPATIBLE "fill_new.h5" #define FILE_NAME_RAW "fillval.raw" @@ -679,7 +683,119 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) return 0; } - +/*------------------------------------------------------------------------- + * Function: test_compatible + * + * Purpose: Tests fill value and dataspace for datasets created by v1.5 + * library. + * + * Return: Success: 0 + * + * Failure: number of errors + * + * Programmer: Raymond Lu + * Feb 27, 2002 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_compatible(void) +{ + hid_t file=-1, dset1=-1, dset2=-1; + hid_t dcpl1=-1, dcpl2=-1, fspace=-1, mspace=-1; + int rd_fill=0, fill_val1=4444, val_rd=0, fill_val2=5555; + hsize_t dims[2], one[2]={1,1}; + hssize_t hs_offset[2]={3,4}; + + TESTING("contiguous dataset compatibility with v. 1.5"); + if((file=H5Fopen(FILE_COMPATIBLE, H5F_ACC_RDONLY, H5P_DEFAULT))<0) goto error; + + if((dset1=H5Dopen(file, "dset1"))<0) goto error; + if ((dcpl1=H5Dget_create_plist(dset1))<0) goto error; + if (H5Pget_fill_value(dcpl1, H5T_NATIVE_INT, &rd_fill)<0) goto error; + if (rd_fill != fill_val1) { + H5_FAILED(); + puts(" Got a different fill value than what was set."); + printf(" Got %ld, set %ld\n", (long)rd_fill, (long)fill_val1); + goto error; + } + if((fspace = H5Dget_space(dset1))<0) goto error; + if(H5Sget_simple_extent_dims(fspace, dims, NULL)<0) goto error; + if(dims[0] != 8 || dims[1] != 8) { + H5_FAILED(); + puts(" Got a different dimension size than what was set."); + printf(" Got dims[0]=%ld, dims[1]=%ld, set 8x8\n", (long)dims[0], (long)dims[1]); + goto error; + } + if((mspace=H5Screate_simple(2, one, NULL))<0) goto error; + if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL)<0) + goto error; + if(H5Dread(dset1, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, &val_rd)<0) + goto error; + if (val_rd != fill_val1) { + H5_FAILED(); + puts(" Got a different value than what was set."); + printf(" Got %ld, set %ld\n", (long)val_rd, (long)fill_val1); + goto error; + } + if(H5Pclose(dcpl1)<0) goto error; + if(H5Sclose(fspace)<0) goto error; + if(H5Sclose(mspace)<0) goto error; + if(H5Dclose(dset1)<0) goto error; + + + if((dset2=H5Dopen(file, "dset2"))<0) goto error; + if ((dcpl2=H5Dget_create_plist(dset2))<0) goto error; + if (H5Pget_fill_value(dcpl2, H5T_NATIVE_INT, &rd_fill)<0) goto error; + if (rd_fill != fill_val2) { + H5_FAILED(); + puts(" Got a different fill value than what was set."); + printf(" Got %ld, set %ld\n", (long)rd_fill, (long)fill_val2); + goto error; + } + fspace = -1; + if((fspace = H5Dget_space(dset2))<0) goto error; + dims[0] = dims[1] = -1; + if(H5Sget_simple_extent_dims(fspace, dims, NULL)<0) goto error; + if(dims[0] != 8 || dims[1] != 8) { + H5_FAILED(); + puts(" Got a different dimension size than what was set."); + printf(" Got dims[0]=%ld, dims[1]=%ld, set 8x8\n", (long)dims[0], (long)dims[1]); + goto error; + } + if((mspace=H5Screate_simple(2, one, NULL))<0) goto error; + if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL)<0) + goto error; + /* Should fail, there's no data to read */ + H5E_BEGIN_TRY { + if(H5Dread(dset2, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, &val_rd)>=0) + goto error; + } H5E_END_TRY; + if(H5Pclose(dcpl2)<0) goto error; + if(H5Sclose(fspace)<0) goto error; + if(H5Sclose(mspace)<0) goto error; + if(H5Dclose(dset2)<0) goto error; + + if(H5Fclose(file)<0) goto error; + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(dcpl1); + H5Sclose(fspace); + H5Sclose(mspace); + H5Dclose(dset1); + H5Pclose(dcpl2); + H5Sclose(fspace); + H5Dclose(dset2); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} + /*------------------------------------------------------------------------- * Function: main @@ -734,6 +850,7 @@ main(int argc, char *argv[]) nerrors += test_create(fapl, FILENAME[1], H5D_CONTIGUOUS); nerrors += test_rdwr (fapl, FILENAME[3], H5D_CONTIGUOUS); nerrors += test_extend(fapl, FILENAME[5], H5D_CONTIGUOUS); + nerrors += test_compatible(); } if (nerrors) goto error; diff --git a/test/gen_old_fill.c b/test/gen_old_fill.c new file mode 100644 index 0000000..1046600 --- /dev/null +++ b/test/gen_old_fill.c @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2000 NCSA + * All rights reserved. + * + * Programmer: Raymond Lu + * Feb 27, 2002 + * + * Purpose: This program is run to generate a HDF5 data file with fill + * value property. A new fill value design has been put into + * library v1.5. To test compatibility between v1.4 and v1.5, + * compile and run this program, it will generate a file called + * fill_old.h5. You need to move it to the /test directory + * in HDF5 source codes. The fillval.c program will read it. + * + */ + +#include "h5test.h" + +#define FILENAME "fill_old.h5" + +int main() +{ + hid_t file=-1, dcpl=-1, space=-1, dset1=-1, dset2=-1; + hsize_t cur_size[2]={8, 8}; + int fill_val = 4444; + + + if((file=H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) + <0) goto error; + if((space=H5Screate_simple(2, cur_size, cur_size))<0) goto error; + if((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error; + + /* Create a dataset without fill value */ + if((dset1 = H5Dcreate(file, "dset1", H5T_NATIVE_INT, space, dcpl))<0) + goto error; + if(H5Dclose(dset1)<0) goto error; + + /* Create a dataset with a fill value */ + if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill_val)<0) goto error; + if((dset2 = H5Dcreate(file, "dset2", H5T_NATIVE_INT, space, dcpl))<0) + goto error; + if(H5Dclose(dset2)<0) goto error; + + if(H5Sclose(space)<0) goto error; + if(H5Pclose(dcpl)<0) goto error; + if(H5Fclose(file)<0) goto error; + + return 0; + + error: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Sclose(space); + H5Dclose(dset1); + H5Dclose(dset2); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} -- cgit v0.12