diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.in | 8 | ||||
-rw-r--r-- | test/testhdf5.c | 5 | ||||
-rw-r--r-- | test/testhdf5.h | 2 | ||||
-rw-r--r-- | test/tfile.c | 4 | ||||
-rw-r--r-- | test/tmisc.c | 150 |
5 files changed, 160 insertions, 9 deletions
diff --git a/test/Makefile.in b/test/Makefile.in index 7d4383f..0dc0b2e 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -48,7 +48,7 @@ MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \ tattr.h5 tselect.h5 mtime.h5 unlink.h5 \ fillval_[0-9].h5 fillval.raw mount_[0-9].h5 testmeta.h5 \ ttime.h5 trefer[12].h5 tvltypes.h5 tvlstr.h5 flush.h5 enum1.h5 \ - titerate.h5 ttsafe.h5 tarray1.h5 tgenprop.h5 + titerate.h5 ttsafe.h5 tarray1.h5 tgenprop.h5 tmisc.h5 CLEAN=$(TIMINGS) ## Source and object files for programs... The TEST_SRC list contains all the @@ -61,8 +61,8 @@ TEST_SRC=big.c bittests.c cmpd_dset.c dsets.c dtypes.c extend.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 \ - 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 \ + 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 TEST_OBJ=$(TEST_SRC:.c=.lo) @@ -85,7 +85,7 @@ $(TEST_PROGS): $(LIB) $(LIBHDF5) TESTHDF5_OBJ=testhdf5.lo tarray.lo tattr.lo tconfig.lo tfile.lo tgenprop.lo \ th5s.lo titerate.lo tmeta.lo ttime.lo trefer.lo tselect.lo ttbbt.lo \ - tvltypes.lo tvlstr.lo + tvltypes.lo tvlstr.lo tmisc.lo TTS_OBJ=ttsafe.lo ttsafe_dcreate.lo ttsafe_error.lo ttsafe_cancel.lo \ ttsafe_acreate.lo diff --git a/test/testhdf5.c b/test/testhdf5.c index 798c3ee..190cdf3 100644 --- a/test/testhdf5.c +++ b/test/testhdf5.c @@ -138,9 +138,7 @@ main(int argc, char *argv[]) int Summary = 0; int CleanUp = 1; int Cache = 1; - unsigned major, minor, release; - - + unsigned major, minor, release; #if !(defined MAC || defined __MWERKS__ || defined SYMANTEC_C) /* Un-buffer the stdout and stderr */ @@ -170,6 +168,7 @@ main(int argc, char *argv[]) InitTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration"); InitTest("array", test_array, cleanup_array, "Array Datatypes"); InitTest("genprop", test_genprop, cleanup_genprop, "Generic Properties"); + InitTest("misc", test_misc, cleanup_misc, "Miscellaneous"); Verbosity = 4; /* Default Verbosity is Low */ H5get_libversion(&major, &minor, &release); diff --git a/test/testhdf5.h b/test/testhdf5.h index ff79e75..0868983 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -135,6 +135,7 @@ void test_iterate(void); void test_array(void); void test_genprop(void); void test_configure(void); +void test_misc(void); /* Prototypes for the cleanup routines */ void cleanup_metadata(void); @@ -150,5 +151,6 @@ void cleanup_iterate(void); void cleanup_array(void); void cleanup_genprop(void); void cleanup_configure(void); +void cleanup_misc(void); #endif /* HDF5cleanup_H */ diff --git a/test/tfile.c b/test/tfile.c index 2b1eb28..07f8976 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -830,9 +830,9 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, /* close the two new files */ ret = H5Fclose(fid3); - CHECK(fid3, FAIL, "H5Fclose"); + CHECK(ret, FAIL, "H5Fclose"); ret = H5Fclose(fid4); - CHECK(fid4, FAIL, "H5Fclose"); + CHECK(ret, FAIL, "H5Fclose"); } /**************************************************************** diff --git a/test/tmisc.c b/test/tmisc.c new file mode 100644 index 0000000..6476c32 --- /dev/null +++ b/test/tmisc.c @@ -0,0 +1,150 @@ +/**************************************************************************** + * NCSA HDF * + * Software Development Group * + * National Center for Supercomputing Applications * + * University of Illinois at Urbana-Champaign * + * 605 E. Springfield, Champaign IL 61820 * + * * + * For conditions of distribution and use, see the accompanying * + * hdf/COPYING file. * + * * + ****************************************************************************/ + +/* $Id$ */ + +/*********************************************************** +* +* Test program: tmisc +* +* Test miscellaneous features not tested elsewhere. Generally +* regression tests for bugs that are reported and don't +* have an existing test to add them to. +* +*************************************************************/ + +#include "hdf5.h" +#include "testhdf5.h" + +#define FILE "tmisc.h5" + +/* Definitions for misc. test #1 */ +#define MISC1_VAL (13417386) /* 0xccbbaa */ +#define MISC1_VAL2 (15654348) /* 0xeeddcc */ +#define MISC1_DSET_NAME "/scalar_set" + +/**************************************************************** +** +** test_misc1(): test unlinking a dataset from a group and immediately +** re-using the dataset name +** +****************************************************************/ +static void +test_misc1(void) +{ + int i; + int i_check; + hid_t file, dataspace, dataset; + herr_t ret; + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Unlinking Dataset and Re-creating It\n")); + + file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(file, FAIL, "H5Fcreate"); + + dataspace = H5Screate(H5S_SCALAR); + CHECK(dataspace, FAIL, "H5Screate"); + + /* Write the dataset the first time. */ + dataset = H5Dcreate(file, MISC1_DSET_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT); + CHECK(dataset, FAIL, "H5Dcreate"); + + i = MISC1_VAL; + ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &i); + CHECK(ret, FAIL, "H5Dwrite"); + + ret = H5Dclose(dataset); + CHECK(ret, FAIL, "H5Dclose"); + + /* Remove the dataset. */ + ret = H5Gunlink(file, MISC1_DSET_NAME); + CHECK(ret, FAIL, "H5Gunlink"); + + /* Write the dataset for the second time with a different value. */ + dataset = H5Dcreate(file, MISC1_DSET_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT); + CHECK(dataset, FAIL, "H5Dcreate"); + + i = MISC1_VAL2; + ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &i); + CHECK(ret, FAIL, "H5Dwrite"); + + ret = H5Dclose(dataset); + CHECK(ret, FAIL, "H5Dclose"); + + ret = H5Sclose(dataspace); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); + + /* Now, check the value written to the dataset, after it was re-created */ + file = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(file, FAIL, "H5Fopen"); + + dataspace = H5Screate(H5S_SCALAR); + CHECK(dataspace, FAIL, "H5Screate"); + + dataset = H5Dopen(file, MISC1_DSET_NAME); + CHECK(dataset, FAIL, "H5Dopen"); + + ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &i_check); + CHECK(ret, FAIL, "H5Dread"); + VERIFY(i_check,MISC1_VAL2,"H5Dread"); + + ret = H5Sclose(dataspace); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Dclose(dataset); + CHECK(ret, FAIL, "H5Dclose"); + + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); + +} /* end test_misc1() */ + +/**************************************************************** +** +** test_misc(): Main misc. test routine. +** +****************************************************************/ +void +test_misc(void) +{ + /* Output message about test being performed */ + MESSAGE(5, ("Testing Miscellaneous Routines\n")); + + /* Various tests, using the same test file */ + test_misc1(); /* Test unlinking a dataset & immediately re-using name */ + +} /* test_misc() */ + + +/*------------------------------------------------------------------------- + * Function: cleanup_misc + * + * Purpose: Cleanup temporary test files + * + * Return: none + * + * Programmer: Albert Cheng + * July 2, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +void +cleanup_misc(void) +{ + remove(FILE); +} |