summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Arber <larber@ncsa.uiuc.edu>2006-10-04 19:50:40 (GMT)
committerLeon Arber <larber@ncsa.uiuc.edu>2006-10-04 19:50:40 (GMT)
commit4dea870b6a383f57494af9a729dacf7f00537435 (patch)
tree992c59351db20f3076e36266fba79a241ba26724
parent3ac3e03244ebc93f4a75b8ab945a1b160e679e29 (diff)
downloadhdf5-4dea870b6a383f57494af9a729dacf7f00537435.zip
hdf5-4dea870b6a383f57494af9a729dacf7f00537435.tar.gz
hdf5-4dea870b6a383f57494af9a729dacf7f00537435.tar.bz2
[svn-r12718] Purpose: New Feature
Description: Add a new part to the flush test that checks to see what happens in case a file is flushed, and then a new dataset is created and the program exits without flushing this subsequent dataset. The test verifies that, at the very least, the data written out before the H5Fflush call is correct.
-rw-r--r--test/flush1.c66
-rw-r--r--test/flush2.c79
2 files changed, 130 insertions, 15 deletions
diff --git a/test/flush1.c b/test/flush1.c
index f6c99c3..9adf06d 100644
--- a/test/flush1.c
+++ b/test/flush1.c
@@ -27,6 +27,7 @@
const char *FILENAME[] = {
"flush",
"noflush",
+ "noflush_extend",
NULL
};
@@ -35,7 +36,7 @@ static double the_data[100][100];
/*-------------------------------------------------------------------------
* Function: create_file
*
- * Purpose: Creates file used in part 1 of the test
+ * Purpose: Creates files used in part 1 of the test
*
* Return: Success: 0
*
@@ -93,6 +94,59 @@ error:
}
+
+/*-------------------------------------------------------------------------
+ * Function: extend_file
+ *
+ * Purpose: Add a small dataset to the file.
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Leon Arber
+ * Oct. 4, 2006
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t extend_file(hid_t file)
+{
+ hid_t dcpl, space, dset;
+ hsize_t ds_size[2] = {100, 100};
+ hsize_t ch_size[2] = {5, 5};
+ hsize_t i, j;
+
+ /* Create a chunked dataset */
+ if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
+ if (H5Pset_chunk(dcpl, 2, ch_size)<0) goto error;
+ if ((space=H5Screate_simple(2, ds_size, NULL))<0) goto error;
+ if ((dset=H5Dcreate(file, "dset2", H5T_NATIVE_FLOAT, space, H5P_DEFAULT))<0)
+ goto error;
+
+ /* Write some data */
+ for (i=0; i<ds_size[0]; i++) {
+ /*
+ * The extra cast in the following statement is a bug workaround
+ * for the Win32 version 5.0 compiler.
+ * 1998-11-06 ptl
+ */
+ for (j=0; j<ds_size[1]; j++) {
+ the_data[i][j] = (double)(hssize_t)i/(hssize_t)(j+1);
+ }
+ }
+ if (H5Dwrite(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT,
+ the_data)<0) goto error;
+
+
+ return file;
+
+error:
+ HD_exit(1);
+
+}
+
/*-------------------------------------------------------------------------
* Function: main
*
@@ -108,6 +162,8 @@ error:
* Modifications:
* Leon Arber
* Sept. 26, 2006, expand test to check for failure if H5Fflush is not called.
+ * Oct. 4 2006, expand test to check for partial failure in case file is flushed, but then
+ * new datasets are created after the flush.
*
*
*-------------------------------------------------------------------------
@@ -133,6 +189,14 @@ main(void)
/* Flush and exit without closing the library */
if (H5Fflush(file, H5F_SCOPE_GLOBAL)<0) goto error;
+ /* Create the file */
+ h5_fixname(FILENAME[2], fapl, name, sizeof name);
+ file = create_file(name, fapl);
+ /* Flush and exit without closing the library */
+ if (H5Fflush(file, H5F_SCOPE_GLOBAL)<0) goto error;
+ /* Add a bit to the file and don't flush the new part */
+ extend_file(file);
+
/* Create the other file which will not be flushed */
h5_fixname(FILENAME[1], fapl, name, sizeof name);
file = create_file(name, fapl);
diff --git a/test/flush2.c b/test/flush2.c
index 8fed21f..0156961 100644
--- a/test/flush2.c
+++ b/test/flush2.c
@@ -26,37 +26,36 @@
const char *FILENAME[] = {
"flush",
"noflush",
+ "noflush_extend",
NULL
};
static double the_data[100][100];
-
/*-------------------------------------------------------------------------
- * Function: check_file
+ * Function: check_dset
*
- * Purpose: Part 2 of a two-part H5Fflush() test.
+ * Purpose: Part 2 of a two-part H5Fflush() test, checks if the data in a dataset
+ * is what it is supposed to be.
*
* Return: Success: 0
*
* Failure: 1
*
* Programmer: Leon Arber
- * Sept. 26, 2006.
+ * Oct. 4, 2006.
*
*-------------------------------------------------------------------------
*/
-int check_file(char* name, hid_t fapl)
-{
- hid_t file, space, dset, groups, grp;
- hsize_t ds_size[2];
+int check_dset(hid_t file, const char* name)
+{
+ hid_t space, dset;
+ hsize_t ds_size[2] = {100, 100};
double error;
hsize_t i, j;
- if ((file=H5Fopen(name, H5F_ACC_RDONLY, fapl))<0) goto error;
-
/* Open the dataset */
- if ((dset=H5Dopen(file, "dset"))<0) goto error;
+ if ((dset=H5Dopen(file, name))<0) goto error;
if ((space=H5Dget_space(dset))<0) goto error;
if (H5Sget_simple_extent_dims(space, ds_size, NULL)<0) goto error;
assert(100==ds_size[0] && 100==ds_size[1]);
@@ -82,6 +81,36 @@ int check_file(char* name, hid_t fapl)
}
}
}
+ if (H5Dclose(dset)<0) goto error;
+ return 0;
+
+error:
+ return 1;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: check_file
+ *
+ * Purpose: Part 2 of a two-part H5Fflush() test.
+ *
+ * Return: Success: 0
+ *
+ * Failure: 1
+ *
+ * Programmer: Leon Arber
+ * Sept. 26, 2006.
+ *
+ *-------------------------------------------------------------------------
+ */
+int check_file(char* filename, hid_t fapl, int flag)
+{
+ hid_t file, groups, grp;
+ char name[1024];
+ int i;
+
+ if ((file=H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) goto error;
+ if(check_dset(file, "dset")) goto error;
/* Open some groups */
if ((groups=H5Gopen(file, "some_groups"))<0) goto error;
@@ -91,8 +120,14 @@ int check_file(char* name, hid_t fapl)
if (H5Gclose(grp)<0) goto error;
}
+ /* Check to see if that last added dataset in the third file is accessible
+ * (it shouldn't be...but it might. Flag an error in case it is for now */
+ if(flag)
+ {
+ if(check_dset(file, "dset2")) goto error;
+ }
+
if (H5Gclose(groups)<0) goto error;
- if (H5Dclose(dset)<0) goto error;
if (H5Fclose(file)<0) goto error;
return 0;
error:
@@ -139,7 +174,7 @@ main(void)
if (HDstrcmp(envval, "core") && HDstrcmp(envval, "split")) {
/* Check the case where the file was flushed */
h5_fixname(FILENAME[0], fapl, name, sizeof name);
- if(check_file(name, fapl))
+ if(check_file(name, fapl, FALSE))
{
H5_FAILED()
goto error;
@@ -155,7 +190,7 @@ main(void)
H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL);
h5_fixname(FILENAME[1], fapl, name, sizeof name);
- if(check_file(name, fapl))
+ if(check_file(name, fapl, FALSE))
PASSED()
else
{
@@ -164,7 +199,23 @@ main(void)
}
H5Eset_auto_stack(H5E_DEFAULT, func, NULL);
+ /* Check the case where the file was flushed, but more data was added afterward. This should give an error
+ * so we turn off the error stack temporarily */
+ TESTING("H5Fflush (part2 with flush and later addition)");
+ H5Eget_auto_stack(H5E_DEFAULT,&func,NULL);
+ H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL);
+ h5_fixname(FILENAME[2], fapl, name, sizeof name);
+ if(check_file(name, fapl, TRUE))
+ PASSED()
+ else
+ {
+ H5_FAILED()
+ goto error;
+ }
+ H5Eset_auto_stack(H5E_DEFAULT, func, NULL);
+
+
h5_cleanup(FILENAME, fapl);
}
else