summaryrefslogtreecommitdiffstats
path: root/test/flush2.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /test/flush2.c
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'test/flush2.c')
-rw-r--r--test/flush2.c209
1 files changed, 101 insertions, 108 deletions
diff --git a/test/flush2.c b/test/flush2.c
index c3103d9..cc38cf1 100644
--- a/test/flush2.c
+++ b/test/flush2.c
@@ -23,39 +23,29 @@
#include "h5test.h"
/* This file needs to access the file driver testing code */
-#define H5FD_FRIEND /*suppress error about including H5FDpkg */
+#define H5FD_FRIEND /*suppress error about including H5FDpkg */
#define H5FD_TESTING
-#include "H5FDpkg.h" /* File drivers */
+#include "H5FDpkg.h" /* File drivers */
/* 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"
+#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
-};
+const char *FILENAME[] = {"flush", "flush-swmr", "noflush",
+ "noflush-swmr", "flush_extend", "flush_extend-swmr",
+ "noflush_extend", "noflush_extend-swmr", NULL};
/* Number and size of dataset dims, chunk size, etc. */
-#define NELEMENTS 10000
-#define FIRST_DSET_NAME "dset1"
-#define SECOND_DSET_NAME "dset2"
+#define NELEMENTS 10000
+#define FIRST_DSET_NAME "dset1"
+#define SECOND_DSET_NAME "dset2"
/* Number of sub-groups created in the containing group */
-#define NGROUPS 100
+#define NGROUPS 100
static hbool_t dset_ok(hid_t fid, const char *dset_name);
static hbool_t file_ok(const char *filename, hid_t fapl_id, hbool_t check_second_dset);
-
/*-------------------------------------------------------------------------
* Function: dset_ok
*
@@ -71,34 +61,34 @@ static hbool_t file_ok(const char *filename, hid_t fapl_id, hbool_t check_second
static hbool_t
dset_ok(hid_t fid, const char *dset_name)
{
- hid_t sid = -1; /* dataspace ID */
- hid_t did = -1; /* dataset ID */
- int *data = NULL; /* data buffer */
- hsize_t dims[1] = {0}; /* size of dataset */
- int i; /* iterator */
+ hid_t sid = -1; /* dataspace ID */
+ hid_t did = -1; /* dataset ID */
+ int * data = NULL; /* data buffer */
+ hsize_t dims[1] = {0}; /* size of dataset */
+ int i; /* iterator */
/* Open the dataset and check size */
- if((did = H5Dopen2(fid, dset_name, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, dset_name, H5P_DEFAULT)) < 0)
goto error;
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto error;
- if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
goto error;
- if(dims[0] != NELEMENTS)
+ if (dims[0] != NELEMENTS)
goto error;
/* Read the data */
- if(NULL == (data = (int *)HDcalloc((size_t)NELEMENTS, sizeof(int))))
+ if (NULL == (data = (int *)HDcalloc((size_t)NELEMENTS, sizeof(int))))
goto error;
- if(H5Dread(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data) < 0)
goto error;
- for(i = 0; i < NELEMENTS; i++)
- if(i != data[i])
+ for (i = 0; i < NELEMENTS; i++)
+ if (i != data[i])
goto error;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto error;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto error;
HDfree(data);
@@ -106,17 +96,18 @@ dset_ok(hid_t fid, const char *dset_name)
return TRUE;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Sclose(sid);
H5Dclose(did);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
HDfree(data);
return FALSE;
} /* end dset_ok() */
-
/*-------------------------------------------------------------------------
* Function: file_ok
*
@@ -132,47 +123,49 @@ error:
static hbool_t
file_ok(const char *filename, hid_t fapl_id, hbool_t check_second_dset)
{
- hid_t fid = -1; /* file ID */
- hid_t top_gid = -1; /* containing group ID */
- hid_t gid = -1; /* subgroup ID */
- char group_name[32]; /* group name */
- int i; /* iterator */
+ hid_t fid = -1; /* file ID */
+ hid_t top_gid = -1; /* containing group ID */
+ hid_t gid = -1; /* subgroup ID */
+ char group_name[32]; /* group name */
+ int i; /* iterator */
/* open file */
- if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl_id)) < 0)
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl_id)) < 0)
goto error;
/* check datasets */
- if(!dset_ok(fid, FIRST_DSET_NAME))
+ if (!dset_ok(fid, FIRST_DSET_NAME))
goto error;
- if(check_second_dset)
- if(!dset_ok(fid, SECOND_DSET_NAME))
+ if (check_second_dset)
+ if (!dset_ok(fid, SECOND_DSET_NAME))
goto error;
/* check groups */
- if((top_gid = H5Gopen2(fid, "top_group", H5P_DEFAULT)) < 0)
+ if ((top_gid = H5Gopen2(fid, "top_group", H5P_DEFAULT)) < 0)
goto error;
- for(i = 0; i < NGROUPS; i++) {
+ for (i = 0; i < NGROUPS; i++) {
HDsprintf(group_name, "group%02d", i);
- if((gid = H5Gopen2(top_gid, group_name, H5P_DEFAULT)) < 0)
+ if ((gid = H5Gopen2(top_gid, group_name, H5P_DEFAULT)) < 0)
goto error;
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto error;
} /* end for */
- if(H5Gclose(top_gid) < 0)
+ if (H5Gclose(top_gid) < 0)
goto error;
- if(H5Fclose(fid) < 0)
+ if (H5Fclose(fid) < 0)
goto error;
return TRUE;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Gclose(top_gid);
H5Gclose(gid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FALSE;
} /* end file_ok() */
@@ -193,42 +186,43 @@ error:
static herr_t
clear_status_flags(const char *filename, hid_t fapl_id)
{
- hid_t new_fapl_id = -1; /* copy of the file access plist ID */
- hid_t fid = -1; /* file ID */
- hbool_t clear = TRUE;
+ hid_t new_fapl_id = -1; /* copy of the file access plist ID */
+ hid_t fid = -1; /* file ID */
+ hbool_t clear = TRUE;
/* Get a copy of fapl */
- if((new_fapl_id = H5Pcopy(fapl_id)) < 0)
+ if ((new_fapl_id = H5Pcopy(fapl_id)) < 0)
goto error;
/* Set this private property */
- if(H5Pset(new_fapl_id, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0)
+ if (H5Pset(new_fapl_id, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0)
goto error;
/* Has to open rw */
- if((fid = H5Fopen(filename, H5F_ACC_RDWR, new_fapl_id)) < 0)
+ if ((fid = H5Fopen(filename, H5F_ACC_RDWR, new_fapl_id)) < 0)
goto error;
/* CLose the property list */
- if(H5Pclose(new_fapl_id) < 0)
+ if (H5Pclose(new_fapl_id) < 0)
goto error;
/* Close the file */
- if(H5Fclose(fid) < 0)
+ if (H5Fclose(fid) < 0)
goto error;
return SUCCEED;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(new_fapl_id);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
} /* end clear_status_flags() */
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -245,19 +239,19 @@ error:
int
main(void)
{
- char *driver = NULL; /* name of current VFD (from env var) */
- hbool_t vfd_supports_swmr; /* whether the current VFD supports SWMR */
- hid_t fapl_id = -1; /* file access proplist ID */
- char filename[1024]; /* filename */
- hbool_t check_second_dset; /* whether or not to check the second dset */
- H5E_auto2_t func; /* for shutting off error reporting */
+ char * driver = NULL; /* name of current VFD (from env var) */
+ hbool_t vfd_supports_swmr; /* whether the current VFD supports SWMR */
+ hid_t fapl_id = -1; /* file access proplist ID */
+ char filename[1024]; /* filename */
+ hbool_t check_second_dset; /* whether or not to check the second dset */
+ H5E_auto2_t func; /* for shutting off error reporting */
h5_reset();
- if((fapl_id = h5_fileaccess()) < 0)
+ if ((fapl_id = h5_fileaccess()) < 0)
PUTS_ERROR("bad vfd-dependent fapl")
/* Check if the current VFD supports SWMR */
- driver = HDgetenv("HDF5_DRIVER");
+ driver = HDgetenv("HDF5_DRIVER");
vfd_supports_swmr = H5FD__supports_swmr_test(driver);
/* TEST 1 */
@@ -265,7 +259,7 @@ main(void)
TESTING("H5Fflush (part2 with flush)");
h5_fixname(FILENAME[0], fapl_id, filename, sizeof(filename));
check_second_dset = FALSE;
- if(file_ok(filename, fapl_id, check_second_dset))
+ if (file_ok(filename, fapl_id, check_second_dset))
PASSED();
else
TEST_ERROR
@@ -273,12 +267,12 @@ main(void)
/* TEST 2 */
/* Check the case where the file was flushed (w/SWMR) */
TESTING("H5Fflush (part2 with flush + SWMR)");
- if(vfd_supports_swmr) {
+ if (vfd_supports_swmr) {
h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename));
check_second_dset = FALSE;
- if(clear_status_flags(filename, fapl_id) < 0)
+ if (clear_status_flags(filename, fapl_id) < 0)
TEST_ERROR
- if(file_ok(filename, fapl_id, check_second_dset))
+ if (file_ok(filename, fapl_id, check_second_dset))
PASSED();
else
TEST_ERROR
@@ -290,14 +284,14 @@ main(void)
/* Check the case where the file was not flushed */
TESTING("H5Fflush (part2 without flush)");
/* Turn the error stack off (failures expected) */
- if(H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0)
+ if (H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0)
FAIL_STACK_ERROR
- if(H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0)
+ if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0)
FAIL_STACK_ERROR
h5_fixname(FILENAME[2], fapl_id, filename, sizeof(filename));
check_second_dset = FALSE;
- if(file_ok(filename, fapl_id, check_second_dset)) {
-#if defined H5_HAVE_WIN32_API && !defined (hdf5_EXPORTS)
+ if (file_ok(filename, fapl_id, check_second_dset)) {
+#if defined H5_HAVE_WIN32_API && !defined(hdf5_EXPORTS)
SKIPPED();
HDputs(" the DLL will flush the file even when calling _exit, skip this test temporarily");
#else
@@ -307,24 +301,24 @@ main(void)
else
PASSED();
/* Turn the error stack back on */
- if(H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0)
+ if (H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0)
FAIL_STACK_ERROR
/* TEST 4 */
/* Check the case where the file was not flushed (w/SWMR) */
TESTING("H5Fflush (part2 without flush + SWMR)");
- if(vfd_supports_swmr) {
+ if (vfd_supports_swmr) {
/* Turn the error stack off (failures expected) */
- if(H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0)
+ if (H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0)
FAIL_STACK_ERROR
- if(H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0)
+ if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0)
FAIL_STACK_ERROR
h5_fixname(FILENAME[3], fapl_id, filename, sizeof(filename));
check_second_dset = FALSE;
- if(clear_status_flags(filename, fapl_id) < 0)
+ if (clear_status_flags(filename, fapl_id) < 0)
TEST_ERROR
- if(file_ok(filename, fapl_id, check_second_dset)) {
-#if defined H5_HAVE_WIN32_API && !defined (hdf5_EXPORTS)
+ if (file_ok(filename, fapl_id, check_second_dset)) {
+#if defined H5_HAVE_WIN32_API && !defined(hdf5_EXPORTS)
SKIPPED();
HDputs(" the DLL will flush the file even when calling _exit, skip this test temporarily");
#else
@@ -334,7 +328,7 @@ main(void)
else
PASSED();
/* Turn the error stack back on */
- if(H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0)
+ if (H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0)
FAIL_STACK_ERROR
} /* end if */
else
@@ -347,7 +341,7 @@ main(void)
TESTING("H5Fflush (part2 with flush and later addition and another flush)");
check_second_dset = TRUE;
h5_fixname(FILENAME[4], fapl_id, filename, sizeof(filename));
- if(file_ok(filename, fapl_id, check_second_dset))
+ if (file_ok(filename, fapl_id, check_second_dset))
PASSED();
else
TEST_ERROR
@@ -357,12 +351,12 @@ main(void)
* added afterward and then flushed (w/SWMR)
*/
TESTING("H5Fflush (part2 with flush and later addition and another flush + SWMR)");
- if(vfd_supports_swmr) {
+ if (vfd_supports_swmr) {
check_second_dset = TRUE;
h5_fixname(FILENAME[5], fapl_id, filename, sizeof(filename));
- if(clear_status_flags(filename, fapl_id) < 0)
+ if (clear_status_flags(filename, fapl_id) < 0)
TEST_ERROR
- if(file_ok(filename, fapl_id, check_second_dset))
+ if (file_ok(filename, fapl_id, check_second_dset))
PASSED();
else
TEST_ERROR
@@ -376,14 +370,14 @@ main(void)
*/
TESTING("H5Fflush (part2 with flush and later addition)");
/* Turn the error stack off (failures expected) */
- if(H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0)
+ if (H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0)
FAIL_STACK_ERROR
- if(H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0)
+ if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0)
FAIL_STACK_ERROR
h5_fixname(FILENAME[6], fapl_id, filename, sizeof(filename));
check_second_dset = TRUE;
- if(file_ok(filename, fapl_id, check_second_dset)) {
-#if defined H5_HAVE_WIN32_API && !defined (hdf5_EXPORTS)
+ if (file_ok(filename, fapl_id, check_second_dset)) {
+#if defined H5_HAVE_WIN32_API && !defined(hdf5_EXPORTS)
SKIPPED()
HDputs(" the DLL will flush the file even when calling _exit, skip this test temporarily");
#else
@@ -393,7 +387,7 @@ main(void)
else
PASSED();
/* Turn the error stack back on */
- if(H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0)
+ if (H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0)
FAIL_STACK_ERROR
/* TEST 8 */
@@ -401,18 +395,18 @@ main(void)
* afterward and not flushed (w/ SWMR).
*/
TESTING("H5Fflush (part2 with flush and later addition + SWMR)");
- if(vfd_supports_swmr) {
+ if (vfd_supports_swmr) {
/* Turn the error stack off (failures expected) */
- if(H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0)
+ if (H5Eget_auto2(H5E_DEFAULT, &func, NULL) < 0)
FAIL_STACK_ERROR
- if(H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0)
+ if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0)
FAIL_STACK_ERROR
h5_fixname(FILENAME[7], fapl_id, filename, sizeof(filename));
check_second_dset = TRUE;
- if(clear_status_flags(filename, fapl_id) < 0)
+ if (clear_status_flags(filename, fapl_id) < 0)
TEST_ERROR
- if(file_ok(filename, fapl_id, check_second_dset)) {
-#if defined H5_HAVE_WIN32_API && !defined (hdf5_EXPORTS)
+ if (file_ok(filename, fapl_id, check_second_dset)) {
+#if defined H5_HAVE_WIN32_API && !defined(hdf5_EXPORTS)
SKIPPED();
HDputs(" the DLL will flush the file even when calling _exit, skip this test temporarily");
#else
@@ -422,13 +416,13 @@ main(void)
else
PASSED();
/* Turn the error stack back on */
- if(H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0)
+ if (H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0)
FAIL_STACK_ERROR
} /* end if */
else
SKIPPED()
- if(!vfd_supports_swmr)
+ if (!vfd_supports_swmr)
HDprintf("NOTE: Some tests were skipped since the current VFD lacks SWMR support\n");
h5_cleanup(FILENAME, fapl_id);
@@ -438,4 +432,3 @@ main(void)
error:
HDexit(EXIT_FAILURE);
} /* end main() */
-