diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2002-03-27 20:25:48 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2002-03-27 20:25:48 (GMT) |
commit | 0cb78c2087941ed7ae7ee1072433c1c6ce5db0e0 (patch) | |
tree | d58566239ae950aadf94b5176ac4b99251f8b2d7 /test/tmisc.c | |
parent | 7e9738f290af26d1bf4ab9db64544d9a89505f0a (diff) | |
download | hdf5-0cb78c2087941ed7ae7ee1072433c1c6ce5db0e0.zip hdf5-0cb78c2087941ed7ae7ee1072433c1c6ce5db0e0.tar.gz hdf5-0cb78c2087941ed7ae7ee1072433c1c6ce5db0e0.tar.bz2 |
[svn-r5097] Purpose:
Bug Fix
Description:
Regression test for following bug:
The H5Gget_objinfo() function was not setting the 'fileno' field in the
H5G_stat_t struct passed in.
Solution:
Added a "file serial number" to each file currently open in the library
and put that in the 'fileno' field. If a file is opened twice (with
H5Fopen) and the VFL driver detects that it is the same file (i.e. the
two file structures have the same "shared file info" in the library's
memory structures), they will have the same serial number.
This serial number has two drawbacks:
- If a VFL driver doesn't/can't detect that two calls to H5Fopen with
the same file actually _are_ the same file, each will get a
different serial number
- If the same file is closed and re-opened, the serial number will be
different.
It is be possible to fix the second drawback for many VFL drivers, but it
would be a lot of effort and probably isn't worth it until we've got a
good reason to do it. Dunno if we'll ever be able to fix the first
drawback...
Platforms tested:
FreeBSD 4.5 (sleipnir)
VS: ----------------------------------------------------------------------
Diffstat (limited to 'test/tmisc.c')
-rw-r--r-- | test/tmisc.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/test/tmisc.c b/test/tmisc.c index 6980fc3..03ce311 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -51,6 +51,12 @@ typedef struct { #define MISC3_FILL_VALUE 2 #define MISC3_DSET_NAME "/chunked" +/* Definitions for misc. test #4 */ +#define MISC4_FILE_1 "tmisc4a.h5" +#define MISC4_FILE_2 "tmisc4b.h5" +#define MISC4_GROUP_1 "/Group1" +#define MISC4_GROUP_2 "/Group2" + /**************************************************************** ** ** test_misc1(): test unlinking a dataset from a group and immediately @@ -359,6 +365,78 @@ test_misc3(void) CHECK(ret, FAIL, "H5Fclose"); } /* end test_misc3() */ +/**************************************************************** +** +** test_misc4(): Test the that 'fileno' field in H5G_stat_t is +** valid. +** +****************************************************************/ +static void +test_misc4(void) +{ + hid_t file1, file2, group1, group2, group3; + H5G_stat_t stat1, stat2, stat3; + herr_t ret; + + /* Output message about test being performed */ + MESSAGE(5, ("Testing fileno working in H5G_stat_t\n")); + + file1 = H5Fcreate(MISC4_FILE_1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(file1, FAIL, "H5Fcreate"); + + /* Create the first group */ + group1 = H5Gcreate(file1, MISC4_GROUP_1, 0); + CHECK(group1, FAIL, "H5Gcreate"); + + /* Create the second group */ + group2 = H5Gcreate(file1, MISC4_GROUP_2, 0); + CHECK(group2, FAIL, "H5Gcreate"); + + file2 = H5Fcreate(MISC4_FILE_2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(file2, FAIL, "H5Fcreate"); + + /* Create the first group */ + group3 = H5Gcreate(file2, MISC4_GROUP_1, 0); + CHECK(group3, FAIL, "H5Gcreate"); + + /* Get the stat information for each group */ + ret = H5Gget_objinfo(file1,MISC4_GROUP_1,0,&stat1); + CHECK(ret, FAIL, "H5Gget_objinfo"); + ret = H5Gget_objinfo(file1,MISC4_GROUP_2,0,&stat2); + CHECK(ret, FAIL, "H5Gget_objinfo"); + ret = H5Gget_objinfo(file2,MISC4_GROUP_1,0,&stat3); + CHECK(ret, FAIL, "H5Gget_objinfo"); + + /* Verify that the fileno values are the same for groups from file1 */ + VERIFY(stat1.fileno[0],stat2.fileno[0],"H5Gget_objinfo"); + VERIFY(stat1.fileno[1],stat2.fileno[1],"H5Gget_objinfo"); + + /* Verify that the fileno values are not the same between file1 & file2 */ + if(stat1.fileno[0]==stat3.fileno[0] && stat1.fileno[1]==stat3.fileno[1]) { + num_errs++; + printf("Error on line %d: stat1.fileno==stat3.fileno\n",__LINE__); + } /* end if */ + if(stat2.fileno[0]==stat3.fileno[0] && stat2.fileno[1]==stat3.fileno[1]) { + num_errs++; + printf("Error on line %d: stat1.fileno==stat3.fileno\n",__LINE__); + } /* end if */ + + /* Close the objects */ + ret = H5Gclose(group1); + CHECK(ret, FAIL, "H5Gclose"); + + ret = H5Gclose(group2); + CHECK(ret, FAIL, "H5Gclose"); + + ret = H5Gclose(group3); + CHECK(ret, FAIL, "H5Gclose"); + + ret = H5Fclose(file1); + CHECK(ret, FAIL, "H5Fclose"); + + ret = H5Fclose(file2); + CHECK(ret, FAIL, "H5Fclose"); +} /* end test_misc4() */ /**************************************************************** ** @@ -374,6 +452,7 @@ test_misc(void) test_misc1(); /* Test unlinking a dataset & immediately re-using name */ test_misc2(); /* Test storing a VL-derived datatype in two different files */ test_misc3(); /* Test reading from chunked dataset with non-zero fill value */ + test_misc4(); /* Test retrieving the fileno for various objects with H5Gget_objinfo() */ } /* test_misc() */ @@ -399,4 +478,6 @@ cleanup_misc(void) remove(MISC2_FILE_1); remove(MISC2_FILE_2); remove(MISC3_FILE); + remove(MISC4_FILE_1); + remove(MISC4_FILE_2); } |