diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/Makefile.in | 34 | ||||
-rw-r--r-- | test/filename.c | 154 | ||||
-rw-r--r-- | test/mount.c | 715 | ||||
-rw-r--r-- | test/testhdf5.h | 13 | ||||
-rw-r--r-- | test/tfile.c | 155 |
6 files changed, 851 insertions, 222 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index eb53695..6247d1a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -34,7 +34,7 @@ TEST_PROG=testhdf5 lheap ohdr stab gheap cache b+tree btree2 blocktrack sheap \ dtypes dsets cmpd_dset extend external links unlink big mtime \ fillval mount flush1 flush2 enum \ set_extent ttsafe stream_test \ - getname vfd ntypes dangle dtransform filename reserved + getname vfd ntypes dangle dtransform reserved # List programs to be built when testing here. error_test and err_compat are # built at the same time as the other tests, but executed by testerror.sh. diff --git a/test/Makefile.in b/test/Makefile.in index 54ec422..ce95a9b 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -29,7 +29,7 @@ # # HDF5 Library Test Makefile(.in) # -SOURCES = $(libh5test_la_SOURCES) b+tree.c big.c bittests.c blocktrack.c btree2.c cache.c cmpd_dset.c dangle.c dsets.c dt_arith.c dtransform.c dtypes.c enum.c err_compat.c error_test.c extend.c external.c filename.c fillval.c flush1.c flush2.c getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c mtime.c ntypes.c ohdr.c pool.c reserved.c set_extent.c sheap.c stab.c stream_test.c $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c +SOURCES = $(libh5test_la_SOURCES) b+tree.c big.c bittests.c blocktrack.c btree2.c cache.c cmpd_dset.c dangle.c dsets.c dt_arith.c dtransform.c dtypes.c enum.c err_compat.c error_test.c extend.c external.c fillval.c flush1.c flush2.c getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c mtime.c ntypes.c ohdr.c pool.c reserved.c set_extent.c sheap.c stab.c stream_test.c $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c srcdir = @srcdir@ top_srcdir = @top_srcdir@ @@ -81,7 +81,7 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \ flush2$(EXEEXT) enum$(EXEEXT) set_extent$(EXEEXT) \ ttsafe$(EXEEXT) stream_test$(EXEEXT) getname$(EXEEXT) \ vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \ - dtransform$(EXEEXT) filename$(EXEEXT) reserved$(EXEEXT) + dtransform$(EXEEXT) reserved$(EXEEXT) b_tree_SOURCES = b+tree.c b_tree_OBJECTS = b+tree.$(OBJEXT) b_tree_LDADD = $(LDADD) @@ -150,10 +150,6 @@ external_SOURCES = external.c external_OBJECTS = external.$(OBJEXT) external_LDADD = $(LDADD) external_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1) -filename_SOURCES = filename.c -filename_OBJECTS = filename.$(OBJEXT) -filename_LDADD = $(LDADD) -filename_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1) fillval_SOURCES = fillval.c fillval_OBJECTS = fillval.$(OBJEXT) fillval_LDADD = $(LDADD) @@ -273,19 +269,19 @@ LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ SOURCES = $(libh5test_la_SOURCES) b+tree.c big.c bittests.c \ blocktrack.c btree2.c cache.c cmpd_dset.c dangle.c dsets.c \ dt_arith.c dtransform.c dtypes.c enum.c err_compat.c \ - error_test.c extend.c external.c filename.c fillval.c flush1.c \ - flush2.c getname.c gheap.c hyperslab.c istore.c lheap.c \ - links.c mount.c mtime.c ntypes.c ohdr.c pool.c reserved.c \ - set_extent.c sheap.c stab.c stream_test.c $(testhdf5_SOURCES) \ - testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c + error_test.c extend.c external.c fillval.c flush1.c flush2.c \ + getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c \ + mtime.c ntypes.c ohdr.c pool.c reserved.c set_extent.c sheap.c \ + stab.c stream_test.c $(testhdf5_SOURCES) testmeta.c \ + $(ttsafe_SOURCES) unlink.c vfd.c DIST_SOURCES = $(libh5test_la_SOURCES) b+tree.c big.c bittests.c \ blocktrack.c btree2.c cache.c cmpd_dset.c dangle.c dsets.c \ dt_arith.c dtransform.c dtypes.c enum.c err_compat.c \ - error_test.c extend.c external.c filename.c fillval.c flush1.c \ - flush2.c getname.c gheap.c hyperslab.c istore.c lheap.c \ - links.c mount.c mtime.c ntypes.c ohdr.c pool.c reserved.c \ - set_extent.c sheap.c stab.c stream_test.c $(testhdf5_SOURCES) \ - testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c + error_test.c extend.c external.c fillval.c flush1.c flush2.c \ + getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c \ + mtime.c ntypes.c ohdr.c pool.c reserved.c set_extent.c sheap.c \ + stab.c stream_test.c $(testhdf5_SOURCES) testmeta.c \ + $(ttsafe_SOURCES) unlink.c vfd.c ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -532,7 +528,7 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache b+tree btree2 blocktrack sheap dtypes dsets cmpd_dset extend external links unlink big mtime \ fillval mount flush1 flush2 enum \ set_extent ttsafe stream_test \ - getname vfd ntypes dangle dtransform filename reserved + getname vfd ntypes dangle dtransform reserved # The libh5test.a library provides common support code for the tests. @@ -677,9 +673,6 @@ extend$(EXEEXT): $(extend_OBJECTS) $(extend_DEPENDENCIES) external$(EXEEXT): $(external_OBJECTS) $(external_DEPENDENCIES) @rm -f external$(EXEEXT) $(LINK) $(external_LDFLAGS) $(external_OBJECTS) $(external_LDADD) $(LIBS) -filename$(EXEEXT): $(filename_OBJECTS) $(filename_DEPENDENCIES) - @rm -f filename$(EXEEXT) - $(LINK) $(filename_LDFLAGS) $(filename_OBJECTS) $(filename_LDADD) $(LIBS) fillval$(EXEEXT): $(fillval_OBJECTS) $(fillval_DEPENDENCIES) @rm -f fillval$(EXEEXT) $(LINK) $(fillval_LDFLAGS) $(fillval_OBJECTS) $(fillval_LDADD) $(LIBS) @@ -776,7 +769,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extend.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/external.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filename.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fillval.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flush1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flush2.Po@am__quote@ diff --git a/test/filename.c b/test/filename.c deleted file mode 100644 index b11e6c7..0000000 --- a/test/filename.c +++ /dev/null @@ -1,154 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Programmer: Raymond Lu <slu@ncsa.uiuc.edu> - * June 29, 2004 - * - * Purpose: Tests the "H5Fget_name" functionality - */ - -#include "testhdf5.h" - -#define FILENAME "get_file_name" -#define GROUPNAME "group" -#define DSETNAME "dataset" -#define ATTRNAME "attribute" -#define DTYPENAME "compound" -#define NAME_BUF_SIZE 64 - -#define RANK 2 -#define NX 4 -#define NY 5 - -/* Compound datatype */ -typedef struct s1_t { - unsigned int a; - float b; -} s1_t; - -/* Used to make certain a return name _is_ the file name */ -#define VERIFY_NAME(x, val, where) do { \ - if (GetTestVerbosity()>=VERBO_HI) { \ - print_func(" Call to routine: %15s at line %4d in %s had value " \ - "%ld \n", (where), (int)__LINE__, __FILE__, (long)(x)); \ - } \ - if (strcmp(x, val)) { \ - TestErrPrintf("*** UNEXPECTED VALUE from %s should be %s, but is %s at line %4d " \ - "in %s\n", where, val, x, (int)__LINE__, __FILE__); \ - H5Eprint_stack(H5E_DEFAULT, stdout); \ - } \ -} while(0) - -int main( void ) -{ - char filename[NAME_BUF_SIZE]; - hid_t fapl; - hid_t file_id; - hid_t group_id; - hid_t dataset_id; - hid_t space_id; - hid_t type_id; - hid_t attr_id; - hsize_t dims[RANK] = {NX, NY}; - char name[NAME_BUF_SIZE]; - ssize_t name_len; - herr_t ret; - - TESTING("H5Fget_name"); - - /* Reset the library and get the file access property list */ - h5_reset(); - fapl = h5_fileaccess(); - - /* Initialize the file names */ - h5_fixname(FILENAME, fapl, filename, sizeof filename); - - /* Create a new file_id using default properties. */ - file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ); - CHECK(file_id, FAIL, "H5Fcreate"); - - /* Get and verify file name */ - name_len = H5Fget_name(file_id, name, NAME_BUF_SIZE); - CHECK(name_len, FAIL, "H5Fget_name"); - VERIFY_NAME(name, filename, "H5Fget_name"); - - /* Create a group in the root group */ - group_id = H5Gcreate(file_id, GROUPNAME, 0); - CHECK(group_id, FAIL, "H5Gcreate"); - - /* Get and verify file name */ - name_len = H5Fget_name(group_id, name, NAME_BUF_SIZE); - CHECK(name_len, FAIL, "H5Fget_name"); - VERIFY_NAME(name, filename, "H5Fget_name"); - - /* Create the data space */ - space_id = H5Screate_simple(RANK, dims, NULL); - CHECK(space_id, FAIL, "H5Screate_simple"); - - /* Try get file name from data space. Supposed to fail because - * it's illegal operation. */ - H5E_BEGIN_TRY { - name_len = H5Fget_name(space_id, name, NAME_BUF_SIZE); - } H5E_END_TRY; - VERIFY(name_len, FAIL, "H5Fget_name"); - - /* Create a new dataset */ - dataset_id = H5Dcreate(file_id, DSETNAME, H5T_NATIVE_INT, space_id, H5P_DEFAULT); - CHECK(dataset_id, FAIL, "H5Dcreate"); - - /* Get and verify file name */ - name_len = H5Fget_name(dataset_id, name, NAME_BUF_SIZE); - CHECK(name_len, FAIL, "H5Fget_name"); - VERIFY_NAME(name, filename, "H5Fget_name"); - - /* Create an attribute for the dataset */ - attr_id = H5Acreate(dataset_id,ATTRNAME,H5T_NATIVE_INT,space_id,H5P_DEFAULT); - CHECK(attr_id, FAIL, "H5Acreate"); - - /* Get and verify file name */ - name_len = H5Fget_name(attr_id, name, NAME_BUF_SIZE); - CHECK(name_len, FAIL, "H5Fget_name"); - VERIFY_NAME(name, filename, "H5Fget_name"); - - /* Create a compound datatype */ - type_id = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); - CHECK(type_id, FAIL, "H5Tcreate"); - - /* Insert fields */ - ret = H5Tinsert (type_id, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); - CHECK(ret, FAIL, "H5Tinsert"); - - ret = H5Tinsert (type_id, "b", HOFFSET(s1_t,b), H5T_NATIVE_FLOAT); - CHECK(ret, FAIL, "H5Tinsert"); - - /* Save it on file */ - ret = H5Tcommit(file_id, DTYPENAME, type_id); - CHECK(ret, FAIL, "H5Tcommit"); - - /* Get and verify file name */ - name_len = H5Fget_name(type_id, name, NAME_BUF_SIZE); - CHECK(name_len, FAIL, "H5Fget_name"); - VERIFY_NAME(name, filename, "H5Fget_name"); - - H5Tclose(type_id); - H5Aclose(attr_id); - H5Dclose(dataset_id); - H5Sclose(space_id); - H5Gclose(group_id); - H5Fclose(file_id); - - PASSED(); - return 0; -} diff --git a/test/mount.c b/test/mount.c index dd798a6..4813fa0 100644 --- a/test/mount.c +++ b/test/mount.c @@ -124,15 +124,21 @@ test_basic(hid_t fapl) h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); - if ((file1=H5Fopen(filename1, H5F_ACC_RDONLY, fapl))<0 || - (file2=H5Fopen(filename2, H5F_ACC_RDONLY, fapl))<0) - goto error; - if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT)<0) goto error; - if ((grp=H5Gopen(file1, "/mnt1/file2"))<0) goto error; - if (H5Gclose(grp)<0) goto error; - if (H5Funmount(file1, "/mnt1")<0) goto error; - if (H5Fclose(file1)<0) goto error; - if (H5Fclose(file2)<0) goto error; + if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || + (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR + if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + TEST_ERROR + if ((grp = H5Gopen(file1, "/mnt1/file2")) < 0) + TEST_ERROR + if (H5Gclose(grp) < 0) + TEST_ERROR + if (H5Funmount(file1, "/mnt1") < 0) + TEST_ERROR + if (H5Fclose(file1) < 0) + TEST_ERROR + if (H5Fclose(file2) < 0) + TEST_ERROR PASSED(); return 0; @@ -972,7 +978,6 @@ test_close(hid_t fapl) { hid_t file1=-1, file2=-1; char filename1[1024], filename2[1024]; - herr_t status; TESTING("file handle close"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); @@ -985,21 +990,21 @@ test_close(hid_t fapl) if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT)<0) goto error; /* - * Close file1 unmounting it from the virtual file. Objects in file2 are - * still accessible through the file2 handle, but nothing in file1 is - * accessible. + * Close file1 unmounting it from the virtual file. Objects in file1 are + * still accessible through the file2 handle. */ if (H5Fclose(file1)<0) goto error; - H5E_BEGIN_TRY { - status = H5Gget_objinfo(file2, "/mnt1", TRUE, NULL); - } H5E_END_TRY; - if (status>=0) { + if(H5Gget_objinfo(file2, "/mnt1", TRUE, NULL) < 0) { H5_FAILED(); - puts(" File1 contents are still accessible!"); + puts(" File1 contents are not accessible!"); goto error; } if (H5Fclose(file2)<0) goto error; + /* Check that all file IDs have been closed */ + if(H5I_nmembers(H5I_FILE) != 0) + TEST_ERROR + /* Build the virtual file again */ if ((file1=H5Fopen(filename1, H5F_ACC_RDWR, fapl))<0 || (file2=H5Fopen(filename2, H5F_ACC_RDWR, fapl))<0) @@ -1013,6 +1018,10 @@ test_close(hid_t fapl) if (H5Gget_objinfo(file1, "/mnt1/file2", TRUE, NULL)<0) goto error; if (H5Fclose(file1)<0) goto error; + /* Check that all file IDs have been closed */ + if(H5I_nmembers(H5I_FILE) != 0) + TEST_ERROR + /* Shut down */ PASSED(); return 0; @@ -1657,10 +1666,6 @@ test_missing_unmount(hid_t fapl) if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR - /* Check that all "file closing" IDs have been closed */ - if(H5I_nmembers(H5I_FILE_CLOSING) != 0) - TEST_ERROR - PASSED(); return 0; @@ -1795,10 +1800,6 @@ test_hold_open_file(hid_t fapl) if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR - /* Check that all "file closing" IDs have been closed */ - if(H5I_nmembers(H5I_FILE_CLOSING) != 0) - TEST_ERROR - PASSED(); return 0; @@ -1835,7 +1836,7 @@ static int test_hold_open_group(hid_t fapl) { hid_t fid1 = -1, fid2 = -1; /* File IDs */ - hid_t gidA = -1, gidM = -1, gidAM = -1, gidAM2 = -1; /* Group IDs */ + hid_t gid = -1, gidA = -1, gidM = -1, gidAM = -1, gidAM2 = -1; /* Group IDs */ char filename1[1024], filename2[1024]; /* Name of files to mount */ @@ -1916,21 +1917,326 @@ test_hold_open_group(hid_t fapl) if((gidAM2 = H5Gopen(fid1, "/A/M")) < 0) TEST_ERROR + /* Close file #1 */ + if(H5Fclose(fid1) < 0) + TEST_ERROR + + /* Get ID of file #2 */ + if((fid2 = H5Iget_file_id(gidAM2)) < 0) + TEST_ERROR + + /* Close group in mounted file */ + if(H5Gclose(gidAM2) < 0) + TEST_ERROR + + /* Attempt to open group in mounted file */ + /* (Should work because file is still mounted) */ + if((gidAM2 = H5Gopen(fid2, "/A/M")) < 0) + TEST_ERROR + + /* Close file #2 */ + if(H5Fclose(fid2) < 0) + TEST_ERROR + + /* Attempt to open group in parent file */ + /* (Should work because files should be mounted together) */ + if((gid = H5Gopen(gidAM2, "/")) < 0) + TEST_ERROR + /* Close group in mounted file */ if(H5Gclose(gidAM2) < 0) TEST_ERROR + /* Close group in parent file */ + if(H5Gclose(gid) < 0) + TEST_ERROR + + /* Check that all file IDs have been closed */ + if(H5I_nmembers(H5I_FILE) != 0) + TEST_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Gclose(gidM); + H5Gclose(gidAM); + H5Gclose(gidAM2); + H5Gclose(gidA); + H5Gclose(gid); + H5Fclose(fid2); + H5Fclose(fid1); + } H5E_END_TRY; + return 1; +} /* end test_hold_open_group() */ + + +/*------------------------------------------------------------------------- + * Function: test_fcdegree_same + * + * Purpose: Test that the library will only allow files with same file + * close degree to be mounted together. + * + * Return: Success: 0 + * + * Failure: number of errors + * + * Programmer: Quincey Koziol + * Tuesday, July 19, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_fcdegree_same(hid_t fapl) +{ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gidA = -1, gidM = -1, gidAM = -1; /* Group IDs */ + hid_t fapl_id = -1; /* FAPL IDs */ + herr_t ret; /* Generic return value */ + char filename1[1024], + filename2[1024]; /* Name of files to mount */ + + TESTING("file close degrees must be same"); + + h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); + h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); + + /* Create file #1 */ + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + if((gidA = H5Gcreate(fid1, "A", (size_t)0)) < 0) + TEST_ERROR + + if(H5Gclose(gidA) < 0) + TEST_ERROR + + if(H5Fclose(fid1) < 0) + TEST_ERROR + + + /* Create file #2 */ + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + if((gidM = H5Gcreate(fid2, "M", (size_t)0)) < 0) + TEST_ERROR + + if(H5Gclose(gidM) < 0) + TEST_ERROR + + if(H5Fclose(fid2) < 0) + TEST_ERROR + + + /* Re-open files and mount file #2 in file #1 */ + if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR + + if((gidA = H5Gopen(fid1, "A")) < 0) + TEST_ERROR + + /* Create FAPL & set file close degree for file #2 to be different */ + if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR + + /* Set file close mode to H5F_CLOSE_STRONG */ + if(H5Pset_fclose_degree(fapl_id, H5F_CLOSE_STRONG) < 0) + TEST_ERROR + + if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl_id)) < 0) + TEST_ERROR + + /* Try mounting file with different file close degree (should fail) */ + H5E_BEGIN_TRY { + ret = H5Fmount(gidA, ".", fid2, H5P_DEFAULT); + } H5E_END_TRY; + if(ret >= 0) + TEST_ERROR + + /* Set file close mode to H5F_CLOSE_WEAK */ + if(H5Pset_fclose_degree(fapl_id, H5F_CLOSE_WEAK) < 0) + TEST_ERROR + + /* Close file #2 & re-open with same file close degree as file #1 */ + if(H5Fclose(fid2) < 0) + TEST_ERROR + if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl_id)) < 0) + TEST_ERROR + + /* Try mounting files again (should work now) */ + if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + TEST_ERROR + + /* Verify opening group in mounted file */ + if((gidAM = H5Gopen(fid1, "A/M")) < 0) + TEST_ERROR + + /* Close group in mounted file */ + if(H5Gclose(gidAM) < 0) + TEST_ERROR + + /* Close group in parent file */ + if(H5Gclose(gidA) < 0) + TEST_ERROR + + /* Close file #2 */ + if(H5Fclose(fid2) < 0) + TEST_ERROR + /* Close file #1 */ - /* (should unmount file #2 also) */ if(H5Fclose(fid1) < 0) TEST_ERROR + /* Close FAPL ID */ + if(H5Pclose(fapl_id) < 0) + TEST_ERROR + /* Check that all file IDs have been closed */ if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR - /* Check that all "file closing" IDs have been closed */ - if(H5I_nmembers(H5I_FILE_CLOSING) != 0) + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(fapl_id); + H5Gclose(gidM); + H5Gclose(gidAM); + H5Gclose(gidA); + H5Fclose(fid2); + H5Fclose(fid1); + } H5E_END_TRY; + return 1; +} /* end test_fcdegree_same() */ + + +/*------------------------------------------------------------------------- + * Function: test_fcdegree_semi + * + * Purpose: Test that the library perform correct actions when using + * "semi" file close degree on mounted files + * + * Return: Success: 0 + * + * Failure: number of errors + * + * Programmer: Quincey Koziol + * Tuesday, July 19, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_fcdegree_semi(hid_t fapl) +{ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gidA = -1, gidM = -1, gidAM = -1; /* Group IDs */ + hid_t fapl_id = -1; /* FAPL IDs */ + herr_t ret; /* Generic return value */ + char filename1[1024], + filename2[1024]; /* Name of files to mount */ + + TESTING("'semi' file close degree"); + + h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); + h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); + + /* Create file #1 */ + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + if((gidA = H5Gcreate(fid1, "A", (size_t)0)) < 0) + TEST_ERROR + + if(H5Gclose(gidA) < 0) + TEST_ERROR + + if(H5Fclose(fid1) < 0) + TEST_ERROR + + + /* Create file #2 */ + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + if((gidM = H5Gcreate(fid2, "M", (size_t)0)) < 0) + TEST_ERROR + + if(H5Gclose(gidM) < 0) + TEST_ERROR + + if(H5Fclose(fid2) < 0) + TEST_ERROR + + + /* Create FAPL & set file close degree to be "semi" */ + if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR + + /* Set file close mode to H5F_CLOSE_SEMI */ + if(H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI) < 0) + TEST_ERROR + + /* Re-open files and mount file #2 in file #1 */ + if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl_id)) < 0) + TEST_ERROR + + if((gidA = H5Gopen(fid1, "A")) < 0) + TEST_ERROR + + if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl_id)) < 0) + TEST_ERROR + + /* Mount files together */ + if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + TEST_ERROR + + /* Verify opening group in mounted file */ + if((gidAM = H5Gopen(fid1, "A/M")) < 0) + TEST_ERROR + + /* Close file #1 (should succeed, since file #2 is open still) */ + if(H5Fclose(fid1) < 0) + TEST_ERROR + + /* Try closing file #2 (should fail, since there are still objects open) */ + H5E_BEGIN_TRY { + ret = H5Fclose(fid2); + } H5E_END_TRY; + if(ret >= 0) + TEST_ERROR + + /* Close group in parent file */ + if(H5Gclose(gidA) < 0) + TEST_ERROR + + /* Try closing file #2 (should still fail, since there are still objects open in child file) */ + H5E_BEGIN_TRY { + ret = H5Fclose(fid2); + } H5E_END_TRY; + if(ret >= 0) + TEST_ERROR + + /* Close group in mounted file */ + if(H5Gclose(gidAM) < 0) + TEST_ERROR + + /* Close file #2 (should succeed now) */ + if(H5Fclose(fid2) < 0) + TEST_ERROR + + /* Close FAPL ID */ + if(H5Pclose(fapl_id) < 0) + TEST_ERROR + + /* Check that all file IDs have been closed */ + if(H5I_nmembers(H5I_FILE) != 0) TEST_ERROR PASSED(); @@ -1938,15 +2244,356 @@ test_hold_open_group(hid_t fapl) error: H5E_BEGIN_TRY { + H5Pclose(fapl_id); H5Gclose(gidM); H5Gclose(gidAM); - H5Gclose(gidAM2); H5Gclose(gidA); H5Fclose(fid2); H5Fclose(fid1); } H5E_END_TRY; return 1; -} /* end test_hold_open_group() */ +} /* end test_fcdegree_semi() */ + + +/*------------------------------------------------------------------------- + * Function: test_fcdegree_strong + * + * Purpose: Test that the library perform correct actions when using + * "strong" file close degree on mounted files + * + * Return: Success: 0 + * + * Failure: number of errors + * + * Programmer: Quincey Koziol + * Tuesday, July 19, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_fcdegree_strong(hid_t fapl) +{ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gidA = -1, gidM = -1, gidAM = -1; /* Group IDs */ + hid_t fapl_id = -1; /* FAPL IDs */ + herr_t ret; /* Generic return value */ + char filename1[1024], + filename2[1024]; /* Name of files to mount */ + + TESTING("'strong' file close degree"); + + h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); + h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); + + /* Create file #1 */ + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + if((gidA = H5Gcreate(fid1, "A", (size_t)0)) < 0) + TEST_ERROR + + if(H5Gclose(gidA) < 0) + TEST_ERROR + + if(H5Fclose(fid1) < 0) + TEST_ERROR + + + /* Create file #2 */ + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + if((gidM = H5Gcreate(fid2, "M", (size_t)0)) < 0) + TEST_ERROR + + if(H5Gclose(gidM) < 0) + TEST_ERROR + + if(H5Fclose(fid2) < 0) + TEST_ERROR + + + /* Create FAPL & set file close degree to be "strong" */ + if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR + + /* Set file close mode to H5F_CLOSE_STRONG */ + if(H5Pset_fclose_degree(fapl_id, H5F_CLOSE_STRONG) < 0) + TEST_ERROR + + /* Re-open files and mount file #2 in file #1 */ + if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl_id)) < 0) + TEST_ERROR + + if((gidA = H5Gopen(fid1, "A")) < 0) + TEST_ERROR + + if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl_id)) < 0) + TEST_ERROR + + /* Mount files together */ + if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + TEST_ERROR + + /* Open group in mounted file */ + if((gidAM = H5Gopen(fid1, "A/M")) < 0) + TEST_ERROR + + /* Close file #1 */ + if(H5Fclose(fid1) < 0) + TEST_ERROR + + /* Check that objects are still open */ + if (H5Gget_objinfo(gidA, ".", TRUE, NULL) < 0) + TEST_ERROR + if (H5Gget_objinfo(gidAM, ".", TRUE, NULL) < 0) + TEST_ERROR + + /* Close file #2 (should close open objects also) */ + if(H5Fclose(fid2) < 0) + TEST_ERROR + + /* Check that objects are closed */ + H5E_BEGIN_TRY { + ret = H5Gget_objinfo(gidA, ".", TRUE, NULL); + } H5E_END_TRY; + if(ret >= 0) + TEST_ERROR + H5E_BEGIN_TRY { + ret = H5Gget_objinfo(gidAM, ".", TRUE, NULL); + } H5E_END_TRY; + if(ret >= 0) + TEST_ERROR + + /* Close FAPL ID */ + if(H5Pclose(fapl_id) < 0) + TEST_ERROR + + /* Check that all file IDs have been closed */ + if(H5I_nmembers(H5I_FILE) != 0) + TEST_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(fapl_id); + H5Gclose(gidM); + H5Gclose(gidAM); + H5Gclose(gidA); + H5Fclose(fid2); + H5Fclose(fid1); + } H5E_END_TRY; + return 1; +} /* end test_fcdegree_strong() */ + + +/*------------------------------------------------------------------------- + * Function: test_acc_perm + * + * Purpose: Test that the library correctly segregates operations in + * parts of mounted file hierarchy with files that have different + * R/W access permissions. + * + * + * Return: Success: 0 + * + * Failure: number of errors + * + * Programmer: Quincey Koziol + * Tuesday, July 19, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_acc_perm(hid_t fapl) +{ + hid_t fid1 = -1, fid2 = -1, fid3 = -1; /* File IDs */ + hid_t gidA = -1, gidB = -1, gidC = -1, gidM = -1, gidAM = -1, gidAMZ = -1; /* Group IDs */ + hid_t bad_id = -1; /* Bad ID from object create */ + char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */ + ssize_t name_len; /* Filename length */ + char filename1[1024], + filename2[1024], + filename3[1024]; /* Name of files to mount */ + + TESTING("access permissions"); + + h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); + h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); + h5_fixname(FILENAME[2], fapl, filename3, sizeof filename3); + + /* Create file #1 */ + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + if((gidA = H5Gcreate(fid1, "A", (size_t)0)) < 0) + TEST_ERROR + + if(H5Gclose(gidA) < 0) + TEST_ERROR + + if(H5Fclose(fid1) < 0) + TEST_ERROR + + + /* Create file #2 */ + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + if((gidM = H5Gcreate(fid2, "M", (size_t)0)) < 0) + TEST_ERROR + + if(H5Gclose(gidM) < 0) + TEST_ERROR + + if(H5Fclose(fid2) < 0) + TEST_ERROR + + + /* Re-open files and mount file #2 in file #1 */ + if((fid1 = H5Fopen(filename1, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + TEST_ERROR + + if((gidA = H5Gopen(fid1, "A")) < 0) + TEST_ERROR + + /* Get and verify file name */ + if((name_len = H5Fget_name(gidA, name, NAME_BUF_SIZE)) < 0) + TEST_ERROR + if(HDstrcmp(name, filename1) != 0) + TEST_ERROR + + if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Get and verify file name */ + if((name_len = H5Fget_name(fid2, name, NAME_BUF_SIZE)) < 0) + TEST_ERROR + if(HDstrcmp(name, filename2) != 0) + TEST_ERROR + + /* Mount files together */ + if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0) + TEST_ERROR + + /* Get and verify file name */ + if((name_len = H5Fget_name(fid2, name, NAME_BUF_SIZE)) < 0) + TEST_ERROR + if(HDstrcmp(name, filename2) != 0) + TEST_ERROR + + /* Open group in mounted file */ + if((gidAM = H5Gopen(fid1, "A/M")) < 0) + TEST_ERROR + + /* Get and verify file name */ + if((name_len = H5Fget_name(gidAM, name, NAME_BUF_SIZE)) < 0) + TEST_ERROR + if(HDstrcmp(name, filename2) != 0) + TEST_ERROR + + /* Attempt to create objects in read only file (should fail) */ + H5E_BEGIN_TRY { + bad_id = H5Gcreate(gidAM, "Z", (size_t)0); + } H5E_END_TRY; + if(bad_id >= 0) + TEST_ERROR + H5E_BEGIN_TRY { + bad_id = H5Gcreate(fid1, "/A/L", (size_t)0); + } H5E_END_TRY; + if(bad_id >= 0) + TEST_ERROR + + /* Attempt to create objects in read/write file (should succeed) */ + if((gidB = H5Gcreate(fid2, "/B", (size_t)0)) < 0) + TEST_ERROR + if(H5Gclose(gidB) < 0) + TEST_ERROR + + /* (Note that this object should get created in the "hidden" group for "A" in parent file) */ + if((gidC = H5Gcreate(gidA, "C", (size_t)0)) < 0) + TEST_ERROR + if(H5Gclose(gidC) < 0) + TEST_ERROR + + /* Create file #3 (it will have R/W permissions) */ + if((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Mount file #3 on file #2 */ + if(H5Fmount(gidAM, ".", fid3, H5P_DEFAULT) < 0) + TEST_ERROR + + /* Attempt to create objects in read/write file (should succeed) */ + if((gidAMZ = H5Gcreate(fid1, "/A/M/Z", (size_t)0)) < 0) + TEST_ERROR + + /* Get and verify file name */ + if((name_len = H5Fget_name(gidAMZ, name, NAME_BUF_SIZE)) < 0) + TEST_ERROR + if(HDstrcmp(name, filename3) != 0) + TEST_ERROR + + /* Close object in file #3 */ + if(H5Gclose(gidAMZ) < 0) + TEST_ERROR + + + /* Attempt to create objects in read only file again (should fail) */ + H5E_BEGIN_TRY { + bad_id = H5Gcreate(fid1, "/A/L", (size_t)0); + } H5E_END_TRY; + if(bad_id >= 0) + TEST_ERROR + + /* Close group in mounted file */ + if(H5Gclose(gidAM) < 0) + TEST_ERROR + + /* Close group in parent file */ + if(H5Gclose(gidA) < 0) + TEST_ERROR + + /* Close file #3 */ + if(H5Fclose(fid3) < 0) + TEST_ERROR + + /* Close file #2 */ + if(H5Fclose(fid2) < 0) + TEST_ERROR + + /* Close file #1 */ + if(H5Fclose(fid1) < 0) + TEST_ERROR + + + /* Check that all file IDs have been closed */ + if(H5I_nmembers(H5I_FILE) != 0) + TEST_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Gclose(gidM); + H5Gclose(gidAMZ); + H5Gclose(gidAM); + H5Gclose(gidC); + H5Gclose(gidB); + H5Gclose(gidA); + H5Fclose(fid3); + H5Fclose(fid2); + H5Fclose(fid1); + } H5E_END_TRY; + return 1; +} /* end test_acc_perm() */ /*------------------------------------------------------------------------- @@ -1993,6 +2640,10 @@ main(void) nerrors += test_missing_unmount(fapl); nerrors += test_hold_open_file(fapl); nerrors += test_hold_open_group(fapl); + nerrors += test_fcdegree_same(fapl); + nerrors += test_fcdegree_semi(fapl); + nerrors += test_fcdegree_strong(fapl); + nerrors += test_acc_perm(fapl); if (nerrors) goto error; puts("All mount tests passed."); diff --git a/test/testhdf5.h b/test/testhdf5.h index 7043950..2274b78 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -80,6 +80,19 @@ } \ } while(0) +/* Used to make certain a string return value _is_ a value */ +#define VERIFY_STR(x, val, where) do { \ + if (GetTestVerbosity()>=VERBO_HI) { \ + print_func(" Call to routine: %15s at line %4d in %s had value " \ + "%s \n", (where), (int)__LINE__, __FILE__, x); \ + } \ + if (HDstrcmp(x, val)) { \ + TestErrPrintf("*** UNEXPECTED VALUE from %s should be %s, but is %s at line %4d " \ + "in %s\n", where, val, x, (int)__LINE__, __FILE__); \ + H5Eprint_stack(H5E_DEFAULT, stdout); \ + } \ +} while(0) + /* Used to document process through a test and to check for errors */ #define RESULT(ret,func) do { \ if (GetTestVerbosity()>VERBO_MED) { \ diff --git a/test/tfile.c b/test/tfile.c index 0e1e7ec..05a0765 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -69,6 +69,15 @@ #define DSET1 "Dataset1" #define DSET2 "/Group1/Dataset2" +#define TESTA_GROUPNAME "group" +#define TESTA_DSETNAME "dataset" +#define TESTA_ATTRNAME "attribute" +#define TESTA_DTYPENAME "compound" +#define TESTA_NAME_BUF_SIZE 64 +#define TESTA_RANK 2 +#define TESTA_NX 4 +#define TESTA_NY 5 + static void create_objects(hid_t, hid_t, hid_t *, hid_t *, hid_t *, hid_t *); static void @@ -1447,64 +1456,181 @@ test_file_open_overlap(void) /* Create file */ fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - assert(fid1 > 0); + CHECK(fid1, FAIL, "H5Fcreate"); /* Open file also */ fid2 = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT); - assert(fid2 > 0); + CHECK(fid2, FAIL, "H5Fopen"); /* Create a group in file */ gid = H5Gcreate(fid1, GROUP1, (size_t)0); - assert(gid > 0); + CHECK(gid, FAIL, "H5Gcreate"); /* Create dataspace for dataset */ sid = H5Screate(H5S_SCALAR); - assert(sid > 0); + CHECK(sid, FAIL, "H5Screate"); /* Create dataset in group w/first file ID */ did1 = H5Dcreate(gid, DSET1, H5T_NATIVE_INT, sid, H5P_DEFAULT); - assert(did1 > 0); + CHECK(did1, FAIL, "H5Dcreate"); /* Check number of objects opened in first file */ nobjs = H5Fget_obj_count(fid1, H5F_OBJ_LOCAL|H5F_OBJ_ALL); - assert(nobjs == 3); /* 3 == file, dataset & group */ + VERIFY(nobjs, 3, "H5Fget_obj_count"); /* 3 == file, dataset & group */ /* Close dataset */ ret = H5Dclose(did1); - assert(ret >= 0); + CHECK(ret, FAIL, "H5Dclose"); /* Close group */ ret = H5Gclose(gid); - assert(ret >= 0); + CHECK(ret, FAIL, "H5Gclose"); /* Close first file ID */ ret = H5Fclose(fid1); - assert(ret >= 0); + CHECK(ret, FAIL, "H5Fclose"); /* Create dataset with second file ID */ did2 = H5Dcreate(fid2, DSET2, H5T_NATIVE_INT, sid, H5P_DEFAULT); - assert(did2 > 0); + CHECK(did2, FAIL, "H5Dcreate"); /* Check number of objects opened in first file */ nobjs = H5Fget_obj_count(fid2, H5F_OBJ_ALL); - assert(nobjs == 2); /* 2 == file & dataset */ + VERIFY(nobjs, 2, "H5Fget_obj_count"); /* 3 == file & dataset */ /* Close dataspace */ ret = H5Sclose(sid); - assert(ret >= 0); + CHECK(ret, FAIL, "H5Sclose"); /* Close second dataset */ ret = H5Dclose(did2); - assert(ret >= 0); + CHECK(ret, FAIL, "H5Dclose"); /* Close second file */ ret = H5Fclose(fid2); - assert(ret >= 0); + CHECK(ret, FAIL, "H5Fclose"); } /* end test_file_open_overlap() */ /**************************************************************** ** +** test_file_getname(): low-level file test routine. +** This test checks whether H5Fget_name works correctly. +** +*****************************************************************/ +static void +test_file_getname(void) +{ + /* Compound datatype */ + typedef struct s1_t { + unsigned int a; + float b; + } s1_t; + + hid_t file_id; + hid_t group_id; + hid_t dataset_id; + hid_t space_id; + hid_t type_id; + hid_t attr_id; + hsize_t dims[TESTA_RANK] = {TESTA_NX, TESTA_NY}; + char name[TESTA_NAME_BUF_SIZE]; + ssize_t name_len; + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing H5Fget_name() functionality\n")); + + /* Create a new file_id using default properties. */ + file_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); + CHECK(file_id, FAIL, "H5Fcreate"); + + /* Get and verify file name */ + name_len = H5Fget_name(file_id, name, TESTA_NAME_BUF_SIZE); + CHECK(name_len, FAIL, "H5Fget_name"); + VERIFY_STR(name, FILE1, "H5Fget_name"); + + /* Create a group in the root group */ + group_id = H5Gcreate(file_id, TESTA_GROUPNAME, 0); + CHECK(group_id, FAIL, "H5Gcreate"); + + /* Get and verify file name */ + name_len = H5Fget_name(group_id, name, TESTA_NAME_BUF_SIZE); + CHECK(name_len, FAIL, "H5Fget_name"); + VERIFY_STR(name, FILE1, "H5Fget_name"); + + /* Create the data space */ + space_id = H5Screate_simple(TESTA_RANK, dims, NULL); + CHECK(space_id, FAIL, "H5Screate_simple"); + + /* Try get file name from data space. Supposed to fail because + * it's illegal operation. */ + H5E_BEGIN_TRY { + name_len = H5Fget_name(space_id, name, TESTA_NAME_BUF_SIZE); + } H5E_END_TRY; + VERIFY(name_len, FAIL, "H5Fget_name"); + + /* Create a new dataset */ + dataset_id = H5Dcreate(file_id, TESTA_DSETNAME, H5T_NATIVE_INT, space_id, H5P_DEFAULT); + CHECK(dataset_id, FAIL, "H5Dcreate"); + + /* Get and verify file name */ + name_len = H5Fget_name(dataset_id, name, TESTA_NAME_BUF_SIZE); + CHECK(name_len, FAIL, "H5Fget_name"); + VERIFY_STR(name, FILE1, "H5Fget_name"); + + /* Create an attribute for the dataset */ + attr_id = H5Acreate(dataset_id,TESTA_ATTRNAME,H5T_NATIVE_INT,space_id,H5P_DEFAULT); + CHECK(attr_id, FAIL, "H5Acreate"); + + /* Get and verify file name */ + name_len = H5Fget_name(attr_id, name, TESTA_NAME_BUF_SIZE); + CHECK(name_len, FAIL, "H5Fget_name"); + VERIFY_STR(name, FILE1, "H5Fget_name"); + + /* Create a compound datatype */ + type_id = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); + CHECK(type_id, FAIL, "H5Tcreate"); + + /* Insert fields */ + ret = H5Tinsert (type_id, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); + CHECK(ret, FAIL, "H5Tinsert"); + + ret = H5Tinsert (type_id, "b", HOFFSET(s1_t,b), H5T_NATIVE_FLOAT); + CHECK(ret, FAIL, "H5Tinsert"); + + /* Save it on file */ + ret = H5Tcommit(file_id, TESTA_DTYPENAME, type_id); + CHECK(ret, FAIL, "H5Tcommit"); + + /* Get and verify file name */ + name_len = H5Fget_name(type_id, name, TESTA_NAME_BUF_SIZE); + CHECK(name_len, FAIL, "H5Fget_name"); + VERIFY_STR(name, FILE1, "H5Fget_name"); + + /* Close things down */ + ret = H5Tclose(type_id); + CHECK(ret, FAIL, "H5Tclose"); + + ret = H5Aclose(attr_id); + CHECK(ret, FAIL, "H5Aclose"); + + ret = H5Dclose(dataset_id); + CHECK(ret, FAIL, "H5Dclose"); + + ret = H5Sclose(space_id); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Gclose(group_id); + CHECK(ret, FAIL, "H5Gclose"); + + ret = H5Fclose(file_id); + CHECK(ret, FAIL, "H5Fclose"); + +} /* end test_file_getname() */ + +/**************************************************************** +** ** test_file(): Main low-level file I/O test routine. ** ****************************************************************/ @@ -1525,6 +1651,7 @@ test_file(void) test_file_ishdf5(); /* Test detecting HDF5 files correctly */ test_file_open_dot(); /* Test opening objects with "." for a name */ test_file_open_overlap(); /* Test opening files in an overlapping manner */ + test_file_getname(); /* Test basic H5Fget_name() functionality */ } /* test_file() */ |