summaryrefslogtreecommitdiffstats
path: root/test/vfd_swmr_reader.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/vfd_swmr_reader.c')
-rw-r--r--test/vfd_swmr_reader.c66
1 files changed, 32 insertions, 34 deletions
diff --git a/test/vfd_swmr_reader.c b/test/vfd_swmr_reader.c
index d074771..da7cb50 100644
--- a/test/vfd_swmr_reader.c
+++ b/test/vfd_swmr_reader.c
@@ -14,15 +14,13 @@
/*-------------------------------------------------------------------------
*
* Created: vfd_swmr_reader.c
+ * (copied and modified from swmr_reader.c)
*
* Purpose: Reads data from a randomly selected subset of the datasets
- * in the SWMR test file.
+ * in the VFD SWMR test file.
*
* This program is intended to run concurrently with the
- * swmr_writer program.
- *
- * This is copied from swmr_reader.c and modified for testing
- * with VFD SWMR.
+ * vfd_swmr_writer program.
*
*-------------------------------------------------------------------------
*/
@@ -208,7 +206,7 @@ read_records(const char *filename, hbool_t verbose, FILE *verbose_file,
symbol_t record; /* The record to read from the dataset */
unsigned v; /* Local index variable */
hbool_t use_log_vfd = FALSE; /* Use the log VFD (set this manually) */
-H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */
+ H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */
HDassert(filename);
HDassert(nseconds != 0);
@@ -284,11 +282,33 @@ H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */
if(use_log_vfd) {
char verbose_name[1024];
- HDsnprintf(verbose_name, sizeof(verbose_name), "swmr_reader.log.%u", random_seed);
+ HDsnprintf(verbose_name, sizeof(verbose_name), "vfd_swmr_reader.log.%u", random_seed);
H5Pset_fapl_log(fapl, verbose_name, H5FD_LOG_ALL, (size_t)(512 * 1024 * 1024));
} /* end if */
+ /*
+ * Set up to open the file with VFD SWMR configured.
+ */
+ /* Enable page buffering */
+ if(H5Pset_page_buffer_size(fapl, 4096, 0, 0) < 0)
+ return -1;
+
+ /* Allocate memory for the configuration structure */
+ if((config = (H5F_vfd_swmr_config_t *)HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL)
+ return -1;
+
+ config->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION;
+ config->tick_len = 4;
+ config->max_lag = 6;
+ config->vfd_swmr_writer = FALSE;
+ config->md_pages_reserved = 2;
+ HDstrcpy(config->md_file_path, "./my_md_file");
+
+ /* Enable VFD SWMR configuration */
+ if(H5Pset_vfd_swmr_config(fapl, config) < 0)
+ return -1;
+
/* Loop over reading records until [at least] the correct # of seconds have passed */
while(curr_time < (time_t)(start_time + (time_t)nseconds)) {
@@ -296,28 +316,6 @@ H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */
if(verbose)
HDfprintf(verbose_file, "Opening file: %s\n", filename);
- /*
- * Set up to open the file with VFD SWMR configured.
- */
- /* Enable page buffering */
- if(H5Pset_page_buffer_size(fapl, 4096, 0, 0) < 0)
- return -1;
-
- /* Allocate memory for the configuration structure */
- if((config = (H5F_vfd_swmr_config_t *)HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL)
- return -1;
-
- config->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION;
- config->tick_len = 4;
- config->max_lag = 6;
- config->vfd_swmr_writer = FALSE;
- config->md_pages_reserved = 2;
- HDstrcpy(config->md_file_path, "./my_md_file");
-
- /* Enable VFD SWMR configuration */
- if(H5Pset_vfd_swmr_config(fapl, config) < 0)
- return -1;
-
/* Open the file with VFD SWMR configured */
if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
return -1;
@@ -375,6 +373,9 @@ H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */
if(H5Pclose(fapl) < 0)
return -1;
+ if(config)
+ HDfree(config);
+
/* Emit informational message */
if(verbose)
HDfprintf(verbose_file, "Closing datasets\n");
@@ -391,9 +392,6 @@ H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */
HDfree(sym_com);
} /* end if */
- /* Free the config structure */
- if(config)
- HDfree(config);
return 0;
} /* end read_records() */
@@ -403,7 +401,7 @@ usage(void)
printf("\n");
printf("Usage error!\n");
printf("\n");
- printf("Usage: swmr_reader [-q] [-s <# of seconds to sleep between polling>]\n");
+ printf("Usage: vfd_swmr_reader [-q] [-s <# of seconds to sleep between polling>]\n");
printf(" [-h <# of common symbols to poll>] [-l <# of random symbols to poll>]\n");
printf(" [-r <random seed>] <# of seconds to test>\n");
printf("\n");
@@ -511,7 +509,7 @@ int main(int argc, const char *argv[])
if(verbose) {
char verbose_name[1024];
- HDsnprintf(verbose_name, sizeof(verbose_name), "swmr_reader.out.%u", random_seed);
+ HDsnprintf(verbose_name, sizeof(verbose_name), "vfd_swmr_reader.out.%u", random_seed);
if(NULL == (verbose_file = HDfopen(verbose_name, "w"))) {
HDfprintf(stderr, "Can't open verbose output file!\n");
HDexit(1);