summaryrefslogtreecommitdiffstats
path: root/test/tfile.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2016-02-22 21:40:03 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2016-02-22 21:40:03 (GMT)
commit19a8216bd52b6a495c4bc989b7d01e9a7ecd46bf (patch)
treebf07b7366747d1519b628ea1c399bb5e8b654753 /test/tfile.c
parent7511d8b4691770a15f1ba9f7fcc242f038c79669 (diff)
downloadhdf5-19a8216bd52b6a495c4bc989b7d01e9a7ecd46bf.zip
hdf5-19a8216bd52b6a495c4bc989b7d01e9a7ecd46bf.tar.gz
hdf5-19a8216bd52b6a495c4bc989b7d01e9a7ecd46bf.tar.bz2
[svn-r29182] Re-commit of HDFFV-8740 fix, which adds the ability to configure
external dataset storage path behavior. This check-in fixes a bug in the original check-in where the external path stored in the file struct was not copied on reopen causing subsequent dataset operations to fail. Tested on: 64-bit Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 autotools serial w/ fortran and C++ autotools parallel (MPICH 3.1.4) w/ fortran
Diffstat (limited to 'test/tfile.c')
-rw-r--r--test/tfile.c60
1 files changed, 58 insertions, 2 deletions
diff --git a/test/tfile.c b/test/tfile.c
index 927ecab..db74720 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -52,6 +52,9 @@
#define FILE1 "tfile1.h5"
#define SFILE1 "sys_file1"
+#define REOPEN_FILE "tfile_reopen.h5"
+#define REOPEN_DSET "dset"
+
#define F2_USERBLOCK_SIZE (hsize_t)512
#define F2_OFFSET_SIZE 8
#define F2_LENGTH_SIZE 8
@@ -532,6 +535,59 @@ test_file_open(void)
/****************************************************************
**
+** test_file_reopen(): File reopen test routine.
+**
+****************************************************************/
+static void
+test_file_reopen(void)
+{
+ hid_t fid = -1; /* file ID from initial open */
+ hid_t rfid = -1; /* file ID from reopen */
+ hid_t did = -1; /* dataset ID (both opens) */
+ hid_t sid = -1; /* dataspace ID for dataset creation */
+ hsize_t dims = 6; /* dataspace size */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing File Re-opening\n"));
+
+ /* Create file via first ID */
+ fid = H5Fcreate(REOPEN_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK_I(fid, "H5Fcreate");
+
+ /* Create a dataset in the file */
+ sid = H5Screate_simple(1, &dims, &dims);
+ CHECK_I(sid, "H5Screate_simple")
+ did = H5Dcreate2(fid, REOPEN_DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK_I(did, "H5Dcreate2");
+
+ /* Close dataset and dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Reopen the file with a different file ID */
+ rfid = H5Freopen(fid);
+ CHECK_I(rfid, "H5Freopen");
+
+ /* Reopen the dataset through the reopen file ID */
+ did = H5Dopen2(rfid, REOPEN_DSET, H5P_DEFAULT);
+ CHECK_I(did, "H5Dopen2");
+
+ /* Close and clean up */
+ ret = H5Dclose(did);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Fclose(rfid);
+ CHECK(ret, FAIL, "H5Fclose");
+ HDremove(REOPEN_FILE);
+
+} /* test_file_reopen() */
+
+/****************************************************************
+**
** test_file_close(): low-level file close test routine.
** It mainly tests behavior with close degree.
**
@@ -3660,8 +3716,8 @@ test_file(void)
/* Output message about test being performed */
MESSAGE(5, ("Testing Low-Level File I/O\n"));
- test_file_create(); /* Test file creation(also creation templates)*/
- test_file_open(); /* Test file opening */
+ test_file_create(); /* Test file creation(also creation templates)*/
+ test_file_open(); /* Test file opening */
test_file_close(); /* Test file close behavior */
test_get_file_id(); /* Test H5Iget_file_id */
test_get_obj_ids(); /* Test H5Fget_obj_ids for Jira Issue 8528 */