summaryrefslogtreecommitdiffstats
path: root/test/flush2.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/flush2.c')
-rw-r--r--test/flush2.c173
1 files changed, 171 insertions, 2 deletions
diff --git a/test/flush2.c b/test/flush2.c
index 7dc45be..3f4328a 100644
--- a/test/flush2.c
+++ b/test/flush2.c
@@ -24,10 +24,20 @@
*/
#include "h5test.h"
+/* Make this private property (defined in H5Fprivate.h) available */
+/* This is used in the helper routine clear_status_flags() */
+#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags"
+
+
const char *FILENAME[] = {
"flush",
+ "flush-swmr",
"noflush",
+ "noflush-swmr",
+ "flush_extend",
+ "flush_extend-swmr",
"noflush_extend",
+ "noflush_extend-swmr",
NULL
};
@@ -134,6 +144,53 @@ error:
return 1;
} /* end check_file() */
+/*-------------------------------------------------------------------------
+ * Function: clear_status_flags
+ *
+ * Purpose: To clear the status_flags in the superblock of the file.
+ * It is smilar to the tool "h5clear".
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Vailin Choi
+ * July 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+clear_status_flags(char *name, hid_t fapl)
+{
+ hid_t new_fapl = -1;
+ hid_t fid = -1;
+ hbool_t clear = TRUE;
+
+ /* Get a copy of fapl */
+ if((new_fapl = H5Pcopy(fapl)) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Set this private property */
+ if(H5Pset(new_fapl, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Has to open rw */
+ if((fid = H5Fopen(name, H5F_ACC_RDWR, new_fapl)) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR;
+
+ /* CLose the property list */
+ if(H5Pclose(new_fapl) < 0)
+ FAIL_STACK_ERROR;
+
+ return 0;
+
+error:
+ return 1;
+} /* clear_status_flags() */
+
/*-------------------------------------------------------------------------
* Function: main
@@ -166,6 +223,26 @@ main(void)
/* Check the case where the file was flushed */
h5_fixname(FILENAME[0], fapl, name, sizeof name);
+
+ if(check_file(name, fapl, FALSE)) {
+ H5_FAILED()
+ goto error;
+ }
+ else
+ PASSED();
+
+
+ TESTING("H5Fflush (part2 with flush + SWMR)");
+
+ /* Check the case where the file was flushed w/SWMR */
+ h5_fixname(FILENAME[1], fapl, name, sizeof name);
+
+ /* Clear the status_flags of the file which is flushed and exited in flush1.c */
+ if(clear_status_flags(name, fapl) < 0) {
+ H5_FAILED()
+ goto error;
+ }
+
if(check_file(name, fapl, FALSE)) {
H5_FAILED()
goto error;
@@ -180,7 +257,31 @@ main(void)
H5Eget_auto2(H5E_DEFAULT,&func,NULL);
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
- h5_fixname(FILENAME[1], fapl, name, sizeof name);
+ h5_fixname(FILENAME[2], fapl, name, sizeof name);
+ /* No need to clear the status_flags because this file is not flushed in flush1.c */
+ /* H5Fopen() in check_file() will just return error */
+ if(check_file(name, fapl, FALSE))
+ PASSED()
+ else {
+#if defined H5_HAVE_WIN32_API && !defined (hdf5_EXPORTS)
+ SKIPPED();
+ puts(" DLL will flush the file even when calling _exit, skip this test temporarily");
+#else
+ H5_FAILED()
+ goto error;
+#endif
+ }
+ H5Eset_auto2(H5E_DEFAULT, func, NULL);
+
+ /* Check the case where the file was not flushed. This should give an error
+ * so we turn off the error stack temporarily */
+ TESTING("H5Fflush (part2 without flush + SWMR)");
+ H5Eget_auto2(H5E_DEFAULT,&func,NULL);
+ H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
+
+ h5_fixname(FILENAME[3], fapl, name, sizeof name);
+ /* No need to clear the status_flags because this file is not flushed in flush1.c */
+ /* H5Fopen() in check_file() will just return error */
if(check_file(name, fapl, FALSE))
PASSED()
else {
@@ -196,11 +297,79 @@ main(void)
/* 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 and another flush)");
+ H5Eget_auto2(H5E_DEFAULT,&func,NULL);
+ H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
+
+ h5_fixname(FILENAME[4], fapl, name, sizeof name);
+
+ /* Clear the status_flags of the file which is flushed and exited in flush1.c */
+ if(clear_status_flags(name, fapl) < 0) {
+ H5_FAILED()
+ goto error;
+ }
+
+ if(check_file(name, fapl, TRUE)) {
+ H5_FAILED()
+ goto error;
+ }
+ else
+ PASSED();
+
+ H5Eset_auto2(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 and another flush + SWMR)");
+ H5Eget_auto2(H5E_DEFAULT,&func,NULL);
+ H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
+
+ h5_fixname(FILENAME[5], fapl, name, sizeof name);
+
+ if(check_file(name, fapl, TRUE))
+ PASSED()
+ else {
+#if defined H5_HAVE_WIN32_API && !defined (hdf5_EXPORTS)
+ SKIPPED();
+ puts(" DLL will flush the file even when calling _exit, skip this test temporarily");
+#else
+ H5_FAILED()
+ goto error;
+#endif
+ }
+
+ H5Eset_auto2(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_auto2(H5E_DEFAULT,&func,NULL);
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
- h5_fixname(FILENAME[2], fapl, name, sizeof name);
+ h5_fixname(FILENAME[6], fapl, name, sizeof name);
+
+ if(check_file(name, fapl, TRUE))
+ PASSED()
+ else {
+#if defined H5_HAVE_WIN32_API && !defined (hdf5_EXPORTS)
+ SKIPPED();
+ puts(" DLL will flush the file even when calling _exit, skip this test temporarily");
+#else
+ H5_FAILED()
+ goto error;
+#endif
+ }
+
+ H5Eset_auto2(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 + SWMR)");
+ H5Eget_auto2(H5E_DEFAULT,&func,NULL);
+ H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
+
+ h5_fixname(FILENAME[7], fapl, name, sizeof name);
+
if(check_file(name, fapl, TRUE))
PASSED()
else {