diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2003-04-25 20:55:10 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2003-04-25 20:55:10 (GMT) |
commit | b11c892b4f57325ce7c18d8c67e42b08d338b8a7 (patch) | |
tree | 021d9fb32bd4a212d1fc334029248554277c5273 /test/tfile.c | |
parent | d76dfb1985412de2f30d7d92b6de2206d92202f4 (diff) | |
download | hdf5-b11c892b4f57325ce7c18d8c67e42b08d338b8a7.zip hdf5-b11c892b4f57325ce7c18d8c67e42b08d338b8a7.tar.gz hdf5-b11c892b4f57325ce7c18d8c67e42b08d338b8a7.tar.bz2 |
[svn-r6756]
Purpose: Verify library behavior
Description: A file is first opened as read only. Then it's closed with
an object left open. A second open of the same file for read and
write should fail.
Platforms tested: arabica - simply test to verify correct library behavior.
Diffstat (limited to 'test/tfile.c')
-rw-r--r-- | test/tfile.c | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/test/tfile.c b/test/tfile.c index c84cf3f..cac159a 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -43,6 +43,7 @@ #define F2_RANK 2 #define F2_DIM0 4 #define F2_DIM1 6 +#define F2_DSET "dset" #define FILE2 "tfile2.h5" #define F3_USERBLOCK_SIZE (hsize_t)0 @@ -204,7 +205,7 @@ test_file_create(void) CHECK(dataspace_id, FAIL, "H5Screate_simple"); /* Create the dataset. */ - dataset_id = H5Dcreate(fid2, "/dset", H5T_NATIVE_INT, dataspace_id, H5P_DEFAULT); + dataset_id = H5Dcreate(fid2, F2_DSET, H5T_NATIVE_INT, dataspace_id, H5P_DEFAULT); CHECK(dataset_id, FAIL, "H5Dcreate"); for(i=0; i<F2_DIM0; i++) @@ -310,7 +311,9 @@ test_file_create(void) static void test_file_open(void) { - hid_t fid1; /*HDF5 File IDs */ + hid_t fid1, fid2; /*HDF5 File IDs */ + hid_t did; /*dataset ID */ + hid_t fapl_id; /*file access property list ID */ hid_t tmpl1; /*file creation templates */ hsize_t ublock; /*sizeof user block */ size_t parm; /*file-creation parameters */ @@ -323,6 +326,10 @@ test_file_open(void) #endif /* H5_WANT_H5_V1_4_COMPAT */ herr_t ret; /*generic return value */ + /* + * Test single file open + */ + /* Output message about test being performed */ MESSAGE(5, ("Testing Low-Level File Opening I/O\n")); @@ -356,7 +363,45 @@ test_file_open(void) /* Close first file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_file_open() */ + + + /* + * Test two file opens: one is opened H5F_ACC_RDONLY and H5F_CLOSE_WEAK. + * It's closed with an object left open. Then another is opened + * H5F_ACC_RDWR, which should fail. + */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing 2 File Openings\n")); + + /* Create file access property list */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl_id, FAIL, "H5Pcreate"); + + /* Set file close mode to H5F_CLOSE_WEAK */ + ret = H5Pset_fclose_degree(fapl_id, H5F_CLOSE_WEAK); + CHECK(ret, FAIL, "H5Pset_fclose_degree"); + + /* Open file for first time */ + fid1 = H5Fopen(FILE2, H5F_ACC_RDONLY, fapl_id); + CHECK(fid1, FAIL, "H5Fopen"); + + /* Open dataset */ + did = H5Dopen(fid1, F2_DSET); + CHECK(did, FAIL, "H5Dopen"); + + /* Close first open */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + + /* Open file for second time, which should fail. */ + fid2 = H5Fopen(FILE2, H5F_ACC_RDWR, fapl_id); + VERIFY(fid2, FAIL, "H5Fopen"); + + /* Close dataset from first open */ + ret = H5Dclose(did); + CHECK(ret, FAIL, "H5Dclose"); +} /* test_file_open() */ /**************************************************************** ** |