summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/use.h2
-rw-r--r--test/use_append_chunk.c67
-rw-r--r--test/use_append_mchunks.c68
-rw-r--r--test/use_common.c32
4 files changed, 109 insertions, 60 deletions
diff --git a/test/use.h b/test/use.h
index 0885cc5..54d9b26 100644
--- a/test/use.h
+++ b/test/use.h
@@ -58,6 +58,6 @@ int setup_parameters(int argc, char * const argv[]);
void show_parameters(void);
void usage(const char *prog);
int create_uc_file(void);
-int write_uc_file(hbool_t tosend);
+int write_uc_file(hbool_t tosend, hid_t fid);
int read_uc_file(hbool_t towait);
diff --git a/test/use_append_chunk.c b/test/use_append_chunk.c
index 005eb51..7dda732 100644
--- a/test/use_append_chunk.c
+++ b/test/use_append_chunk.c
@@ -124,6 +124,9 @@ main(int argc, char *argv[])
int ret_value = 0;
int child_ret_value;
hbool_t send_wait = FALSE;
+ hid_t fapl = -1; /* File access property list */
+ hid_t fid = -1; /* File ID */
+ char *name; /* Test file name */
/* initialization */
if (setup_parameters(argc, argv) < 0){
@@ -182,29 +185,59 @@ main(int argc, char *argv[])
/* ============= */
/* this process continues to launch the writer */
printf("%d: continue as the writer process\n", mypid);
- if (write_uc_file(send_wait) < 0){
- fprintf(stderr, "write_uc_file encountered error\n");
- Hgoto_error(1);
+
+ name = UC_opts.filename;
+
+ /* Set file access proeprty list */
+ if((fapl = h5_fileaccess()) < 0)
+ Hgoto_error(1);
+
+ if(UC_opts.use_swmr)
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ Hgoto_error(1);
+
+ /* Open the file */
+ if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) {
+ fprintf(stderr, "H5Fopen failed\n");
+ Hgoto_error(1);
+ }
+
+ if(write_uc_file(send_wait, fid) < 0) {
+ fprintf(stderr, "write_uc_file encountered error\n");
+ Hgoto_error(1);
}
/* ================================================ */
/* If readwrite, collect exit code of child process */
/* ================================================ */
if (UC_opts.launch == UC_READWRITE){
- if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0){
- HDperror("waitpid");
- Hgoto_error(1);
- }
- if (WIFEXITED(child_status)){
- if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
- printf("%d: child process exited with non-zero code (%d)\n",
- mypid, child_ret_value);
- Hgoto_error(2);
- }
- } else {
- printf("%d: child process terminated abnormally\n", mypid);
- Hgoto_error(2);
- }
+ if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0){
+ HDperror("waitpid");
+ Hgoto_error(1);
+ }
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0) {
+ fprintf(stderr, "Failed to close file id\n");
+ Hgoto_error(1);
+ }
+
+ /* Close the property list */
+ if(H5Pclose(fapl) < 0) {
+ fprintf(stderr, "Failed to property list\n");
+ Hgoto_error(1);
+ }
+
+ if (WIFEXITED(child_status)){
+ if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
+ printf("%d: child process exited with non-zero code (%d)\n",
+ mypid, child_ret_value);
+ Hgoto_error(2);
+ }
+ } else {
+ printf("%d: child process terminated abnormally\n", mypid);
+ Hgoto_error(2);
+ }
}
done:
diff --git a/test/use_append_mchunks.c b/test/use_append_mchunks.c
index 9ee37cb..2dc7bdb 100644
--- a/test/use_append_mchunks.c
+++ b/test/use_append_mchunks.c
@@ -117,6 +117,9 @@ main(int argc, char *argv[])
int ret_value = 0;
int child_ret_value;
hbool_t send_wait = 0;
+ hid_t fapl = -1; /* File access property list */
+ hid_t fid = -1; /* File ID */
+ char *name; /* Test file name */
/* initialization */
if (setup_parameters(argc, argv) < 0){
@@ -175,29 +178,60 @@ main(int argc, char *argv[])
/* ============= */
/* this process continues to launch the writer */
printf("%d: continue as the writer process\n", mypid);
- if (write_uc_file(send_wait) < 0){
- fprintf(stderr, "write_uc_file encountered error\n");
- Hgoto_error(1);
+
+ name = UC_opts.filename;
+
+ /* Set the file access property list */
+ if((fapl = h5_fileaccess()) < 0)
+ Hgoto_error(1);
+
+ if(UC_opts.use_swmr)
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ Hgoto_error(1);
+
+ /* Open the file */
+ if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) {
+ fprintf(stderr, "H5Fopen failed\n");
+ Hgoto_error(1);
+ }
+
+ if(write_uc_file(send_wait, fid) < 0) {
+ fprintf(stderr, "write_uc_file encountered error\n");
+ Hgoto_error(1);
}
+
/* ================================================ */
/* If readwrite, collect exit code of child process */
/* ================================================ */
if (UC_opts.launch == UC_READWRITE){
- if ((tmppid = waitpid(childpid, &child_status, child_wait_option)) < 0){
- perror("waitpid");
- Hgoto_error(1);
- }
- if (WIFEXITED(child_status)){
- if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
- printf("%d: child process exited with non-zero code (%d)\n",
- mypid, child_ret_value);
- Hgoto_error(2);
- }
- } else {
- printf("%d: child process terminated abnormally\n", mypid);
- Hgoto_error(2);
- }
+ if ((tmppid = waitpid(childpid, &child_status, child_wait_option)) < 0){
+ perror("waitpid");
+ Hgoto_error(1);
+ }
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0) {
+ fprintf(stderr, "Failed to close file id\n");
+ Hgoto_error(1);
+ }
+
+ /* Close the property list */
+ if(H5Pclose(fapl) < 0) {
+ fprintf(stderr, "Failed to property list\n");
+ Hgoto_error(1);
+ }
+
+ if (WIFEXITED(child_status)){
+ if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
+ printf("%d: child process exited with non-zero code (%d)\n",
+ mypid, child_ret_value);
+ Hgoto_error(1);
+ }
+ } else {
+ printf("%d: child process terminated abnormally\n", mypid);
+ Hgoto_error(2);
+ }
}
done:
diff --git a/test/use_common.c b/test/use_common.c
index 5aa6692..164480f 100644
--- a/test/use_common.c
+++ b/test/use_common.c
@@ -252,13 +252,10 @@ int create_uc_file(void)
*
* Return: 0 succeed; -1 fail.
*/
-int write_uc_file(hbool_t tosend)
+int write_uc_file(hbool_t tosend, hid_t fid)
{
- hid_t fid; /* File ID for new HDF5 file */
hid_t dsid; /* dataset ID */
- hid_t fapl; /* File access property list */
hid_t dcpl; /* Dataset creation property list */
- char *name;
UC_CTYPE *buffer, *bufptr; /* data buffer */
hsize_t cz=UC_opts.chunksize; /* Chunk size */
hid_t f_sid; /* dataset file space id */
@@ -270,19 +267,6 @@ int write_uc_file(hbool_t tosend)
hsize_t start[3] = {0,0,0}, count[3]; /* Hyperslab selection values */
hsize_t i, j, k;
- name = UC_opts.filename;
-
- /* Open the file */
- if((fapl = h5_fileaccess()) < 0)
- return -1;
- if(UC_opts.use_swmr)
- if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
- return -1;
- if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0){
- fprintf(stderr, "H5Fopen failed\n");
- return -1;
- }
-
if(tosend)
/* Send a message that H5Fopen is complete--releasing the file lock */
h5_send_message(WRITER_MESSAGE, NULL, NULL);
@@ -427,14 +411,6 @@ int write_uc_file(hbool_t tosend)
fprintf(stderr, "Failed to close file space\n");
return -1;
}
- if (H5Pclose(fapl) < 0){
- fprintf(stderr, "Failed to property list\n");
- return -1;
- }
- if (H5Fclose(fid) < 0){
- fprintf(stderr, "Failed to close file id\n");
- return -1;
- }
return 0;
}
@@ -645,6 +621,12 @@ int read_uc_file(hbool_t towait)
}
}
+ /* Close the file */
+ if(H5Fclose(fid) < 0) {
+ fprintf(stderr, "H5Fclose failed\n");
+ return -1;
+ }
+
if (nreadererr)
return -1;
else