diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2011-04-17 05:20:49 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2011-04-17 05:20:49 (GMT) |
commit | 2898c115902975fa9e0cb4634a6b65598d24b445 (patch) | |
tree | ee9405729d168f8b070205ec0ff99fcfbfcc38aa /test | |
parent | 7610dd20af382ba6d784c95f6436bb56ff895e07 (diff) | |
download | hdf5-2898c115902975fa9e0cb4634a6b65598d24b445.zip hdf5-2898c115902975fa9e0cb4634a6b65598d24b445.tar.gz hdf5-2898c115902975fa9e0cb4634a6b65598d24b445.tar.bz2 |
[svn-r20535] Description:
Add explicit test that checks that the 'fileno' field in H5O_info_t
is the same for objects in the same file, whether the file was opened twice
or not.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Diffstat (limited to 'test')
-rw-r--r-- | test/th5o.c | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/test/th5o.c b/test/th5o.c index 17619ee..70f8067 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -1225,6 +1225,111 @@ test_h5o_comment_by_name(void) } /* test_h5o_comment_by_name() */ + +/**************************************************************** +** +** test_h5o_getinfo_same_file(): Test that querying the object info for +** objects in the same file will return the same file "number" +** +****************************************************************/ +static void +test_h5o_getinfo_same_file(void) +{ + hid_t fid1, fid2; /* HDF5 File ID */ + hid_t gid1, gid2; /* Group IDs */ + H5O_info_t oinfo1, oinfo2; /* Object info structs */ + herr_t ret; /* Value returned from API calls */ + + /* Create a new HDF5 file */ + fid1 = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid1, FAIL, "H5Fcreate"); + + /* Create two groups in the file */ + gid1 = H5Gcreate2(fid1, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid1, FAIL, "H5Gcreate2"); + gid2 = H5Gcreate2(fid1, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid2, FAIL, "H5Gcreate2"); + + /* Reset object info */ + HDmemset(&oinfo1, 0, sizeof(oinfo1)); + HDmemset(&oinfo2, 0, sizeof(oinfo2)); + + /* Query the object info for each object, through group IDs */ + ret = H5Oget_info(gid1, &oinfo1); + CHECK(ret, FAIL, "H5Oget_info"); + ret = H5Oget_info(gid2, &oinfo2); + CHECK(ret, FAIL, "H5Oget_info"); + + VERIFY(oinfo1.fileno, oinfo2.fileno, "file number from H5Oget_info"); + + /* Reset object info */ + HDmemset(&oinfo1, 0, sizeof(oinfo1)); + HDmemset(&oinfo2, 0, sizeof(oinfo2)); + + /* Query the object info for each object, by name */ + ret = H5Oget_info_by_name(fid1, "group1", &oinfo1, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_name"); + ret = H5Oget_info_by_name(fid1, "group2", &oinfo2, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_name"); + + VERIFY(oinfo1.fileno, oinfo2.fileno, "file number from H5Oget_info"); + + /* Close everything */ + ret = H5Gclose(gid1); + CHECK(ret, FAIL, "H5Gclose"); + ret = H5Gclose(gid2); + CHECK(ret, FAIL, "H5Gclose"); + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + + + /* Open file twice */ + fid1 = H5Fopen(TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(fid1, FAIL, "H5Fopen"); + fid2 = H5Fopen(TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(fid2, FAIL, "H5Fopen"); + + /* Open the two groups in the file */ + gid1 = H5Gopen2(fid1, "group1", H5P_DEFAULT); + CHECK(gid1, FAIL, "H5Gopen2"); + gid2 = H5Gopen2(fid2, "group2", H5P_DEFAULT); + CHECK(gid2, FAIL, "H5Gopen2"); + + /* Reset object info */ + HDmemset(&oinfo1, 0, sizeof(oinfo1)); + HDmemset(&oinfo2, 0, sizeof(oinfo2)); + + /* Query the object info for each object, through group IDs */ + ret = H5Oget_info(gid1, &oinfo1); + CHECK(ret, FAIL, "H5Oget_info"); + ret = H5Oget_info(gid2, &oinfo2); + CHECK(ret, FAIL, "H5Oget_info"); + + VERIFY(oinfo1.fileno, oinfo2.fileno, "file number from H5Oget_info"); + + /* Reset object info */ + HDmemset(&oinfo1, 0, sizeof(oinfo1)); + HDmemset(&oinfo2, 0, sizeof(oinfo2)); + + /* Query the object info for each object, by name */ + ret = H5Oget_info_by_name(fid1, "group1", &oinfo1, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_name"); + ret = H5Oget_info_by_name(fid1, "group2", &oinfo2, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_name"); + + VERIFY(oinfo1.fileno, oinfo2.fileno, "file number from H5Oget_info"); + + /* Close everything */ + ret = H5Gclose(gid1); + CHECK(ret, FAIL, "H5Gclose"); + ret = H5Gclose(gid2); + CHECK(ret, FAIL, "H5Gclose"); + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Fclose(fid2); + CHECK(ret, FAIL, "H5Fclose"); + +} /* test_h5o_getinfo_same_file() */ /**************************************************************** @@ -1246,6 +1351,7 @@ test_h5o(void) test_h5o_link(); /* Test object link routine */ test_h5o_comment(); /* Test routines for comment */ test_h5o_comment_by_name(); /* Test routines for comment by name */ + test_h5o_getinfo_same_file(); /* Test info for objects in the same file */ } /* test_h5o() */ |