summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-06-01 21:20:10 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-06-01 21:20:10 (GMT)
commit45bbf45250734eda45794d5fc5bcfde4454d734b (patch)
tree9925e40d4ccb5bfdc9904e29f9bb1297bf1330ea /test
parent3f84e6478518a288a3a22d4385b114527a2d5b6e (diff)
downloadhdf5-45bbf45250734eda45794d5fc5bcfde4454d734b.zip
hdf5-45bbf45250734eda45794d5fc5bcfde4454d734b.tar.gz
hdf5-45bbf45250734eda45794d5fc5bcfde4454d734b.tar.bz2
[svn-r10837] Purpose:
Bug fix/new feature Description: Setting "SEMI" or "STRONG" file close degrees causes problems when multiple file IDs exist for the same file on disk. Solution: Make the "SEMI" and "STRONG" settings only apply to the file ID that is being closed. Also, add an "H5F_OBJ_LOCAL" flag for the H5Fget_obj_count() & H5Fget_obj_ids() calls, so that applications can query about objects opened with a particular file ID instead of all the objects opened in the file on disk. Platforms tested: FreeBSD 4.11 (sleipnir) h5committest
Diffstat (limited to 'test')
-rw-r--r--test/mount.c34
-rw-r--r--test/tfile.c106
2 files changed, 114 insertions, 26 deletions
diff --git a/test/mount.c b/test/mount.c
index ac8212e..7a42790 100644
--- a/test/mount.c
+++ b/test/mount.c
@@ -712,7 +712,7 @@ test_unlink(hid_t fapl)
} H5E_END_TRY;
if (status>=0) {
H5_FAILED();
- puts(" Unmount by name should not have been allowed!");
+ printf(" %d: Unmount by name should not have been allowed!\n",__LINE__);
goto error;
}
H5E_BEGIN_TRY {
@@ -720,7 +720,7 @@ test_unlink(hid_t fapl)
} H5E_END_TRY;
if (status>=0) {
H5_FAILED();
- puts(" Unmount by name should not have been allowed!");
+ printf(" %d: Unmount by name should not have been allowed!\n",__LINE__);
goto error;
}
if (H5Funmount(mnt, ".")<0) goto error;
@@ -916,27 +916,27 @@ test_uniformity(hid_t fapl)
/* Build the virtual file */
if ((file1=H5Fopen(filename1, H5F_ACC_RDWR, fapl))<0 ||
(file2=H5Fopen(filename2, H5F_ACC_RDWR, fapl))<0)
- goto error;
- if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT)<0) goto error;
+ TEST_ERROR;
+ if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT)<0) TEST_ERROR;
/* Access some things from the file1 handle */
- if (H5Gget_objinfo(file1, "/", TRUE, NULL)<0) goto error;
- if (H5Gget_objinfo(file1, "/mnt1", TRUE, NULL)<0) goto error;
- if (H5Gget_objinfo(file1, "mnt1", TRUE, NULL)<0) goto error;
- if (H5Gget_objinfo(file1, "/mnt1/file2", TRUE, NULL)<0) goto error;
- if (H5Gget_objinfo(file1, "mnt1/file2", TRUE, NULL)<0) goto error;
+ if (H5Gget_objinfo(file1, "/", TRUE, NULL)<0) TEST_ERROR;
+ if (H5Gget_objinfo(file1, "/mnt1", TRUE, NULL)<0) TEST_ERROR;
+ if (H5Gget_objinfo(file1, "mnt1", TRUE, NULL)<0) TEST_ERROR;
+ if (H5Gget_objinfo(file1, "/mnt1/file2", TRUE, NULL)<0) TEST_ERROR;
+ if (H5Gget_objinfo(file1, "mnt1/file2", TRUE, NULL)<0) TEST_ERROR;
/* Access the same things from the file2 handle */
- if (H5Gget_objinfo(file2, "/", TRUE, NULL)<0) goto error;
- if (H5Gget_objinfo(file2, "/mnt1", TRUE, NULL)<0) goto error;
- if (H5Gget_objinfo(file2, "mnt1", TRUE, NULL)<0) goto error;
- if (H5Gget_objinfo(file2, "/mnt1/file2", TRUE, NULL)<0) goto error;
- if (H5Gget_objinfo(file2, "mnt1/file2", TRUE, NULL)<0) goto error;
+ if (H5Gget_objinfo(file2, "/", TRUE, NULL)<0) TEST_ERROR;
+ if (H5Gget_objinfo(file2, "/mnt1", TRUE, NULL)<0) TEST_ERROR;
+ if (H5Gget_objinfo(file2, "mnt1", TRUE, NULL)<0) TEST_ERROR;
+ if (H5Gget_objinfo(file2, "/mnt1/file2", TRUE, NULL)<0) TEST_ERROR;
+ if (H5Gget_objinfo(file2, "mnt1/file2", TRUE, NULL)<0) TEST_ERROR;
/* Shut down */
- if (H5Funmount(file1, "/mnt1")<0) goto error;
- if (H5Fclose(file1)<0) goto error;
- if (H5Fclose(file2)<0) goto error;
+ if (H5Funmount(file1, "/mnt1")<0) TEST_ERROR;
+ if (H5Fclose(file1)<0) TEST_ERROR;
+ if (H5Fclose(file2)<0) TEST_ERROR;
PASSED();
return 0;
diff --git a/test/tfile.c b/test/tfile.c
index 5955562..0e1e7ec 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -65,6 +65,10 @@
#define OBJ_ID_COUNT_6 6
#define OBJ_ID_COUNT_8 8
+#define GROUP1 "Group1"
+#define DSET1 "Dataset1"
+#define DSET2 "/Group1/Dataset2"
+
static void
create_objects(hid_t, hid_t, hid_t *, hid_t *, hid_t *, hid_t *);
static void
@@ -176,7 +180,7 @@ test_file_create(void)
ret = H5Pset_userblock(tmpl1, F2_USERBLOCK_SIZE);
CHECK(ret, FAIL, "H5Pset_userblock");
- ret = H5Pset_sizes(tmpl1, F2_OFFSET_SIZE, F2_LENGTH_SIZE);
+ ret = H5Pset_sizes(tmpl1, (size_t)F2_OFFSET_SIZE, (size_t)F2_LENGTH_SIZE);
CHECK(ret, FAIL, "H5Pset_sizes");
ret = H5Pset_sym_k(tmpl1, F2_SYM_INTERN_K, F2_SYM_LEAF_K);
@@ -535,9 +539,10 @@ test_file_close(void)
/* Create a dataset and a group in each file open respectively */
create_objects(fid1, fid2, &dataset_id, &group_id1, &group_id2, &group_id3);
- /* Close first open */
+ /* Close first open, should fail since it is SEMI and objects are
+ * still open. */
ret = H5Fclose(fid1);
- CHECK(ret, FAIL, "H5Fclose");
+ VERIFY(ret, FAIL, "H5Fclose");
/* Close second open, should fail since it is SEMI and objects are
* still open. */
@@ -547,6 +552,10 @@ test_file_close(void)
ret = H5Dclose(dataset_id);
CHECK(ret, FAIL, "H5Dclose");
+ /* Close first open */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
ret = H5Gclose(group_id1);
CHECK(ret, FAIL, "H5Gclose");
@@ -774,7 +783,7 @@ create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1,
/* Create a group in the second file open */
{
hid_t gid1, gid2, gid3;
- gid1 = H5Gcreate(fid2, "/group", 0);
+ gid1 = H5Gcreate(fid2, "/group", (size_t)0);
CHECK(gid1, FAIL, "H5Gcreate");
if(ret_gid1 != NULL)
*ret_gid1 = gid1;
@@ -837,7 +846,7 @@ test_get_file_id(void)
/* Create a group in the file. Make a duplicated file ID from the group.
* And close this duplicated ID
*/
- group_id = H5Gcreate(fid, GRP_NAME, 0);
+ group_id = H5Gcreate(fid, GRP_NAME, (size_t)0);
CHECK(group_id, FAIL, "H5Gcreate");
/* Test H5Iget_file_id() */
@@ -1280,7 +1289,7 @@ test_file_ishdf5(void)
buf[u]=(unsigned char)u;
/* Write some information */
- nbytes = HDwrite(fd, buf, 1024);
+ nbytes = HDwrite(fd, buf, (size_t)1024);
VERIFY(nbytes, 1024, "HDwrite");
/* Close the file */
@@ -1318,7 +1327,7 @@ test_file_open_dot(void)
CHECK(fid, FAIL, "H5Fcreate");
/* Create a group in the HDF5 file */
- gid = H5Gcreate(fid, GRP_NAME, 0);
+ gid = H5Gcreate(fid, GRP_NAME, (size_t)0);
CHECK(gid, FAIL, "H5Gcreate");
/* Create a dataspace for creating datasets */
@@ -1379,13 +1388,13 @@ test_file_open_dot(void)
/* Create a group with no name using the file ID */
H5E_BEGIN_TRY {
- gid2 = H5Gcreate(fid, ".", 0);
+ gid2 = H5Gcreate(fid, ".", (size_t)0);
} H5E_END_TRY;
VERIFY(gid2, FAIL, "H5Gcreate");
/* Create a group with no name using the group ID */
H5E_BEGIN_TRY {
- gid2 = H5Gcreate(gid, ".", 0);
+ gid2 = H5Gcreate(gid, ".", (size_t)0);
} H5E_END_TRY;
VERIFY(gid2, FAIL, "H5Gcreate");
@@ -1418,6 +1427,84 @@ test_file_open_dot(void)
/****************************************************************
**
+** test_file_open_overlap(): low-level file test routine.
+** This test checks whether opening files in an overlapping way
+** (as opposed to a nested manner) works correctly.
+**
+*****************************************************************/
+static void
+test_file_open_overlap(void)
+{
+ hid_t fid1, fid2;
+ hid_t did1, did2;
+ hid_t gid;
+ hid_t sid;
+ int nobjs; /* # of open objects */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing opening overlapping file opens\n"));
+
+ /* Create file */
+ fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ assert(fid1 > 0);
+
+ /* Open file also */
+ fid2 = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT);
+ assert(fid2 > 0);
+
+ /* Create a group in file */
+ gid = H5Gcreate(fid1, GROUP1, (size_t)0);
+ assert(gid > 0);
+
+ /* Create dataspace for dataset */
+ sid = H5Screate(H5S_SCALAR);
+ assert(sid > 0);
+
+ /* Create dataset in group w/first file ID */
+ did1 = H5Dcreate(gid, DSET1, H5T_NATIVE_INT, sid, H5P_DEFAULT);
+ assert(did1 > 0);
+
+ /* 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 */
+
+ /* Close dataset */
+ ret = H5Dclose(did1);
+ assert(ret >= 0);
+
+ /* Close group */
+ ret = H5Gclose(gid);
+ assert(ret >= 0);
+
+ /* Close first file ID */
+ ret = H5Fclose(fid1);
+ assert(ret >= 0);
+
+
+ /* Create dataset with second file ID */
+ did2 = H5Dcreate(fid2, DSET2, H5T_NATIVE_INT, sid, H5P_DEFAULT);
+ assert(did2 > 0);
+
+ /* Check number of objects opened in first file */
+ nobjs = H5Fget_obj_count(fid2, H5F_OBJ_ALL);
+ assert(nobjs == 2); /* 2 == file & dataset */
+
+ /* Close dataspace */
+ ret = H5Sclose(sid);
+ assert(ret >= 0);
+
+ /* Close second dataset */
+ ret = H5Dclose(did2);
+ assert(ret >= 0);
+
+ /* Close second file */
+ ret = H5Fclose(fid2);
+ assert(ret >= 0);
+} /* end test_file_open_overlap() */
+
+/****************************************************************
+**
** test_file(): Main low-level file I/O test routine.
**
****************************************************************/
@@ -1437,6 +1524,7 @@ test_file(void)
test_file_freespace(); /* Test file free space information */
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() */