summaryrefslogtreecommitdiffstats
path: root/test/unlink.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-04-11 16:37:18 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-04-11 16:37:18 (GMT)
commite804b4c75b06a0d28793a197d6511de2e781e0e5 (patch)
tree720021286d55c2dbd6d3ad32ce29e0db0d3f8a2e /test/unlink.c
parent705194a4ea98dbc5f0f4c8f78158a162c724512b (diff)
downloadhdf5-e804b4c75b06a0d28793a197d6511de2e781e0e5.zip
hdf5-e804b4c75b06a0d28793a197d6511de2e781e0e5.tar.gz
hdf5-e804b4c75b06a0d28793a197d6511de2e781e0e5.tar.bz2
[svn-r6632] Purpose:
Bug fix Description: This fixes a bug in the low-level metadata caching code in the library which could possibly lose metadata during file I/O when a lot of objects are inserted into a group. This also fixes a couple of (similar) fencepost bugs in the B-tree deletion code. Solution: For the metadata bug - call the low-level driver's 'write' routine instead of H5FD_write. For the B-tree bug - include the correct number of keys. Platforms tested: FreeBSD 4.8 (sleipnir) w/C++ Linux 2.4 (burrwhite) w/FORTRAN Solaris 2.7 (arabica) w/FORTRAN IRIX64 6.5 (modi4) w/FORTRAN & parallel (h5committest is still not working for me on burrwhite) Misc. update:
Diffstat (limited to 'test/unlink.c')
-rw-r--r--test/unlink.c109
1 files changed, 107 insertions, 2 deletions
diff --git a/test/unlink.c b/test/unlink.c
index f73c4cf..72b64a13 100644
--- a/test/unlink.c
+++ b/test/unlink.c
@@ -24,11 +24,16 @@ const char *FILENAME[] = {
"unlink",
"new_move_a",
"new_move_b",
+ "lunlink",
NULL
};
#define THE_OBJECT "/foo"
+/* Macros for test_create_unlink() */
+#define GROUPNAME "Group"
+#define NGROUPS 1000
+
/*-------------------------------------------------------------------------
* Function: test_one
@@ -453,6 +458,83 @@ check_new_move(void)
/*-------------------------------------------------------------------------
+ * Function: test_create_unlink
+ *
+ * Purpose: Creates and then unlinks a large number of objects
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * Friday, April 11, 2003
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int test_create_unlink(const char *msg, hid_t fapl)
+{
+ hid_t file, group;
+ unsigned u;
+ char groupname[1024];
+ char filename[1024];
+
+ TESTING(msg);
+
+ /* Create file */
+ h5_fixname(FILENAME[3], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
+ {
+ H5_FAILED();
+ puts(" Creating file failed");
+ goto error;
+ }
+
+ /* Create a many groups to remove */
+ for(u=0; u<NGROUPS; u++) {
+ sprintf(groupname,"%s %u",GROUPNAME,u);
+ if((group = H5Gcreate (file, groupname, 0))<0)
+ {
+ H5_FAILED();
+ printf("group %s creation failed\n",groupname);
+ goto error;
+ }
+ if(H5Gclose (group)<0)
+ {
+ H5_FAILED();
+ printf("closing group %s failed\n",groupname);
+ goto error;
+ }
+ } /* end for */
+
+ /* Remove the all the groups */
+ for(u=0; u<NGROUPS; u++) {
+ sprintf(groupname,"%s %u",GROUPNAME,u);
+ if(H5Gunlink (file, groupname)<0)
+ {
+ H5_FAILED();
+ printf("Unlinking group %s failed\n",groupname);
+ goto error;
+ }
+ } /* end for */
+
+ /* Close file */
+ if(H5Fclose(file)<0)
+ {
+ H5_FAILED();
+ printf("Closing file failed\n");
+ goto error;
+ }
+
+ PASSED();
+ return 0;
+
+error:
+ return -1;
+} /* end test_create_unlink() */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Test H5Gunlink()
@@ -471,10 +553,16 @@ check_new_move(void)
int
main(void)
{
- hid_t fapl, file;
+ hid_t fapl, fapl2, file;
int nerrors = 0;
char filename[1024];
+ /* Metadata cache parameters */
+ int mdc_nelmts;
+ size_t rdcc_nelmts;
+ size_t rdcc_nbytes;
+ double rdcc_w0;
+
/* Open */
h5_reset();
fapl = h5_fileaccess();
@@ -482,6 +570,19 @@ main(void)
if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
goto error;
+ /* Make copy of regular fapl, to turn down the elements in the metadata cache */
+ if((fapl2=H5Pcopy(fapl))<0)
+ goto error;
+
+ /* Get FAPL cache settings */
+ if(H5Pget_cache(fapl2,&mdc_nelmts,&rdcc_nelmts,&rdcc_nbytes,&rdcc_w0)<0)
+ printf("H5Pget_cache failed\n");
+
+ /* Change FAPL cache settings */
+ mdc_nelmts=1;
+ if(H5Pset_cache(fapl2,mdc_nelmts,rdcc_nelmts,rdcc_nbytes,rdcc_w0)<0)
+ printf("H5Pset_cache failed\n");
+
/* Tests */
nerrors += test_one(file);
nerrors += test_many(file);
@@ -489,6 +590,11 @@ main(void)
nerrors += test_rename(file);
nerrors += test_new_move();
nerrors += check_new_move();
+
+ /* Test creating & unlinking lots of objects with default FAPL */
+ nerrors += test_create_unlink("create and unlink large number of objects",fapl);
+ /* Test creating & unlinking lots of objects with a 1-element metadata cache FAPL */
+ nerrors += test_create_unlink("create and unlink large number of objects with small cache",fapl2);
/* Close */
if (H5Fclose(file)<0) goto error;
@@ -503,4 +609,3 @@ main(void)
return 1;
}
-