summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2018-11-13 21:52:08 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2018-11-13 21:52:08 (GMT)
commit67db60c2c293be2a949fadadbe5b8e5fd4fb658a (patch)
treeca9041ee859c0fe36b0251605973ac098ba3b80d
parentfe15b8a0b82b88d909accd92c0ee7c76b6cb0408 (diff)
parentc00b6863571f6af4b3be81185a0ca35823dad7b4 (diff)
downloadhdf5-67db60c2c293be2a949fadadbe5b8e5fd4fb658a.zip
hdf5-67db60c2c293be2a949fadadbe5b8e5fd4fb658a.tar.gz
hdf5-67db60c2c293be2a949fadadbe5b8e5fd4fb658a.tar.bz2
Merge pull request #1333 in HDFFV/hdf5 from ~VCHOI/my_hdf5_fork:hdf5_1_10 to hdf5_1_10
* commit 'c00b6863571f6af4b3be81185a0ca35823dad7b4': Merge pull request #1314 in HDFFV/hdf5 from ~VCHOI/my_hdf5_fork:develop to develop
-rw-r--r--test/use.h2
-rw-r--r--test/use_append_chunk.c115
-rw-r--r--test/use_append_mchunks.c110
-rw-r--r--test/use_common.c142
4 files changed, 209 insertions, 160 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..4e8c672 100644
--- a/test/use_append_chunk.c
+++ b/test/use_append_chunk.c
@@ -124,10 +124,13 @@ 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){
- Hgoto_error(1);
+ Hgoto_error(1);
}
/* Determine the need to send/wait message file*/
@@ -145,20 +148,20 @@ main(int argc, char *argv[])
/* Create file */
/* ============*/
if (UC_opts.launch != UC_READER){
- printf("Creating skeleton data file for test...\n");
- if (create_uc_file() < 0){
- fprintf(stderr, "***encounter error\n");
- Hgoto_error(1);
- }else
- printf("File created.\n");
+ HDprintf("Creating skeleton data file for test...\n");
+ if (create_uc_file() < 0){
+ HDfprintf(stderr, "***encounter error\n");
+ Hgoto_error(1);
+ }else
+ HDprintf("File created.\n");
}
if (UC_opts.launch==UC_READWRITE){
- /* fork process */
- if((childpid = HDfork()) < 0) {
- HDperror("fork");
- Hgoto_error(1);
- };
+ /* fork process */
+ if((childpid = HDfork()) < 0) {
+ HDperror("fork");
+ Hgoto_error(1);
+ };
};
mypid = HDgetpid();
@@ -166,53 +169,83 @@ main(int argc, char *argv[])
/* launch reader */
/* ============= */
if (UC_opts.launch != UC_WRITER){
- /* child process launch the reader */
- if(0 == childpid) {
- printf("%d: launch reader process\n", mypid);
- if (read_uc_file(send_wait) < 0){
- fprintf(stderr, "read_uc_file encountered error\n");
- exit(1);
- }
- exit(0);
- }
+ /* child process launch the reader */
+ if(0 == childpid) {
+ HDprintf("%d: launch reader process\n", mypid);
+ if (read_uc_file(send_wait) < 0){
+ HDfprintf(stderr, "read_uc_file encountered error\n");
+ HDexit(1);
+ }
+ HDexit(0);
+ }
}
/* ============= */
/* launch writer */
/* ============= */
/* 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);
+ HDprintf("%d: continue as the writer process\n", mypid);
+
+ 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) {
+ HDfprintf(stderr, "H5Fopen failed\n");
+ Hgoto_error(1);
+ }
+
+ if(write_uc_file(send_wait, fid) < 0) {
+ HDfprintf(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) {
+ HDfprintf(stderr, "Failed to close file id\n");
+ Hgoto_error(1);
+ }
+
+ /* Close the property list */
+ if(H5Pclose(fapl) < 0) {
+ HDfprintf(stderr, "Failed to close the property list\n");
+ Hgoto_error(1);
+ }
+
+ if (WIFEXITED(child_status)){
+ if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
+ HDprintf("%d: child process exited with non-zero code (%d)\n",
+ mypid, child_ret_value);
+ Hgoto_error(2);
+ }
+ } else {
+ HDprintf("%d: child process terminated abnormally\n", mypid);
+ Hgoto_error(2);
+ }
}
done:
/* Print result and exit */
if (ret_value != 0){
- printf("Error(s) encountered\n");
+ HDprintf("Error(s) encountered\n");
}else{
- printf("All passed\n");
+ HDprintf("All passed\n");
}
return(ret_value);
diff --git a/test/use_append_mchunks.c b/test/use_append_mchunks.c
index 9ee37cb..0414628 100644
--- a/test/use_append_mchunks.c
+++ b/test/use_append_mchunks.c
@@ -117,10 +117,13 @@ 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){
- Hgoto_error(1);
+ Hgoto_error(1);
}
/* Determine the need to send/wait message file*/
@@ -138,20 +141,20 @@ main(int argc, char *argv[])
/* Create file */
/* ============*/
if (UC_opts.launch != UC_READER){
- printf("Creating skeleton data file for test...\n");
+ HDprintf("Creating skeleton data file for test...\n");
if (create_uc_file() < 0){
- fprintf(stderr, "***encounter error\n");
+ HDfprintf(stderr, "***encounter error\n");
Hgoto_error(1);
}else
- printf("File created.\n");
+ HDprintf("File created.\n");
}
if (UC_opts.launch==UC_READWRITE){
- /* fork process */
- if((childpid = fork()) < 0) {
- perror("fork");
- Hgoto_error(1);
- };
+ /* fork process */
+ if((childpid = fork()) < 0) {
+ perror("fork");
+ Hgoto_error(1);
+ };
};
mypid = getpid();
@@ -159,53 +162,84 @@ main(int argc, char *argv[])
/* launch reader */
/* ============= */
if (UC_opts.launch != UC_WRITER){
- /* child process launch the reader */
- if(0 == childpid) {
- printf("%d: launch reader process\n", mypid);
- if (read_uc_file(send_wait) < 0){
- fprintf(stderr, "read_uc_file encountered error\n");
- exit(1);
- }
- exit(0);
- }
+ /* child process launch the reader */
+ if(0 == childpid) {
+ HDprintf("%d: launch reader process\n", mypid);
+ if (read_uc_file(send_wait) < 0){
+ HDfprintf(stderr, "read_uc_file encountered error\n");
+ HDexit(1);
+ }
+ HDexit(0);
+ }
}
/* ============= */
/* launch writer */
/* ============= */
/* 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);
+ HDprintf("%d: continue as the writer process\n", mypid);
+
+ 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) {
+ HDfprintf(stderr, "H5Fopen failed\n");
+ Hgoto_error(1);
+ }
+
+ if(write_uc_file(send_wait, fid) < 0) {
+ HDfprintf(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) {
+ HDfprintf(stderr, "Failed to close file id\n");
+ Hgoto_error(1);
+ }
+
+ /* Close the property list */
+ if(H5Pclose(fapl) < 0) {
+ HDfprintf(stderr, "Failed to close the property list\n");
+ Hgoto_error(1);
+ }
+
+ if (WIFEXITED(child_status)){
+ if ((child_ret_value=WEXITSTATUS(child_status)) != 0){
+ HDprintf("%d: child process exited with non-zero code (%d)\n",
+ mypid, child_ret_value);
+ Hgoto_error(1);
+ }
+ } else {
+ HDprintf("%d: child process terminated abnormally\n", mypid);
+ Hgoto_error(2);
+ }
}
done:
/* Print result and exit */
if (ret_value != 0){
- printf("Error(s) encountered\n");
+ HDprintf("Error(s) encountered\n");
}else{
- printf("All passed\n");
+ HDprintf("All passed\n");
}
return(ret_value);
diff --git a/test/use_common.c b/test/use_common.c
index 5aa6692..3ecb2e1 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;
}
@@ -471,7 +447,7 @@ int read_uc_file(hbool_t towait)
/* Before reading, wait for the message that H5Fopen is complete--file lock is released */
if(towait && h5_wait_message(WRITER_MESSAGE) < 0) {
- fprintf(stderr, "Cannot find writer message file...failed\n");
+ HDfprintf(stderr, "Cannot find writer message file...failed\n");
return -1;
}
@@ -481,19 +457,19 @@ int read_uc_file(hbool_t towait)
if((fapl = h5_fileaccess()) < 0)
return -1;
if((fid = H5Fopen(name, H5F_ACC_RDONLY | (UC_opts.use_swmr ? H5F_ACC_SWMR_READ : 0), fapl)) < 0){
- fprintf(stderr, "H5Fopen failed\n");
+ HDfprintf(stderr, "H5Fopen failed\n");
return -1;
}
if (H5Pclose(fapl) < 0){
- fprintf(stderr, "Failed to property list\n");
+ HDfprintf(stderr, "Failed to property list\n");
return -1;
}
/* Open the dataset of the program name */
if((dsid = H5Dopen2(fid, progname_g, H5P_DEFAULT)) < 0){
- fprintf(stderr, "H5Dopen2 failed\n");
- return -1;
+ HDfprintf(stderr, "H5Dopen2 failed\n");
+ return -1;
}
/* allocate space for data buffer 1 X dims[1] X dims[2] of UC_CTYPE */
@@ -501,8 +477,8 @@ int read_uc_file(hbool_t towait)
memdims[1] = UC_opts.dims[1];
memdims[2] = UC_opts.dims[2];
if ((buffer=(UC_CTYPE*)HDmalloc((size_t)memdims[1]*(size_t)memdims[2]*sizeof(UC_CTYPE)))==NULL) {
- fprintf(stderr, "malloc: failed\n");
- return -1;
+ HDfprintf(stderr, "malloc: failed\n");
+ return -1;
};
/*
@@ -512,31 +488,31 @@ int read_uc_file(hbool_t towait)
f_sid = H5Dget_space(dsid); /* Get filespace handle first. */
rank = H5Sget_simple_extent_ndims(f_sid);
if (rank != UC_RANK){
- fprintf(stderr, "rank(%d) of dataset does not match\n", rank);
- return -1;
+ HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank);
+ return -1;
}
if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0){
- fprintf(stderr, "H5Sget_simple_extent_dims got error\n");
- return -1;
+ HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n");
+ return -1;
}
- printf("dataset rank %d, dimensions %llu x %llu x %llu\n",
- rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]),
- (unsigned long long)(dims[2]));
+ HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n",
+ rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]),
+ (unsigned long long)(dims[2]));
/* verify that file space dims are as expected and are consistent with memory space dims */
if (dims[1] != memdims[1] || dims[2] != memdims[2]){
- fprintf(stderr, "dataset dimension is not as expected. Got dims=(%llu,%llu,%llu)\n",
- (unsigned long long)dims[0], (unsigned long long)dims[1],
+ HDfprintf(stderr, "dataset dimension is not as expected. Got dims=(%llu,%llu,%llu)\n",
+ (unsigned long long)dims[0], (unsigned long long)dims[1],
(unsigned long long)dims[2]);
- fprintf(stderr, "But memdims=(%llu,%llu,%llu)\n",
- (unsigned long long)memdims[0], (unsigned long long)memdims[1],
+ HDfprintf(stderr, "But memdims=(%llu,%llu,%llu)\n",
+ (unsigned long long)memdims[0], (unsigned long long)memdims[1],
(unsigned long long)memdims[2]);
- return -1;
+ return -1;
}
/* setup mem-space for buffer */
if ((m_sid=H5Screate_simple(rank, memdims, NULL))<0){
- fprintf(stderr, "H5Screate_simple for memory failed\n");
- return -1;
+ HDfprintf(stderr, "H5Screate_simple for memory failed\n");
+ return -1;
};
/* Read 1 plane at a time whenever the dataset grows larger
@@ -550,22 +526,22 @@ int read_uc_file(hbool_t towait)
/* print progress message according to if new planes are availalbe */
if (nplane_old < dims[0]) {
if (nonewplane){
- /* end the previous message */
- printf("\n");
- nonewplane=0;
+ /* end the previous message */
+ HDprintf("\n");
+ nonewplane=0;
}
- printf("reading planes %llu to %llu\n", (unsigned long long)nplane_old,
+ HDprintf("reading planes %llu to %llu\n", (unsigned long long)nplane_old,
(unsigned long long)dims[0]);
}else{
if (nonewplane){
- printf(".");
+ HDprintf(".");
if (nonewplane>=30){
- fprintf(stderr, "waited too long for new plane, quit.\n");
+ HDfprintf(stderr, "waited too long for new plane, quit.\n");
return -1;
}
}else{
- /* print mesg only the first time; dots still no new plane */
- printf("no new planes to read ");
+ /* print mesg only the first time; dots still no new plane */
+ HDprintf("no new planes to read ");
}
nonewplane++;
/* pause for a second */
@@ -575,41 +551,41 @@ int read_uc_file(hbool_t towait)
/* read planes between last old nplanes and current extent */
/* Get the dataset's dataspace */
if((f_sid = H5Dget_space(dsid)) < 0){
- fprintf(stderr, "H5Dget_space failed\n");
- return -1;
+ HDfprintf(stderr, "H5Dget_space failed\n");
+ return -1;
}
start[0]=nplane;
/* Choose the next plane to read */
if(H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0){
- fprintf(stderr, "H5Sselect_hyperslab failed\n");
- return -1;
+ HDfprintf(stderr, "H5Sselect_hyperslab failed\n");
+ return -1;
}
/* Read the plane from the dataset */
if(H5Dread(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0){
- fprintf(stderr, "H5Dread failed\n");
- return -1;
+ HDfprintf(stderr, "H5Dread failed\n");
+ return -1;
}
/* compare read data with expected data value which is nplane */
bufptr = buffer;
nerrs=0;
for (j=0; j<dims[1]; j++){
- for (k=0; k<dims[2]; k++){
- if ((hsize_t)*bufptr++ != nplane){
- if (++nerrs < ErrorReportMax){
- fprintf(stderr,
- "found error %llu plane(%llu,%llu), expected %llu, got %d\n",
- (unsigned long long)nplane, (unsigned long long)j,
- (unsigned long long)k, (unsigned long long)nplane, (int)*(bufptr-1));
- }
- }
- }
+ for (k=0; k<dims[2]; k++){
+ if ((hsize_t)*bufptr++ != nplane){
+ if (++nerrs < ErrorReportMax){
+ HDfprintf(stderr,
+ "found error %llu plane(%llu,%llu), expected %llu, got %d\n",
+ (unsigned long long)nplane, (unsigned long long)j,
+ (unsigned long long)k, (unsigned long long)nplane, (int)*(bufptr-1));
+ }
+ }
+ }
}
if (nerrs){
- nreadererr++;
- fprintf(stderr, "found %d unexpected values in plane %llu\n", nerrs,
+ nreadererr++;
+ HDfprintf(stderr, "found %d unexpected values in plane %llu\n", nerrs,
(unsigned long long)nplane);
}
}
@@ -620,19 +596,19 @@ int read_uc_file(hbool_t towait)
#if 0
/* close dsid and file, then reopen them */
if (H5Dclose(dsid) < 0){
- fprintf(stderr, "H5Dclose failed\n");
+ HDfprintf(stderr, "H5Dclose failed\n");
return -1;
}
if (H5Fclose(fid) < 0){
- fprintf(stderr, "H5Fclose failed\n");
+ HDfprintf(stderr, "H5Fclose failed\n");
return -1;
}
if((fid = H5Fopen(name, H5F_ACC_RDONLY | (UC_opts.use_swmr ? H5F_ACC_SWMR_READ : 0), H5P_DEFAULT)) < 0){
- fprintf(stderr, "H5Fopen failed\n");
+ HDfprintf(stderr, "H5Fopen failed\n");
return -1;
}
if((dsid = H5Dopen2(fid, progname_g, H5P_DEFAULT)) < 0){
- fprintf(stderr, "H5Dopen2 failed\n");
+ HDfprintf(stderr, "H5Dopen2 failed\n");
return -1;
}
#else
@@ -640,16 +616,22 @@ int read_uc_file(hbool_t towait)
#endif
f_sid = H5Dget_space(dsid); /* Get filespace handle first. */
if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0){
- fprintf(stderr, "H5Sget_simple_extent_dims got error\n");
+ HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n");
return -1;
}
}
+ /* Close the file */
+ if(H5Fclose(fid) < 0) {
+ HDfprintf(stderr, "H5Fclose failed\n");
+ return -1;
+ }
+
if (nreadererr)
- return -1;
+ return -1;
else
- return 0;
-}
+ return 0;
+} /* read_uc_file() */
#endif /* H5_HAVE_FORK */