summaryrefslogtreecommitdiffstats
path: root/test/tmisc.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-01-23 21:28:24 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-01-23 21:28:24 (GMT)
commit5e7ed206eacbaf97f92765a393af0acffe931934 (patch)
tree1affec8d0f08d84a99659087066de758163b893d /test/tmisc.c
parent32f52d953cffb133e92b772746b66c57714ff6e8 (diff)
downloadhdf5-5e7ed206eacbaf97f92765a393af0acffe931934.zip
hdf5-5e7ed206eacbaf97f92765a393af0acffe931934.tar.gz
hdf5-5e7ed206eacbaf97f92765a393af0acffe931934.tar.bz2
[svn-r4851] Purpose:
Bug Fix Description: When file space was returned to the file space free-list for reuse, occasionally raw data allocations which used space from the free-list would overlap with the metadata accumulator and get over-written with the cached information in the accumulator, corrupting the data. Solution: Check if the space about to be recycled on the free-list is going to be used for raw data and also overlaps with the metadata accumulator cache, avoiding using space that fits those criteria. This fixes bug #701 Platforms tested: FreeBSD 4.5 (sleipnir)
Diffstat (limited to 'test/tmisc.c')
-rw-r--r--test/tmisc.c150
1 files changed, 150 insertions, 0 deletions
diff --git a/test/tmisc.c b/test/tmisc.c
new file mode 100644
index 0000000..6476c32
--- /dev/null
+++ b/test/tmisc.c
@@ -0,0 +1,150 @@
+/****************************************************************************
+ * NCSA HDF *
+ * Software Development Group *
+ * National Center for Supercomputing Applications *
+ * University of Illinois at Urbana-Champaign *
+ * 605 E. Springfield, Champaign IL 61820 *
+ * *
+ * For conditions of distribution and use, see the accompanying *
+ * hdf/COPYING file. *
+ * *
+ ****************************************************************************/
+
+/* $Id$ */
+
+/***********************************************************
+*
+* Test program: tmisc
+*
+* Test miscellaneous features not tested elsewhere. Generally
+* regression tests for bugs that are reported and don't
+* have an existing test to add them to.
+*
+*************************************************************/
+
+#include "hdf5.h"
+#include "testhdf5.h"
+
+#define FILE "tmisc.h5"
+
+/* Definitions for misc. test #1 */
+#define MISC1_VAL (13417386) /* 0xccbbaa */
+#define MISC1_VAL2 (15654348) /* 0xeeddcc */
+#define MISC1_DSET_NAME "/scalar_set"
+
+/****************************************************************
+**
+** test_misc1(): test unlinking a dataset from a group and immediately
+** re-using the dataset name
+**
+****************************************************************/
+static void
+test_misc1(void)
+{
+ int i;
+ int i_check;
+ hid_t file, dataspace, dataset;
+ herr_t ret;
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Unlinking Dataset and Re-creating It\n"));
+
+ file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(file, FAIL, "H5Fcreate");
+
+ dataspace = H5Screate(H5S_SCALAR);
+ CHECK(dataspace, FAIL, "H5Screate");
+
+ /* Write the dataset the first time. */
+ dataset = H5Dcreate(file, MISC1_DSET_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT);
+ CHECK(dataset, FAIL, "H5Dcreate");
+
+ i = MISC1_VAL;
+ ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &i);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Remove the dataset. */
+ ret = H5Gunlink(file, MISC1_DSET_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+
+ /* Write the dataset for the second time with a different value. */
+ dataset = H5Dcreate(file, MISC1_DSET_NAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT);
+ CHECK(dataset, FAIL, "H5Dcreate");
+
+ i = MISC1_VAL2;
+ ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &i);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ ret = H5Sclose(dataspace);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Fclose(file);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Now, check the value written to the dataset, after it was re-created */
+ file = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK(file, FAIL, "H5Fopen");
+
+ dataspace = H5Screate(H5S_SCALAR);
+ CHECK(dataspace, FAIL, "H5Screate");
+
+ dataset = H5Dopen(file, MISC1_DSET_NAME);
+ CHECK(dataset, FAIL, "H5Dopen");
+
+ ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &i_check);
+ CHECK(ret, FAIL, "H5Dread");
+ VERIFY(i_check,MISC1_VAL2,"H5Dread");
+
+ ret = H5Sclose(dataspace);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ ret = H5Fclose(file);
+ CHECK(ret, FAIL, "H5Fclose");
+
+} /* end test_misc1() */
+
+/****************************************************************
+**
+** test_misc(): Main misc. test routine.
+**
+****************************************************************/
+void
+test_misc(void)
+{
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Miscellaneous Routines\n"));
+
+ /* Various tests, using the same test file */
+ test_misc1(); /* Test unlinking a dataset & immediately re-using name */
+
+} /* test_misc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: cleanup_misc
+ *
+ * Purpose: Cleanup temporary test files
+ *
+ * Return: none
+ *
+ * Programmer: Albert Cheng
+ * July 2, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+cleanup_misc(void)
+{
+ remove(FILE);
+}